|
14 | 14 | #include "common/ProcessIsolatedTestRunner.hpp" |
15 | 15 | #include "debug.h" |
16 | 16 | #include "graph/topo.h" |
| 17 | +#include "rocmwrap.h" |
17 | 18 |
|
18 | 19 | namespace RcclUnitTesting |
19 | 20 | { |
@@ -157,6 +158,14 @@ static bool isProtoStrValid(const char* envStr) |
157 | 158 | return false; // No match found |
158 | 159 | } |
159 | 160 |
|
| 161 | +// Helper that exercises CUCHECK with a guaranteed-to-fail HIP call |
| 162 | +static ncclResult_t triggerCucheckFailure() |
| 163 | +{ |
| 164 | + CUCHECK(hipPointerGetAttribute(nullptr, HIP_POINTER_ATTRIBUTE_CONTEXT, |
| 165 | + (hipDeviceptr_t)0x1)); |
| 166 | + return ncclSuccess; |
| 167 | +} |
| 168 | + |
160 | 169 | // Helper function to validate algorithm string against known valid algorithms |
161 | 170 | static bool isAlgoStrValid(const char* envStr) |
162 | 171 | { |
@@ -1306,4 +1315,48 @@ TEST(Rcclwrap, AllPxnTests) |
1306 | 1315 | EXPECT_TRUE(allTestsPassed) << "One or more PXN process-isolated tests failed"; |
1307 | 1316 | } |
1308 | 1317 |
|
| 1318 | +TEST(Rcclwrap, CucheckMacro_CheckStickyHipErrorOnFailure) |
| 1319 | +{ |
| 1320 | + hipError_t hipErr = hipSetDevice(0); |
| 1321 | + if(hipErr != hipSuccess) |
| 1322 | + { |
| 1323 | + GTEST_SKIP() << "No GPU available"; |
| 1324 | + } |
| 1325 | + |
| 1326 | + // Clear any pre-existing sticky error so we start clean |
| 1327 | + (void)hipGetLastError(); |
| 1328 | + |
| 1329 | + // Force a HIP failure through CUCHECK using an invalid device pointer (0x1) |
| 1330 | + ncclResult_t ret = triggerCucheckFailure(); |
| 1331 | + |
| 1332 | + EXPECT_EQ(ncclUnhandledCudaError, ret) |
| 1333 | + << "CUCHECK should return ncclUnhandledCudaError on failure"; |
| 1334 | + EXPECT_EQ(hipSuccess, hipGetLastError()) |
| 1335 | + << "CUCHECK must clear sticky HIP error after failure"; |
| 1336 | +} |
| 1337 | + |
| 1338 | +TEST(Rcclwrap, CucheckgotoMacro_CheckStickyHipErrorOnFailure) |
| 1339 | +{ |
| 1340 | + hipError_t hipErr = hipSetDevice(0); |
| 1341 | + if(hipErr != hipSuccess) |
| 1342 | + { |
| 1343 | + GTEST_SKIP() << "No GPU available"; |
| 1344 | + } |
| 1345 | + |
| 1346 | + // Clear any pre-existing sticky error so we start clean |
| 1347 | + (void)hipGetLastError(); |
| 1348 | + |
| 1349 | + // Force a HIP failure through CUCHECKGOTO using an invalid device pointer (0x1) |
| 1350 | + ncclResult_t ret = ncclSuccess; |
| 1351 | + CUCHECKGOTO(hipPointerGetAttribute(nullptr, HIP_POINTER_ATTRIBUTE_CONTEXT, |
| 1352 | + (hipDeviceptr_t)0x1), |
| 1353 | + ret, check_sticky); |
| 1354 | + |
| 1355 | +check_sticky: |
| 1356 | + EXPECT_EQ(ncclUnhandledCudaError, ret) |
| 1357 | + << "CUCHECKGOTO should set result to ncclUnhandledCudaError on failure"; |
| 1358 | + EXPECT_EQ(hipSuccess, hipGetLastError()) |
| 1359 | + << "CUCHECKGOTO must clear sticky HIP error after failure"; |
| 1360 | +} |
| 1361 | + |
1309 | 1362 | } // namespace RcclUnitTesting |
0 commit comments