|
1 | 1 | /* |
2 | | -Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. |
| 2 | +Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. |
| 3 | +
|
3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
4 | 5 | of this software and associated documentation files (the "Software"), to deal |
5 | 6 | in the Software without restriction, including without limitation the rights |
6 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
7 | 8 | copies of the Software, and to permit persons to whom the Software is |
8 | 9 | furnished to do so, subject to the following conditions: |
| 10 | +
|
9 | 11 | The above copyright notice and this permission notice shall be included in |
10 | 12 | all copies or substantial portions of the Software. |
11 | | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR |
12 | | -IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
13 | | -FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
14 | | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER |
15 | | -LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
16 | | -OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 13 | +
|
| 14 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
17 | 20 | THE SOFTWARE. |
18 | 21 | */ |
19 | 22 |
|
@@ -41,6 +44,36 @@ static __global__ void Iter(int* Ad, int num) { |
41 | 44 | } |
42 | 45 | } |
43 | 46 |
|
| 47 | +TEST_CASE("Unit_hipDeviceSynchronize_Positive_Empty_Streams") { |
| 48 | + const auto device = GENERATE(range(0, HipTest::getDeviceCount())); |
| 49 | + HIP_CHECK(hipSetDevice(device)); |
| 50 | + INFO("Current device: " << device); |
| 51 | + |
| 52 | + hipStream_t stream; |
| 53 | + HIP_CHECK(hipStreamCreate(&stream)); |
| 54 | + HIP_CHECK(hipDeviceSynchronize()); |
| 55 | + HIP_CHECK(hipStreamDestroy(stream)); |
| 56 | +} |
| 57 | + |
| 58 | +TEST_CASE("Unit_hipDeviceSynchronize_Positive_Nullstream") { |
| 59 | + const auto device = GENERATE(range(0, HipTest::getDeviceCount())); |
| 60 | + HIP_CHECK(hipSetDevice(device)); |
| 61 | + INFO("Current device: " << device); |
| 62 | + |
| 63 | + int *A_h = nullptr, *A_d = nullptr; |
| 64 | + HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&A_h), _SIZE, hipHostMallocDefault)); |
| 65 | + A_h[0] = 1; |
| 66 | + HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&A_d), _SIZE)); |
| 67 | + |
| 68 | + HIP_CHECK(hipMemcpyAsync(A_d, A_h, _SIZE, hipMemcpyHostToDevice, NULL)); |
| 69 | + hipLaunchKernelGGL(HIP_KERNEL_NAME(Iter), dim3(1), dim3(1), 0, NULL, A_d, 1 << 30); |
| 70 | + HIP_CHECK(hipMemcpyAsync(A_h, A_d, _SIZE, hipMemcpyDeviceToHost, NULL)); |
| 71 | + |
| 72 | + CHECK(1 << 30 != A_h[0] - 1); |
| 73 | + HIP_CHECK(hipDeviceSynchronize()); |
| 74 | + CHECK(1 << 30 == A_h[0] - 1); |
| 75 | +} |
| 76 | + |
44 | 77 | TEST_CASE("Unit_hipDeviceSynchronize_Functional") { |
45 | 78 | int* A[NUM_STREAMS]; |
46 | 79 | int* Ad[NUM_STREAMS]; |
|
0 commit comments