Intel® DevCloud
Help for those needing help starting or connecting to the Intel® DevCloud
1596 Discussions

Segmentation fault for simple dpcpp

Chris111
Beginner
412 Views

Hi all, new to dpcpp, don't really have much experience with c++, took a course when I was a kid :).  Anyways, trying to get into dpcpp on devcloud and can't build this simple program without getting it to segfault when run.  I literally had GPT4 write it, and tested it locally on a docker, and it worked fine.  Any ideas why vanilla devcloud segfaults?  I don't know how to get debug info, but I have found that the mere presence of `h.parallel_for` with nothing in it makes it Segfault.  Here's the code (with parts commented out for debugging)

 

#include <CL/sycl.hpp>
#include <iostream>
#include <vector>
using namespace sycl;

// namespace sycl = cl::sycl;

constexpr size_t array_size = 5;

// The compute function that takes an array of ints and uses h.parallel_for to
// make the output of the array the index * 10
void compute(int *data, size_t size) {
  sycl::range<1> work_items{size};

  sycl::buffer<int, 1> data_buffer(data, size);

  auto q = sycl::queue(sycl::default_selector_v); //gpu_selector_v

  q.submit([&](sycl::handler &h) {
    // auto data_acc = data_buffer.get_access<sycl::access::mode::read_write>(h);
    h.parallel_for(work_items, [=](sycl::id<1> idx) {
    //   data_acc[idx] = idx[0] * 10;
    });
  });

  q.wait();
}

// The main function
int main() {
  std::vector<int> data(array_size);

  compute(data.data(), array_size);

//   std::cout << "The result of the computation is: ";
//   for (size_t i = 0; i < array_size; ++i) {
//     std::cout << data[i] << " ";
//   }
//   std::cout << std::endl;

  return 0;
}
0 Kudos
1 Solution
Chris111
Beginner
391 Views

Figured it out

 

Have to run this command to get something that works after ssh into devcloud

 

qsub -I -l nodes=1:gpu:ppn=2 -d .

 

See this link:

 

https://devcloud.intel.com/oneapi/get_started/baseToolkitSamples/

View solution in original post

0 Kudos
2 Replies
Chris111
Beginner
392 Views

Figured it out

 

Have to run this command to get something that works after ssh into devcloud

 

qsub -I -l nodes=1:gpu:ppn=2 -d .

 

See this link:

 

https://devcloud.intel.com/oneapi/get_started/baseToolkitSamples/

0 Kudos
RajashekarK_Intel
Moderator
381 Views

Hi, Thanks for posting in Intel Communities.


Glad to know that your issue is resolved. Thanks for sharing the solution with us. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks,

Rajashekar


0 Kudos
Reply