intel / llvm

Intel staging area for llvm.org contribution. Home for Intel LLVM-based projects.
Other
1.2k stars 715 forks source link

Unable to compile with DPC++ #14455

Closed Laranga22 closed 1 week ago

Laranga22 commented 3 weeks ago

Describe the bug

I am trying to execute SYCL code in a NVidia GPU. I added the compiler and its libs to the path but I am encountering this issue. Is someone else alo encountering this issue?

To reproduce

  1. imple vectorAdd code I am trying to compile
    
    void VectorAddKernel(float* A, float* B, float* C,
                     const sycl::nd_item<3> &item_ct1)
    {
    A[item_ct1.get_local_id(2)] = item_ct1.get_local_id(2) + 1.0f;
    B[item_ct1.get_local_id(2)] = item_ct1.get_local_id(2) + 1.0f;
    C[item_ct1.get_local_id(2)] =
        A[item_ct1.get_local_id(2)] + B[item_ct1.get_local_id(2)];
    }

int main() try { dpct::device_ext &dev_ct1 = dpct::get_current_device(); sycl::queue &q_ct1 = dev_ct1.in_order_queue(); float d_A, d_B, *d_C; dpct::err0 status;

d_A = sycl::malloc_device<float>(VECTOR_SIZE, q_ct1);
d_B = sycl::malloc_device<float>(VECTOR_SIZE, q_ct1);
d_C = sycl::malloc_device<float>(VECTOR_SIZE, q_ct1);

q_ct1.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, VECTOR_SIZE),
                                     sycl::range<3>(1, 1, VECTOR_SIZE)),
                   [=](sycl::nd_item<3> item_ct1) {
                       VectorAddKernel(d_A, d_B, d_C, item_ct1);
                   });

float Result[VECTOR_SIZE] = { };

status = DPCT_CHECK_ERROR(
    q_ct1.memcpy(Result, d_C, VECTOR_SIZE * sizeof(float)).wait());

dpct::dpct_free(d_A, q_ct1);
dpct::dpct_free(d_B, q_ct1);
dpct::dpct_free(d_C, q_ct1);

for (int i = 0; i < VECTOR_SIZE; i++) {
    if (i % 16 == 0) {
        printf("\n");
    }
    printf("%3.0f ", Result[i]);    
}
printf("\n");

return 0;

} catch (sycl::exception const &exc) { std::cerr << exc.what() << "Exception caught at file:" << FILE << ", line:" << LINE << std::endl; std::e

2. Specify the command which should be used to compile the program

`clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda vector_add.dp.cpp -o vector_add-cuda`

3. The output i this one:

vector_add.dp.cpp:8:10: fatal error: 'dpct/dpct.hpp' file not found 8 | #include <dpct/dpct.hpp> | ^~~~~~~ 1 error generated.


### Environment

- OS: WSL 2
- Target device and vendor: NVIDIA GPU 3060 Ti
- DPC++ version: 

clang version 19.0.0git (https://github.com/intel/llvm.git ef62cadd678e0c3a8b7eb70816e8d5cee526d2fd) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /mnt/c/Users/tamar/llvm/build/bin Build config: +assertions

- How I added the compiler to the PATH:

export PATH="/PATH/llvm/build/bin:$PATH" export LD_LIBRARY_PATH="/PATH/llvm/build/lib:$LD_LIBRARY_PATH"



### Additional context

_No response_
abagusetty commented 3 weeks ago

The above header is from an other project: https://github.com/oneapi-src/syclomatic Since your above code looks like it has been ported using the above tool, you would need to have SYCLomatic/DPCT installed and needs to be added to PATH and LD_LIBRARY_PATH envs

dm-vodopyanov commented 2 weeks ago

@Laranga22 hello, could you please confirm that the @abagusetty's reply helped you?

dm-vodopyanov commented 1 week ago

@Laranga22 I hope that you found @abagusetty's reply above helpful. Closing the issue. Feel free to re-open if the problem is still exists for you.