Community
cancel
Showing results for 
Search instead for 
Did you mean: 
277 Views

SYCL contexts and memory access

Jump to solution

My understanding of the cl::sycl::context is that they are used among the different devices on a system. For example, I can only access memory allocated on a given cl::sycl::device using a cl::sycl::queue that was instantiated with the cl::sycl::context associated to said device, i.e. using cl::sycl::device::get_context().

 
Is this correct?
 
A summary of my problem: I generate random numbers in one class and store put them into the memory of an Neo device using a cl::sycl::queue member variable in this class. In another class, I allocate a bunch of memory on the ‘same’(?) Neo device using a cl::sycl::queue member variable in this other class. I get the associated device in both classes with the same common static function, i.e. the same Neo device is used. There are 3-4 classes that are implemented similarly. Now, it seems in some cases that I can use a single cl::sycl::queue from an arbitrary class to access data allocated in other classes, but in other cases I can’t; I need to use the queue/context that was used to allocate the memory. Of course I can’t operate this way since I need to access data stored among multiple classes using a single queue.
 
Is there a preferred/common/proper way to achieve what I want to do? Should I have a global “queue manager” class of sorts that uses a single queue/device/context to take care of all device-side tasks? Should I be explicitly using the same context is shared among all classes? (I wouldn’t think this mattered if my understanding of contexts is correct, and there is only a single iGPU on each machine. Unless there is different memory that is not shareable among different cl::sycl::queue objects?)
 
Thanks in advance.
 
 
Vince
0 Kudos
1 Solution
GouthamK_Intel
Moderator
260 Views

Hi,

Thanks for reaching out to us!

My understanding of the cl::sycl::context is that they are used among the different devices on a system. For example, I can only access memory allocated on a given cl::sycl::device using a cl::sycl::queue that was instantiated with the cl::sycl::context associated to said device, i.e. using cl::sycl::device::get_context().

When you create multiple queues even with the same device, multiple contexts get created. As they are two different SYCL contexts and any buffer you create will be a part of that context.

Could you please send us a sample code/ pseudo code if possible which depicts the problem statement that you are trying to solve.

 

Thanks & Regards

Goutham

View solution in original post

4 Replies
GouthamK_Intel
Moderator
261 Views

Hi,

Thanks for reaching out to us!

My understanding of the cl::sycl::context is that they are used among the different devices on a system. For example, I can only access memory allocated on a given cl::sycl::device using a cl::sycl::queue that was instantiated with the cl::sycl::context associated to said device, i.e. using cl::sycl::device::get_context().

When you create multiple queues even with the same device, multiple contexts get created. As they are two different SYCL contexts and any buffer you create will be a part of that context.

Could you please send us a sample code/ pseudo code if possible which depicts the problem statement that you are trying to solve.

 

Thanks & Regards

Goutham

View solution in original post

GouthamK_Intel
Moderator
228 Views

Hi,

Could you please confirm if your issue is resolved?

If not, provide us a sample code/ pseudo code that depicts the problem statement that you are trying to solve?


Regards

Goutham


222 Views

Yes -- thanks. (I thought that was implied after selecting your post as the solution.)

GouthamK_Intel
Moderator
211 Views

Hi,

Thanks for the confirmation!

As this issue has been resolved, we will no longer respond to this thread. 

If you require any additional assistance from Intel, please start a new thread. 

Any further interaction in this thread will be considered community only.


Thanks & Regards

Goutham


Reply