Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

vslNewStream() & kmp_sharable_malloc()

jbakosi
Beginner
458 Views
Hello,

I'm trying to port a working OpenMP code to Cluster OpenMP. For a Monte-Carlo simulation I generate random numbers in parallel with the MKL VSL routines employing the block-splitting technique to split random number streams and sample from them independently. Thus I use several vslNewStream() calls to create an array of stream pointers dynamically, depending on the number of threads available.

For dynamically allocated sharable arrays the Cluster OpenMP manual advises to use kmp_sharable_malloc / kmp_sharable_free pairs instead of malloc / free.

My question is the following. Are there corresponding Cluster-OpenMP-compatible calls to create random number streams that create sharable streams? Or is there any other way to resolve this issue?

Thank you,
Jozsef
0 Kudos
2 Replies
Ilya_B_Intel
Employee
458 Views

Jozsef,

There are currently no versions of Cluster-OpenMP-compatible create new shareable stream functions.

If I understand you right you are currently usingVSL in the following way:

- Allocatean array of stream state descriptors
- Loop of calling vslNewStream to initialize descriptors
- Cluster OpenMP section:
{
- SkipAhead / Leapfrogfor theStream used in this thread
- Generating and using random numbers
}

Thus you will definetely obtain problems because there are some unshareable memory allocated by vslNewStream. Though if you modify your code by the following way:

-Declare1 stream state descriptors (say, LocalStream)
- Cluster OpenMP section, where LocalStream isdeclared asprivate
{
- Call vslNewStream to initialize private LocalStream
- SkipAhead / Leapfrogfor theLocalStream to be used in this thread
- Generating and using random numbers
- Delete LocalStream
}

Thus vslNewStream does not need to allocate shareable memory...

Does it solve your problem?

Thank you,
Ilya

0 Kudos
jbakosi
Beginner
458 Views
Ilya,

excellent! Works like a charm and it also scales very similarly, even with Cluster OpenMP.

Thank you, your answer was very helpful.
Jozsef
0 Kudos
Reply