Skip to content

Bad build with cmake on windows #16524

Open
@DesCaldnd

Description

@DesCaldnd

Describe the bug

I`m trying to build simple program, that adds two vectors. And it is ok when I use cmd for compilation. But with cmake it falls in runtime with this error, when i call queue.submit:

Exception: Exception 0xe06d7363 encountered at address 0x7fff5a72fb4c
Exception: Exception 0x80000003 encountered at address 0x7ffe28d0d0eb
Exception: Exception 0xc0000005 encountered at address 0x7ffe28d0d0fe: Access violation reading location 0x00000020

This is my cmake file:

cmake_minimum_required(VERSION 3.30 FATAL_ERROR)

project(main LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
find_package(IntelSYCL REQUIRED)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -fsycl-unnamed-lambda")

add_executable(main main.cpp)

and main.cpp:

#include <iostream>
// #include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

class vector_addition;

int main(int, char**) {

	sycl::float4 a = { 1.0, 2.0, 3.0, 4.0 };
	sycl::float4 b = { 4.0, 3.0, 2.0, 1.0 };
	sycl::float4 c = { 0.0, 0.0, 0.0, 0.0 };

	// sycl::device device(sycl::gpu_selector_v);

	sycl::queue queue(sycl::device{sycl::gpu_selector_v});

	std::cout << "Running on "
			  << queue.get_device().get_info<sycl::info::device::name>()
			  << "\n";
	{
		sycl::buffer<sycl::float4, 1> a_sycl(&a, sycl::range<1>(1));
		sycl::buffer<sycl::float4, 1> b_sycl(&b, sycl::range<1>(1));
		sycl::buffer<sycl::float4, 1> c_sycl(&c, sycl::range<1>(1));


		queue.submit([&] (sycl::handler& cgh) {
		   auto a_acc = a_sycl.get_access<sycl::access::mode::read>(cgh);
		   auto b_acc = b_sycl.get_access<sycl::access::mode::read>(cgh);
		   auto c_acc = c_sycl.get_access<sycl::access::mode::discard_write>(cgh);

		   cgh.single_task<class vector_addition>([=] () {
		   c_acc[0] = a_acc[0] + b_acc[0];
		   });
		});
	}
	std::cout << "  A { " << a.x() << ", " << a.y() << ", " << a.z() << ", " << a.w() << " }\n"
		 << "+ B { " << b.x() << ", " << b.y() << ", " << b.z() << ", " << b.w() << " }\n"
		 << "------------------\n"
		 << "= C { " << c.x() << ", " << c.y() << ", " << c.z() << ", " << c.w() << " }"
		 << std::endl;

	return 0;
}

To reproduce

  1. Include a code snippet that is as short as possible
  2. Specify the command which should be used to compile the program
  3. Specify the command which should be used to launch the program
  4. Indicate what is wrong and what was expected

Environment

  • OS: Windows
  • Target device and vendor: NVidia 3050
  • DPC++ version: 2025

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcudaCUDA back-end

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions