@@ -19,17 +19,15 @@ using namespace cl::sycl;
19
19
struct CudaInteropGetNativeTests : public ::testing::TestWithParam<platform> {
20
20
21
21
protected:
22
- queue syclQueue_;
23
- context syclContext_;
22
+ std::unique_ptr<queue> syclQueue_;
24
23
device syclDevice_;
25
24
26
25
void SetUp () override {
27
26
syclDevice_ = GetParam ().get_devices ()[0 ];
28
- syclQueue_ = queue{syclDevice_};
29
- syclContext_ = syclQueue_.get_context ();
27
+ syclQueue_ = std::unique_ptr<queue>{new queue{syclDevice_}};
30
28
}
31
29
32
- void TearDown () override {}
30
+ void TearDown () override { syclQueue_. reset (); }
33
31
};
34
32
35
33
TEST_P (CudaInteropGetNativeTests, getNativeDevice) {
@@ -41,31 +39,32 @@ TEST_P(CudaInteropGetNativeTests, getNativeDevice) {
41
39
}
42
40
43
41
TEST_P (CudaInteropGetNativeTests, getNativeContext) {
44
- CUcontext cudaContext = get_native<backend::cuda>(syclContext_ );
42
+ CUcontext cudaContext = get_native<backend::cuda>(syclQueue_-> get_context () );
45
43
ASSERT_NE (cudaContext, nullptr );
46
44
}
47
45
48
46
TEST_P (CudaInteropGetNativeTests, getNativeQueue) {
49
- CUstream cudaStream = get_native<backend::cuda>(syclQueue_);
47
+ CUstream cudaStream = get_native<backend::cuda>(* syclQueue_);
50
48
ASSERT_NE (cudaStream, nullptr );
51
49
52
50
CUcontext streamContext = nullptr ;
53
51
CUresult result = cuStreamGetCtx (cudaStream, &streamContext);
54
52
ASSERT_EQ (result, CUDA_SUCCESS);
55
53
56
- CUcontext cudaContext = get_native<backend::cuda>(syclContext_ );
54
+ CUcontext cudaContext = get_native<backend::cuda>(syclQueue_-> get_context () );
57
55
ASSERT_EQ (streamContext, cudaContext);
58
56
}
59
57
60
58
TEST_P (CudaInteropGetNativeTests, interopTaskGetMem) {
61
59
buffer<int , 1 > syclBuffer (range<1 >{1 });
62
- syclQueue_. submit ([&](handler &cgh) {
60
+ syclQueue_-> submit ([&](handler &cgh) {
63
61
auto syclAccessor = syclBuffer.get_access <access::mode::read>(cgh);
64
62
cgh.interop_task ([=](interop_handler ih) {
65
63
CUdeviceptr cudaPtr = ih.get_mem <backend::cuda>(syclAccessor);
66
64
CUdeviceptr cudaPtrBase;
67
65
size_t cudaPtrSize = 0 ;
68
- CUcontext cudaContext = get_native<backend::cuda>(syclContext_);
66
+ CUcontext cudaContext =
67
+ get_native<backend::cuda>(syclQueue_->get_context ());
69
68
ASSERT_EQ (CUDA_SUCCESS, cuCtxPushCurrent (cudaContext));
70
69
ASSERT_EQ (CUDA_SUCCESS,
71
70
cuMemGetAddressRange (&cudaPtrBase, &cudaPtrSize, cudaPtr));
@@ -76,8 +75,8 @@ TEST_P(CudaInteropGetNativeTests, interopTaskGetMem) {
76
75
}
77
76
78
77
TEST_P (CudaInteropGetNativeTests, interopTaskGetBufferMem) {
79
- CUstream cudaStream = get_native<backend::cuda>(syclQueue_);
80
- syclQueue_. submit ([&](handler &cgh) {
78
+ CUstream cudaStream = get_native<backend::cuda>(* syclQueue_);
79
+ syclQueue_-> submit ([&](handler &cgh) {
81
80
cgh.interop_task ([=](interop_handler ih) {
82
81
CUstream cudaInteropStream = ih.get_queue <backend::cuda>();
83
82
ASSERT_EQ (cudaInteropStream, cudaStream);
0 commit comments