Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
642 Discussions

How could we use struct including vector or array

jimbook_
Beginner
1,245 Views
struct obj {
  int* arr;
  int size;
};
struct obj {
  vector<int> arr;
  int size;
};

 I want to build  a struct like above, but sycl may not allow these struct. The first struct contains a point, So these data  to which the pointer points cannot be copied to device. The second struct contains a vector, but at code of device I am not able to  get data using subscripts.
The quesition is how can I build a struct with same  functional which can be used on the device.

0 Kudos
1 Solution
RabiyaSK_Intel
Employee
1,127 Views

Hi,


We haven't heard back from you. Were the sample codes that we provided able to resolve your issue?


If you still face any issues, you can reach out to us.


Thanks & Regards,

Shaik Rabiya


View solution in original post

0 Kudos
4 Replies
RabiyaSK_Intel
Employee
1,186 Views

Hi,

 

Thanks for posting in Intel Communities.

 

>>>The quesition is how can I build a struct with same functional which can be used on the device.

We can build structures with both array pointer member and vector member in SYCL code which can be used on device. 

 

We've tried a sample code using structures with both array pointer and vector members and we received expected outputs.

 

Please refer to the attached zip file for the sample codes that we have tried. 

 

Also please refer to the below screenshots for the results.

For structure with pointer array member:

RabiyaSK_Intel_0-1683630536594.png

For structure with vector member:

RabiyaSK_Intel_1-1683630564191.jpeg

Thanks & Regards,

Shaik Rabiya

 

0 Kudos
RabiyaSK_Intel
Employee
1,128 Views

Hi,


We haven't heard back from you. Were the sample codes that we provided able to resolve your issue?


If you still face any issues, you can reach out to us.


Thanks & Regards,

Shaik Rabiya


0 Kudos
RabiyaSK_Intel
Employee
1,096 Views

Hi,


Could you please let us know whether your issue is resolved as you accepted it as a solution?


If your issue isn't resolved, please reach out to us.


Thanks & Regards,

Shaik Rabiya


0 Kudos
RabiyaSK_Intel
Employee
1,019 Views

Hi,


I hope your issue is resolved. If you need any additional information, you can raise a new question as this thread will no longer be monitored by Intel.


Thanks & Regards,

Shaik Rabiya


0 Kudos
Reply