MCPcopy Create free account
hub / github.com/dmlc/xgboost / InitHostDeviceVector

Function InitHostDeviceVector

tests/cpp/plugin/test_sycl_host_device_vector.cc:17–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace {
16
17void InitHostDeviceVector(size_t n, DeviceOrd device, HostDeviceVector<int> *v) {
18 // create the vector
19 v->SetDevice(device);
20 v->Resize(n);
21
22 ASSERT_EQ(v->Size(), n);
23 ASSERT_EQ(v->Device(), device);
24 // ensure that the device have read-write access
25 ASSERT_TRUE(v->DeviceCanRead());
26 ASSERT_TRUE(v->DeviceCanWrite());
27 // ensure that the host has no access
28 ASSERT_FALSE(v->HostCanRead());
29 ASSERT_FALSE(v->HostCanWrite());
30
31 // fill in the data on the host
32 std::vector<int>& data_h = v->HostVector();
33 // ensure that the host has full access, while the device have none
34 ASSERT_TRUE(v->HostCanRead());
35 ASSERT_TRUE(v->HostCanWrite());
36 ASSERT_FALSE(v->DeviceCanRead());
37 ASSERT_FALSE(v->DeviceCanWrite());
38 ASSERT_EQ(data_h.size(), n);
39 std::iota(data_h.begin(), data_h.end(), 0);
40}
41
42void PlusOne(HostDeviceVector<int> *v) {
43 auto device = v->Device();

Callers 2

TestHostDeviceVectorFunction · 0.85
TESTFunction · 0.85

Calls 11

SetDeviceMethod · 0.45
ResizeMethod · 0.45
SizeMethod · 0.45
DeviceMethod · 0.45
DeviceCanReadMethod · 0.45
DeviceCanWriteMethod · 0.45
HostCanReadMethod · 0.45
HostCanWriteMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected