MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

tests/pcuda/device_query.cpp:40–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38};
39
40BOOST_AUTO_TEST_CASE(enumeration) {
41 // This test may change the active device; this guard
42 // ensures that the device is reset to the original one
43 // so as to not perturb subsequent tests.
44 reset_device r;
45
46 int backend_count = 0;
47 BOOST_CHECK(pcudaGetBackendCount(&backend_count) == pcudaSuccess);
48 BOOST_CHECK(backend_count > 0);
49
50 int total_device_count = 0;
51
52 for(int backend = 0; backend < backend_count; ++backend) {
53 std::cout << "Backend " << backend << std::endl;
54
55 auto err = pcudaSetBackend(backend);
56 BOOST_CHECK(err == pcudaSuccess || err == pcudaErrorNoDevice);
57
58 int platform_count = 0;
59 err = pcudaGetPlatformCount(&platform_count);
60 BOOST_CHECK(err == pcudaSuccess || err == pcudaErrorNoDevice);
61 for(int platform = 0; platform < platform_count; ++platform) {
62 std::cout << " Platform " << platform << std::endl;
63 err = pcudaSetPlatform(platform);
64
65 BOOST_CHECK(err == pcudaSuccess || err == pcudaErrorNoDevice);
66
67 int device_count = 0;
68 err = pcudaGetDeviceCount(&device_count);
69 BOOST_CHECK(err == pcudaSuccess || err == pcudaErrorNoDevice);
70
71 for(int device = 0; device < device_count; ++device) {
72 std::cout << " Device " << device << std::endl;
73 ++total_device_count;
74 err = pcudaSetDevice(device);
75 BOOST_CHECK(err == pcudaSuccess);
76
77 int retrieved_device = 0;
78 BOOST_CHECK(pcudaGetDevice(&retrieved_device) == pcudaSuccess);
79 BOOST_CHECK(retrieved_device == device);
80 }
81 }
82 }
83 BOOST_CHECK(total_device_count > 0);
84}
85
86
87BOOST_AUTO_TEST_SUITE_END()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected