- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We can use both `buffers` and `USM` implementations in `oneapi`,
In `USM`:
queue q;
int *data1 = malloc_shared<int>(128, q);
for (int i = 0; i < N; i++) {
data1[i] = 10;
}
auto e1 = q.parallel_for(range<1>(N), [=](id<1> i) { data1[i] += 2; });
We use `q.parallel_for` to do parallel computing.
In `buffers`
std::vector<int> vector1(128, 10);
buffer vector1_buffer(vector1);
queue q;
q.submit([&](handler &h) {
accessor vector1_accessor (vector1_buffer,h);
h.parallel_for(range<1>(N), [=](id<1> index) {
vector1_accessor[index] += 1;
});
});
We pass `handler` to the lambda function and use `h.parallel_for` to do parallel computing.
My question is what is handler, how do I understand it? What is the different between `handler` and `queue`?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel communities.
>>what is handler, how do I understand it? What is the different between `handler` and `queue`?
A command group usually contains code, that defines dependences running as part of the host program (so that the runtime knows what the dependences are) and device code running in the future once the dependences are satisfied.
A command group handler gives more control over how code is submitted to the queue.
A DPC++ queue is employed to schedule and execute the command queues on the devices.
Queue also uses a shortcut method that directly invoke parallel_for on the queue object instead of inside a lambda passed to the submit method (a command group).
Queues are used to schedule the execution of a set of handlers, ensuring that dependencies between commands are correctly managed.
The handler encapsulates the details of a single parallel computation, while the queue manages the execution of a set of handlers.
Please refer to the Data parallel C++ Textbook by James Reinders for more details.
Thanks & Regards,
Vankudothu Vaishnavi.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel communities.
>>what is handler, how do I understand it? What is the different between `handler` and `queue`?
A command group usually contains code, that defines dependences running as part of the host program (so that the runtime knows what the dependences are) and device code running in the future once the dependences are satisfied.
A command group handler gives more control over how code is submitted to the queue.
A DPC++ queue is employed to schedule and execute the command queues on the devices.
Queue also uses a shortcut method that directly invoke parallel_for on the queue object instead of inside a lambda passed to the submit method (a command group).
Queues are used to schedule the execution of a set of handlers, ensuring that dependencies between commands are correctly managed.
The handler encapsulates the details of a single parallel computation, while the queue manages the execution of a set of handlers.
Please refer to the Data parallel C++ Textbook by James Reinders for more details.
Thanks & Regards,
Vankudothu Vaishnavi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Has the information provided above helped? If yes, could you please confirm whether we can close this thread from our end?
Thanks and Regards,
Vankudothu Vaishnavi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks & Regards,
Vankudothu Vaishnavi.
![](/skins/images/D3C0B914909A6564BBB97F4AD1ED1973/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page