Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
6743 Discussions

Visual Studio C# and Intel(R) Xeon(R) CPU E3110 @ 3.00Ghz, 4.00 GB of RAM

darkcminor
Beginner
258 Views

What would be the best configuration to get advantage of this Intel preprocessor using MKLI want to use C# .NET?
Intel Xeon CPU E3110 @ 3.00Ghz, 4.00 GB of RAM
I use this page to get an ideahttp://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/And gotmkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib /Qopenmpthere it says to set the PATH, LIB and INCLUDE environment variables in the command shell using one of mklvars script files in the 'bin' subdirectory of the Intel MKL installation directory.Is this correct?I was using LAPACKE_dgesvd in C#, butI want to use multicore and threaded functions what would be theThreaded Function for LAPACKE_dgesvd?[DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void LAPACKE_dgesvd(
int matrix_order,
char a1,
char a2,
int m,
int n,
[In, Out] double[] input_matrix,
int lda,
[In, Out] double[] s,
[In, Out] double[] u,
int ldu,
[In, Out] double[] vt,
int ldvt,
double[] superb
);I was thinking that a possibilitie would be to put somewhere in the C# code theOMP_NUM_THREADS...

0 Kudos
1 Solution
Ying_H_Intel
Employee
258 Views
Hi darkcminor,

It is good topic. In general,there is two ways touseMKL in C#
1) import custom dll
If you want to use threaded function in C#, then when build the custom dll, use command like
nmake libia32 export=my_function_list name=my_dll threading=parallel
the custom dll tool is under C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl\tools\builder

by default is paralle is on.

2) import mkl_rt.dll
You are right, if forall kind ofconfigurations, you may try set sytem environment MKL_THREADING_LAYER or import the function of mkl_set_interface_layer(), then call it before callLAPACKE_dgesvd in C#.

Here is some help documentation:
http://software.intel.com/en-us/articles/a-new-linking-model-single-dynamic-library-mkl_rt-since-intel-mkl-103/
Using the Intel MKL Dynamic Interface for Windows OS
and mkl user guide: Using the Single Dynamic Library Interface

Butby default, Inte threading ison too. So you don't need to do special setting for multi-core /parallel in C#.

Just in case, please make sure the related dlls are in system environment as the artice show

http://software.intel.com/en-us/articles/some-more-additional-tips-how-to-call-mkl-from-your-c-code/
or right click my computer-> properies> advanced system setting> advanced tab >Environment variable> System variable>path.
(By default, the installer will configure the MKL path, so no work need to do also)


Best Regards,
Ying

View solution in original post

2 Replies
Ying_H_Intel
Employee
259 Views
Hi darkcminor,

It is good topic. In general,there is two ways touseMKL in C#
1) import custom dll
If you want to use threaded function in C#, then when build the custom dll, use command like
nmake libia32 export=my_function_list name=my_dll threading=parallel
the custom dll tool is under C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl\tools\builder

by default is paralle is on.

2) import mkl_rt.dll
You are right, if forall kind ofconfigurations, you may try set sytem environment MKL_THREADING_LAYER or import the function of mkl_set_interface_layer(), then call it before callLAPACKE_dgesvd in C#.

Here is some help documentation:
http://software.intel.com/en-us/articles/a-new-linking-model-single-dynamic-library-mkl_rt-since-intel-mkl-103/
Using the Intel MKL Dynamic Interface for Windows OS
and mkl user guide: Using the Single Dynamic Library Interface

Butby default, Inte threading ison too. So you don't need to do special setting for multi-core /parallel in C#.

Just in case, please make sure the related dlls are in system environment as the artice show

http://software.intel.com/en-us/articles/some-more-additional-tips-how-to-call-mkl-from-your-c-code/
or right click my computer-> properies> advanced system setting> advanced tab >Environment variable> System variable>path.
(By default, the installer will configure the MKL path, so no work need to do also)


Best Regards,
Ying
SergeyKostrov
Valued Contributor II
258 Views
>>...would be to put somewhere in the C# code theOMP_NUM_THREADS...

Even if you can set the OMP_NUM_THREADS environment variable with some value from your application it won't work.

The reason is simple: OMP_NUM_THREADS has to be set before an application loads OpenMP DLL. In case of
a Visual Studio these are 'vcomp.dll' ( Release ) or 'vcompd.dll' ( Debug ) DLLs.

In a C/C++ application youcould use an'omp_set_num_threads' OpenMP function.
Reply