1
1
// FIXME: the rocm include path and link path are highly platform dependent,
2
- // we should set this with some variable instead
2
+ // we should set this with some variable instead.
3
3
// RUN: %{build} -o %t.out -I/opt/rocm/include -L/opt/rocm/lib -lamdhip64
4
4
// RUN: %{run} %t.out
5
5
// REQUIRES: hip
@@ -42,7 +42,6 @@ void copy(buffer<DataT, 1> &Src, buffer<DataT, 1> &Dst, queue &Q) {
42
42
auto HipStream = IH.get_native_queue <backend::ext_oneapi_hip>();
43
43
auto SrcMem = IH.get_native_mem <backend::ext_oneapi_hip>(SrcA);
44
44
auto DstMem = IH.get_native_mem <backend::ext_oneapi_hip>(DstA);
45
- cl_event Event;
46
45
47
46
if (hipMemcpyWithStream (DstMem, SrcMem, sizeof (DataT) * SrcA.get_count (),
48
47
hipMemcpyDefault, HipStream) != hipSuccess) {
@@ -77,14 +76,14 @@ void init(buffer<DataT, 1> &B1, buffer<DataT, 1> &B2, queue &Q) {
77
76
auto Acc2 = B2.template get_access <mode::write>(CGH);
78
77
79
78
CGH.parallel_for <Init<DataT>>(BUFFER_SIZE, [=](item<1 > Id) {
80
- Acc1[Id] = - 1 ;
81
- Acc2[Id] = - 2 ;
79
+ Acc1[Id] = B1Init ;
80
+ Acc2[Id] = B2Init ;
82
81
});
83
82
});
84
83
}
85
84
86
- // A test that uses OpenCL interop to copy data from buffer A to buffer B, by
87
- // getting cl_mem objects and calling the clEnqueueBufferCopy . Then run a SYCL
85
+ // A test that uses HIP interop to copy data from buffer A to buffer B, by
86
+ // getting HIP ptrs and calling the hipMemcpyWithStream . Then run a SYCL
88
87
// kernel that modifies the data in place for B, e.g. increment one, then copy
89
88
// back to buffer A. Run it on a loop, to ensure the dependencies and the
90
89
// reference counting of the objects is not leaked.
@@ -93,10 +92,10 @@ void test1(queue &Q) {
93
92
buffer<int , 1 > Buffer1{BUFFER_SIZE};
94
93
buffer<int , 1 > Buffer2{BUFFER_SIZE};
95
94
96
- // init the buffer with a'priori invalid data
95
+ // Init the buffer with a'priori invalid data.
97
96
init<int , -1 , -2 >(Buffer1, Buffer2, Q);
98
97
99
- // Repeat a couple of times
98
+ // Repeat a couple of times.
100
99
for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
101
100
copy (Buffer1, Buffer2, Q);
102
101
modify (Buffer2, Q);
@@ -115,10 +114,10 @@ void test2(queue &Q) {
115
114
buffer<int , 1 > Buffer1{BUFFER_SIZE};
116
115
buffer<int , 1 > Buffer2{BUFFER_SIZE};
117
116
118
- // init the buffer with a'priori invalid data
117
+ // Init the buffer with a'priori invalid data.
119
118
init<int , -1 , -2 >(Buffer1, Buffer2, Q);
120
119
121
- // Repeat a couple of times
120
+ // Repeat a couple of times.
122
121
for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
123
122
copy (Buffer1, Buffer2, Q);
124
123
modify (Buffer2, Q);
@@ -128,28 +127,7 @@ void test2(queue &Q) {
128
127
checkBufferValues (Buffer2, COUNT - 1 );
129
128
}
130
129
131
- // Same as above but with queue constructed out of context
132
- void test2_1 (queue &Q) {
133
- static constexpr int COUNT = 4 ;
134
- buffer<int , 1 > Buffer1{BUFFER_SIZE};
135
- buffer<int , 1 > Buffer2{BUFFER_SIZE};
136
-
137
- device Device;
138
- auto Context = context (Device);
139
- // init the buffer with a'priori invalid data
140
- init<int , -1 , -2 >(Buffer1, Buffer2, Q);
141
-
142
- // Repeat a couple of times
143
- for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
144
- copy (Buffer1, Buffer2, Q);
145
- modify (Buffer2, Q);
146
- copy (Buffer2, Buffer1, Q);
147
- }
148
- checkBufferValues (Buffer1, COUNT - 1 );
149
- checkBufferValues (Buffer2, COUNT - 1 );
150
- }
151
-
152
- // Check that a single host-interop-task with a buffer will work
130
+ // Check that a single host-interop-task with a buffer will work.
153
131
void test3 (queue &Q) {
154
132
buffer<int , 1 > Buffer{BUFFER_SIZE};
155
133
@@ -179,7 +157,6 @@ void test4(queue &Q) {
179
157
void tests (queue &Q) {
180
158
test1 (Q);
181
159
test2 (Q);
182
- test2_1 (Q);
183
160
test3 (Q);
184
161
test4 (Q);
185
162
}
@@ -193,7 +170,6 @@ int main() {
193
170
std::rethrow_exception (*ExceptionList.begin ());
194
171
});
195
172
tests (Q);
196
- tests (Q);
197
173
std::cout << " Test PASSED" << std::endl;
198
174
return 0 ;
199
175
}
0 commit comments