Intel Math Kernel on windows, call from C # to generate random numbers

Has anyone used the Intel Math Kernel library http://software.intel.com/en-us/intel-mkl/

I am thinking of using this to generate random numbers from a C # application , since we need maximum performance (1.6 trillion random numbers per day).

Also any recommendations for minimizing the overhead of consuming functions from this C ++ code in my C # Monte Carlo simulator .

  • I am going to download Eval from the site and above and try and compare this with my C # application, any help that is much appreciated.

thanks

+4
source share
7 answers

I developed monte carlo / stochastic software that uses MKL and Intel compiler. In general, you will have to wrap the random number generation in a C ++ dll. This is the easiest way, since you can control the management of names and calls. As for minimizing overhead, the best way to do this is to save the simulation code completely in C ++, where it probably still belongs, and only to call C # you need to get an update. The only way to minimize the penalty for interference is to make fewer calls, I found another piece of advice (/ unsafe, etc.) Useless in terms of performance. You can see an example of the interaction and structure of this type of program in my project repository - Stochfit .

+1
source

I don't know anything about this library. But if this is really C ++ code, you cannot call it directly from C #. C # can only interact with C ++ in one of three ways.

  • PInvoke in C shell on top of C ++ lib
  • COM Interop
  • Reverse PInvoke (still need 1 or 2 above to insert wrapper function)

If this is a large C ++ code base, it might be best to create a thin C ++ / CLI shell to interact with the library. Then call it from C #.

+1
source

Declare the function call as β€œstatic” (although I'm not sure if this will matter) and make sure your benchmarking compares the DLL call with the built-in C # Random class. I'm not sure Intel code will be much faster, but who knows?

0
source

1) The link says that "it includes improved integration with Microsoft Visual Studio"

2) There is an evaluation version

So why not give it a try? Intel may have already provided the necessary bindings. Or not. At least you will not spend money on useless software.

0
source

Here's a highly efficient random number generator in C # . This code will be more efficient when calling C ++. Even if your C ++ code runs at zero time, you still have to move the overhead from managed code to unmanaged coded and vice versa.

0
source

Something that may or may not be obvious to you: calls across managed and unmanaged code boundaries are slow, so if you go this route, you probably want to extract blocks of random numbers in large batches to amortize the call time.

0
source

Intel has a set of examples demonstrating a MKL call from C # http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program

0
source

All Articles