How to synchronize the pointer obtained by the array object with the pointer obtained by the device<>().

26 views
Skip to first unread message

林贞浩

unread,
Apr 10, 2025, 10:54:38 AMApr 10
to ArrayFire Users
TEST_CASE("device2") {
double data[] = {1.0, 2.0, 3.0, 4.0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
array *a = new array(2, 3, 4, data);

auto d = a->device<double>();
d[0] = 2;
// af::sync();
a->unlock();
CHECK((*a)(0, 0, 0).scalar<double>() == 2);

*a+=1;
af::sync();
CHECK((*a)(0, 0, 0).scalar<double>() == 3);
CHECK(d[2]==3.0);
auto d2 = a->device<double>();
CHECK(d2[2]==4.0);
}

林贞浩

unread,
Apr 10, 2025, 10:58:50 AMApr 10
to ArrayFire Users
I would expect CHECK(d[2]==4.0);
Reply all
Reply to author
Forward
0 new messages