Skip to content

Commit 1b076eb

Browse files
authored
Merge pull request #706 from LLNL/pr-from-fork/703
Pr from fork/703
2 parents 39c5259 + 3117cd0 commit 1b076eb

5 files changed

+51
-25
lines changed

RELEASE-NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/
2323
not the C language.
2424
- Guard HIP C smoketest against projects that don't enable C as a language in their projects.
2525
- Changes benchmark custom target `run_benchmarks` to exclusively run benchmarks (not other general tests).
26+
- Fix HIP smoketests to fail on HIP errors.
2627

2728
## [Version 0.6.2] - Release date 2024-03-15
2829

tests/smoke/blt_hip_gtest_smoke.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
// file: blt_hip_smoke.cpp
99
//
1010
//-----------------------------------------------------------------------------
11-
12-
#include <iostream>
13-
#include <stdio.h>
1411
#include "gtest/gtest.h"
1512
#include "hip/hip_runtime.h"
1613

1714
__device__ const char STR[] = "HELLO WORLD!";
18-
const char STR_LENGTH = 12;
15+
const int STR_LENGTH = 12;
1916

2017
__global__ void hello()
2118
{
@@ -27,12 +24,13 @@ __global__ void hello()
2724
//------------------------------------------------------------------------------
2825
TEST(blt_hip_gtest_smoke,basic_assert_example)
2926
{
27+
hipError_t rc;
3028
int num_threads = STR_LENGTH;
3129
int num_blocks = 1;
3230
hipLaunchKernelGGL((hello), dim3(num_blocks), dim3(num_threads),0,0);
33-
if(hipSuccess != hipDeviceSynchronize())
34-
{
35-
std::cout << "ERROR: hipDeviceSynchronize failed!" << std::endl;
36-
}
37-
EXPECT_TRUE( true );
31+
rc = hipGetLastError();
32+
EXPECT_EQ(rc,hipSuccess) << "[HIP ERROR]: " << hipGetErrorString(rc) << "\n";
33+
34+
rc = hipDeviceSynchronize();
35+
EXPECT_EQ(rc,hipSuccess) << "[HIP ERROR]: " << hipGetErrorString(rc) << "\n";
3836
}

tests/smoke/blt_hip_runtime_c_smoke.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,26 @@
1515

1616
int main()
1717
{
18-
int nDevices;
18+
hipError_t rc = hipSuccess;
19+
int nDevices = 0;
20+
21+
rc = hipGetDeviceCount(&nDevices);
22+
if (rc != hipSuccess)
23+
{
24+
fprintf(stderr, "[HIP ERROR]: %s", hipGetErrorString(rc));
25+
return -1;
26+
}
1927

20-
hipGetDeviceCount(&nDevices);
2128
for (int i = 0; i < nDevices; i++)
2229
{
2330
hipDeviceProp_t prop;
24-
hipGetDeviceProperties(&prop, i);
31+
rc = hipGetDeviceProperties(&prop, i);
32+
if (rc != hipSuccess)
33+
{
34+
fprintf(stderr, "[HIP ERROR]: %s", hipGetErrorString(rc));
35+
return -1;
36+
}
37+
2538
printf("Device Number: %d\n", i);
2639
printf(" Device name: %s\n", prop.name);
2740
printf(" Memory Clock Rate (KHz): %d\n",

tests/smoke/blt_hip_runtime_smoke.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@
88
// file: blt_hip_runtime_smoke.cpp
99
//
1010
//-----------------------------------------------------------------------------
11-
12-
#include <iostream>
11+
#include <cstdio>
1312
#include "hip/hip_runtime_api.h"
14-
#include <stdio.h>
1513

1614
int main()
1715
{
18-
int nDevices;
16+
hipError_t rc = hipSuccess;
17+
int nDevices{0};
1918

20-
if(hipSuccess != hipGetDeviceCount(&nDevices))
19+
rc = hipGetDeviceCount(&nDevices);
20+
if (rc != hipSuccess)
2121
{
22-
std::cout << "ERROR: hipGetDeviceCount failed!" << std::endl;
22+
fprintf(stderr, "[HIP ERROR]: %s", hipGetErrorString(rc));
23+
return -1;
2324
}
2425

2526
for (int i = 0; i < nDevices; i++)
2627
{
2728
hipDeviceProp_t prop;
28-
if(hipSuccess != hipGetDeviceProperties(&prop, i))
29+
rc = hipGetDeviceProperties(&prop, i);
30+
if (rc != hipSuccess)
2931
{
30-
std::cout << "ERROR: hipGetDeviceProperties failed!" << std::endl;
32+
fprintf(stderr, "[HIP ERROR]: %s", hipGetErrorString(rc));
33+
return -1;
3134
}
35+
3236
printf("Device Number: %d\n", i);
3337
printf(" Device name: %s\n", prop.name);
3438
printf(" Memory Clock Rate (KHz): %d\n",

tests/smoke/blt_hip_smoke.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
//
1010
//-----------------------------------------------------------------------------
1111

12-
#include <iostream>
13-
#include <stdio.h>
12+
#include <cstdio>
1413
#include "hip/hip_runtime.h"
1514

1615
__device__ const char STR[] = "HELLO WORLD!";
17-
const char STR_LENGTH = 12;
16+
const int STR_LENGTH = 12;
1817

1918
__global__ void hello()
2019
{
@@ -23,12 +22,23 @@ __global__ void hello()
2322

2423
int main()
2524
{
25+
hipError_t rc = hipSuccess;
2626
int num_threads = STR_LENGTH;
2727
int num_blocks = 1;
28+
2829
hipLaunchKernelGGL((hello), dim3(num_blocks), dim3(num_threads),0,0);
29-
if(hipSuccess != hipDeviceSynchronize())
30+
rc = hipGetLastError();
31+
if (rc != hipSuccess)
32+
{
33+
fprintf(stderr,"[HIP ERROR]: %s\n", hipGetErrorString(rc));
34+
return -1;
35+
}
36+
37+
rc = hipDeviceSynchronize();
38+
if (rc != hipSuccess)
3039
{
31-
std::cout << "ERROR: hipDeviceSynchronize failed!" << std::endl;
40+
fprintf(stderr, "[HIP ERROR]: %s\n", hipGetErrorString(rc));
41+
return -1;
3242
}
3343

3444
return 0;

0 commit comments

Comments
 (0)