#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include #include // ---------------------------------------------------------------------------- // USM Allocator // ---------------------------------------------------------------------------- TEST_CASE("cudaUSMAllocator" * doctest::timeout(300)) { tf::cudaStream stream; std::vector> vec; std::vector> rhs; REQUIRE(vec.size() == 0); vec.resize(100, 10); REQUIRE(vec.size() == 100); for(auto c : vec) { REQUIRE(c == 10); } rhs = std::move(vec); REQUIRE(vec.size() == 0); REQUIRE(rhs.size() == 100); for(auto c : rhs) { REQUIRE(c == 10); } for(int i=0; i<65536; i++) { vec.push_back(-i); } for(int i=0; i<65536; i++) { REQUIRE(vec[i] == -i); } rhs = vec; for(int i=0; i<65536; i++) { REQUIRE(vec[i] == rhs[i]); } tf::cudaDefaultExecutionPolicy p(stream); tf::cuda_for_each(p, vec.data(), vec.data() + vec.size(), [] __device__ (int& v) { v = -177; }); stream.synchronize(); rhs = vec; for(size_t i=0; i, tf::cudaDeviceAllocator>> vec; std::vector, tf::cudaDeviceAllocator>> rhs(N); REQUIRE(vec.size() == 0); REQUIRE(rhs.size() == 10000); //tf::cudaStream stream; //tf::cudaDefaultExecutionPolicy policy(stream); // //tf::cuda_for_each(policy, rhs.data(), rhs.data() + N, [] __device__ (tf::NoInit& v) { // v = -177; //}); //stream.synchronize(); }