Skip to content

rewrite description of anatomy.cpp#1

Merged
MikeL270 merged 7 commits into
buffer-usm-migrationfrom
first_ex_rewrite
Jun 18, 2026
Merged

rewrite description of anatomy.cpp#1
MikeL270 merged 7 commits into
buffer-usm-migrationfrom
first_ex_rewrite

Conversation

@MikeL270

@MikeL270 MikeL270 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Rewrote the description of anatomy.cpp

@MikeL270
MikeL270 marked this pull request as draft June 11, 2026 22:37
@TApplencourt

Copy link
Copy Markdown
Collaborator

What about:


At line 2 we [code]#{hash}include# the SYCL header file, which provides all of
the SYCL features that will be used.

At line 11 we instantiate a <<queue>> with the [code]#in_order# property.
A <<queue>> is bound to a single <<device>>; if you do not specify a device by
passing a selector to the  <<queue>> constructor, the SYCL runtime will choose one
automatically.
A <<queue>> executes the commands submitted to it on its associated <<device>>.
In our case, because of the [code]#in_order# propert, commands are executed in a first in, first out (FIFO) order.
The commands submitted to [code]#myQueue# execute asynchronously with respect to
the host code.

At line 14 we use [code]#malloc_device# to allocate memory on the <<device>>
associated with our <<queue>>, storing a <<usm, unified shared memory (USM)>>
pointer to it in [code]#dataDevice#. This memory is accessible only on the
device.

On lines 17 to 20, [code]#parallel_for# does three conceptual things:

  * the <<sycl-kernel-function>> (defined here as a lambda), passed as the
    second argument to [code]#parallel_for#, is compiled by a
    <<device-compiler>> into a <<kernel>> that can run on the <<device>>
    associated with [code]#myQueue#;
  * a command invoking that <<kernel>> is submitted to [code]#myQueue#, and
    executes asynchronously with respect to the host;
  * when the command runs, the range from 0 to 1023 is decomposed into
    <<work-item,work-items>>, and the <<sycl-kernel-function>> is invoked once
    for each <<work-item>> on the device.

The different <<queue>> member functions used to invoke a <<sycl-kernel-function>> can be found in <<subsec:invokingkernels>>.

At line 23 we use the [code]#copy# member function to submit a copy commands
that copies the results from the device allocation back to host memory.

At line 25 we call [code]#wait# to block the host until all commands submitted
to [code]#myQueue# (the [code]#parallel_for# and the [code]#copy#) have
completed.

At lines 28 to 29 we print the host memory, which now contains a copy of the
device memory.

At line 32, the device allocation [code]#dataDevice# is released with
[code]#free#.

Try to clarify what // for is doing a little clearer (not sure if it's...)

@MikeL270
MikeL270 marked this pull request as ready for review June 18, 2026 20:52
@MikeL270
MikeL270 merged commit f9e1ce1 into buffer-usm-migration Jun 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants