Skip to content

Commit 1025859

Browse files
authored
Merge pull request #18 from ENCCS/fix-issue-16
Fix #16
2 parents ead93cd + 5af5d14 commit 1025859

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

content/code/day-1/07_axpy-usm_allocator/axpy.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ axpy(
2424
assert(x.size() == y.size());
2525
auto sz = x.size();
2626

27+
auto ptrX = x.data();
28+
auto ptrY = y.data();
29+
2730
// FIXME allocate output vector
2831
std::vector z(...);
2932
// NOTE why do we take the address of the output vector?

content/code/day-1/07_axpy-usm_allocator/solution/axpy.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ axpy(
2222
assert(x.size() == y.size());
2323
auto sz = x.size();
2424

25+
auto ptrX = x.data();
26+
auto ptrY = y.data();
27+
2528
std::vector z(sz, T { 0.0 }, shared_allocator<T>(Q));
2629
// get address of z, because we rely on by-copy capture in the kernel lambda.
2730
// Why?
@@ -33,7 +36,7 @@ axpy(
3336
Q.submit([&](handler& cgh) {
3437
cgh.parallel_for(range { sz }, [=](id<1> tid) {
3538
auto i = tid[0];
36-
ptrZ[i] = alpha * x[i] + y[i];
39+
ptrZ[i] = alpha * ptrX[i] + ptrY[i];
3740
});
3841
})
3942
.wait();

content/unified-shared-memory.rst

+11
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ Implicit
334334

335335
A working solution is in the ``solution`` subfolder.
336336

337+
.. note::
338+
339+
The fact that we use a device-aware allocator for ``std::vector``
340+
does not mean that STL objects will *magically* work within the
341+
SYCL runtime. Indeed, doing so is absolutely not legal code: it
342+
might compile and even work in some cases, but is to be considered
343+
a bug.
344+
You can read up a complete explanation `here
345+
<https://github.com/illuhad/hipSYCL/issues/817#issuecomment-1231922115>`_.
346+
347+
337348

338349
.. keypoints::
339350

0 commit comments

Comments
 (0)