computecpp-sdk icon indicating copy to clipboard operation
computecpp-sdk copied to clipboard

Running SYCL program in MSVC Debug mode throws std::bad_array_new_length

Open martinstarkov opened this issue 3 years ago • 9 comments

Cloned the latest computecpp-sdk samples and built project files using the included CMake. Running on Visual Studio v16.9.4 2019 on Windows 10 in Debug mode. Exception points to the queue construction (with both default constructor and with specific ones): image This seems like a ComputeCpp bug and nothing to do with the samples as I have tested in my own code and it occurs with any simple queue construction. Perhaps not though, as Visual Studio seems to link with the correct debug library, found in the linker dependencies: \computecpp\lib\ComputeCpp_d.lib

martinstarkov avatar May 27 '21 13:05 martinstarkov

Hello,

The image says fluid_simulation.exe which is not in the samples as far as I can see. Does the same exception occur for all programs in the SDK? Or some of them?

alycm avatar May 27 '21 13:05 alycm

Oh. Yes that image was taken from my own program but the same exception occurs on the sample programs. I have not tested every single one but it seems to occur where a cl::sycl::queue object is used (constructed).

martinstarkov avatar May 27 '21 14:05 martinstarkov

I'm joinning this thread because I have the same issue. I am using Visual Studio 16.11.2 on Windows 10. Here's computecpp_info output on my machine : computecpp_info

Build has been done through CMake with the following command line from the guide, plus an extra command for my device : cmake .. -G "Visual Studio 16 2019" -A x64 -DComputeCpp_DIR="C:\Program Files\Codeplay\ComputeCpp" -DCOMPUTECPP_BITCODE=ptx64. No problem so far.

Building simple_vector_add in release mode seems to work, but in debug mode the same error as @martinstarkov is thrown : debug_mode_computecpp

razorbeard avatar Sep 13 '21 11:09 razorbeard

The CMake should pick up the debug version of the ComputeCpp library when building in debug mode, but it's possible that it's not. Can you check the CMake cache (it's in the build folder) for the entry COMPUTECPP_RUNTIME_LIBRARY_DEBUG?

DuncanMcBain avatar Sep 14 '21 13:09 DuncanMcBain

Hello Duncan, here's the following lines from my CMakeCache file : cmakecache_output

It seems to be ok in Debug mode. In the project properties in C/C++ > Code Generation > Runtime Library, if I manually switch the /MDd flag to /MT only it works. I have also tested previous versions of CMake in case of deprecating functions, but I still get the same problem.

razorbeard avatar Sep 14 '21 16:09 razorbeard

Yes those are the right libraries. Are you saying that if you change from the debug CRT to the release CRT, debug builds start working again? If that's the case, that's definitely unexpected (I don't know what those flags do, I'm afraid, but I'm guessing from some documentation).

DuncanMcBain avatar Sep 14 '21 17:09 DuncanMcBain

Yes, here's the flag I have changed in the simple-add-vector sample : runtime_mdd

Changing it to this one make it works : runtime_mt

Could it be a bug in the ComputeCpp_d.lib file ?

razorbeard avatar Sep 14 '21 18:09 razorbeard

I have also tested previous versions of CMake in case of deprecating functions, but I still get the same problem.

Did you try any version of CMake 3.14 or lower? I believe 3.15 introduced the change that causes this issue.

Bensuo avatar Sep 15 '21 09:09 Bensuo

Doesn't seems to work either. I tried versions 3.14 and 3.15 but the same error is raised. Below 3.14 there's not support for Visual Studio 2019 unfortunately.

razorbeard avatar Sep 15 '21 10:09 razorbeard