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

vslCopyStreamState fails

Guillaume_A_
New Contributor II
724 Views

Hello,

Since I upgraded MKL from 2024.0.0 to 2025.1.0 I observe crashes around the vslCopyStreamState method.

 

This simple program will fail on Linux OS:

#include <iostream>
#include <mkl_vsl.h>

int main()
{
    unsigned int scrambledSobolMaxBit = 32;
    unsigned int dimension = 399;

    int z = 0;
    for (; z < 100; z++)
    {
        std::cout <<"z:" << z <<"\n";

        unsigned int nbParameters = 3 + scrambledSobolMaxBit * dimension;
        unsigned int* parameters = new unsigned int[nbParameters];
        
        int k = 0;
        parameters[k++] = dimension;
        parameters[k++] = VSL_USER_QRNG_INITIAL_VALUES;
        parameters[k++] = VSL_USER_DIRECTION_NUMBERS;
        for (; k < nbParameters; k++)
        {
            parameters[k] = 0;
        }

        VSLStreamStatePtr rngState;
        if (vslNewStreamEx(&rngState, VSL_BRNG_SOBOL, nbParameters, parameters) != VSL_STATUS_OK)
        {
            std::cout <<"fail to vslNewStreamEx rngState" <<"\n";
            return 1;
        }
        VSLStreamStatePtr tempState;
        if (vslNewStreamEx(&tempState, VSL_BRNG_SOBOL, nbParameters, parameters) != VSL_STATUS_OK)
        {
            std::cout <<"fail to vslNewStreamEx tempState" <<"\n";
            return 1;
        }
        delete[] parameters;
        std::cout <<"\t0\n";

        if (vslCopyStreamState(tempState, rngState) != VSL_STATUS_OK)
        {
            std::cout << "\t0\t"<< "\tfail to copy streamState" <<"\n";
            return 1;
        }
        
        // no prb if use below commented code
        /*
        if (vslDeleteStream(&tempState) != VSL_STATUS_OK)
        {
            std::cout << "\t0\t"<< "\tfail to vslDeleteStream" <<"\n";
            return 1;
        }
        if (vslCopyStream(&tempState, rngState) != VSL_STATUS_OK)
        {
            std::cout << "\t0\t"<< "\tfail to vslCopyStream" <<"\n";
            return 1;
        }
        */

        std::cout << "\t1\n";

        vslDeleteStream(&rngState);
        vslDeleteStream(&tempState);
    }
    return 0;
}

 The program crashs during the first vslCopyStreamState and show the msg: 

 

free(): invalid pointer
Aborted (core dumped)

 

 

Useful infos:

Compilation options:
-DISOLATION_AWARE_ENABLED -std=gnu++17 -m64 -mavx -axCORE-AVX2,CORE-AVX512 -fthreadsafe-statics -fexceptions -frtti -fomit-frame-pointer -fno-strict-aliasing -O0 -g2 -gdwarf-2 -fPIE -MD -MT

Link options:
-pie -m64 -static-libgcc -static-libstdc++ -static-intel -Wl,--start-group libmkl_intel_lp64.a libmkl_sequential.a libmkl_core.a -Wl,--end-group -lpthread -ldl

Cpuinfo:
  vendor_id : AuthenticAMD
  model name : AMD EPYC-Rome Processor

OS:
  Red Hat Enterprise Linux release 9.5

Env:
  gcc == 13.1.0
  gxx == 13.1.0
  dpcpp_linux-64 == 2025.0.4
  mkl-static == 2025.1.0

 

 

 

Fun facts:

  • the program works fine with dimension <= 398.
  • the program works fine if comment the first std::cout (line 12).
  • the program works fine with the similar method vslCopyStream
  • the program works fine with MKL 2024.0.0
  • the same code crashs randomly on Windows 11 with an Intel(R) Xeon(R) W-11955M... 

 

Regards,

Guillaume A.

 

0 Kudos
7 Replies
Aleksandra_K
Moderator
606 Views

Hi Guillaume,

Could you specify how you are running the code? I tried icpx with the compilation and link options which you mentioned and got correct results.


Regards,

Alex


0 Kudos
Guillaume_A_
New Contributor II
598 Views

Hi,

Thanks for your answer. 

I am running it the most simple way, in the console: ./myprogram.out on Linux, myprogram.exe on Windows.

 

Did you run it on Windows or Linux OS? With an AMD or Intel CPU?

 

Regards,

Guillaume A.

0 Kudos
Aleksandra_K
Moderator
592 Views

Sorry for making the confusion, by 'running' I meant mainly compiling. I used Linux.


0 Kudos
Guillaume_A_
New Contributor II
563 Views

Oh ok, my whole compilation/link commands:

/Console # /root/bin/mf-current/bin/icpx -DISOLATION_AWARE_ENABLED -I/root/bin/mf-current/x86_64-conda-linux-gnu/include/c++/13.1.0 -I/root/bin/mf-current/x86_64-conda-linux-gnu/include/c++/13.1.0/x86_64-conda-linux-gnu -I/root/bin/mf-current/x86_64-conda-linux-gnu/sysroot/usr/include -I/root/bin/mf-current/include -std=gnu++17 -m64 -mavx -O0 -g2 -gdwarf-2 -fPIE -o myprogram.cpp.o -c myprogram.cpp
/Console # /root/bin/mf-current/bin/icpx -pie -m64 --sysroot=/root/bin/mf-current/x86_64-conda-linux-gnu/sysroot -static-libgcc -static-libstdc++ -static-intel myprogram.cpp.o -o myprogram.out -Wl,--start-group /root/bin/mf-current/lib/libmkl_intel_lp64.a /root/bin/mf-current/lib/libmkl_sequential.a /root/bin/mf-current/lib/libmkl_core.a -Wl,--end-group -lpthread -ldl

 

Note that I removed some option to keep it simple, but I still reproduce the crash.

 

gcc, g++, mkl and dpcpp have been installed with conda (miniforge).

0 Kudos
Aleksandra_K
Moderator
452 Views

Hi, I eventually reproduced the issue and we will work on it internally. I'll post here with any news.



Guillaume_A_
New Contributor II
97 Views

Hello, any news on this?

Guillaume A.

0 Kudos
Aleksandra_K
Moderator
89 Views

Hi,


I confirmed that work on this issue is in progress. I'll post here once there are updates.


Regards,

Alex


0 Kudos
Reply