EXSWCPHIPT-42 - Add HIP RTC support to the test framework (#2719)

* EXSWCPHIPT-42 - Add HIP RTC support to the test framework
* Removed ifdef from hipTestContext class
This commit is contained in:
Fábio
2022-06-13 11:05:02 +01:00
committed by GitHub
parent 1e6bfe7215
commit f04fdbd0f7
13 changed files with 553 additions and 42 deletions
+5 -5
View File
@@ -23,8 +23,8 @@ THE SOFTWARE.
// Through manual inspection of the reported timestamps, can determine if recording a NULL event
// forces synchronization : set
#include <hip_test_checkers.hh>
#include <hip_test_kernels.hh>
#include <kernels.hh>
#include <hip_test_context.hh>
#include <hip_test_common.hh>
TEST_CASE("Unit_hipEventRecord") {
@@ -61,8 +61,8 @@ TEST_CASE("Unit_hipEventRecord") {
// Record the start event
HIP_CHECK(hipEventRecord(start, NULL));
hipLaunchKernelGGL(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0,
static_cast<const float*>(A_d), static_cast<const float*>(B_d), C_d, N);
HipTest::launchKernel<float>(HipTest::vectorADD<float>, blocks, threadsPerBlock, 0, 0,
static_cast<const float*>(A_d), static_cast<const float*>(B_d), C_d, N);
HIP_CHECK(hipEventRecord(stop, NULL));
HIP_CHECK(hipEventSynchronize(stop));
@@ -87,5 +87,5 @@ TEST_CASE("Unit_hipEventRecord") {
HIP_CHECK(hipEventDestroy(stop));
HipTest::checkVectorADD(A_h, B_h, C_h, N, true);
TestContext::get().cleanContext();
}
+8 -10
View File
@@ -30,8 +30,9 @@ This testfile verifies the following scenarios of hipHostMalloc API
*/
#include<hip_test_checkers.hh>
#include<hip_test_kernels.hh>
#include<kernels.hh>
#include<hip_test_common.hh>
#include <hip_test_context.hh>
#define SYNC_EVENT 0
#define SYNC_STREAM 1
@@ -41,11 +42,6 @@ std::vector<std::string> syncMsg = {"event", "stream", "device"};
static constexpr int numElements{1024 * 16};
static constexpr size_t sizeBytes{numElements * sizeof(int)};
__global__ void Set(int* Ad, int val) {
int tx = threadIdx.x + blockIdx.x * blockDim.x;
Ad[tx] = val;
}
void CheckHostPointer(int numElements, int* ptr, unsigned eventFlags,
int syncMethod, std::string msg) {
std::cerr << "test: CheckHostPointer "
@@ -70,10 +66,10 @@ void CheckHostPointer(int numElements, int* ptr, unsigned eventFlags,
const int expected = 13;
// Init array to know state:
hipLaunchKernelGGL(Set, dimGrid, dimBlock, 0, 0x0, ptr, -42);
HipTest::launchKernel(Set, dimGrid, dimBlock, 0, 0x0, ptr, -42);
HIP_CHECK(hipDeviceSynchronize());
hipLaunchKernelGGL(Set, dimGrid, dimBlock, 0, s, ptr, expected);
HipTest::launchKernel(Set, dimGrid, dimBlock, 0, s, ptr, expected);
HIP_CHECK(hipEventRecord(e, s));
// Host waits for event :
@@ -137,9 +133,9 @@ TEST_CASE("Unit_hipHostMalloc_Basic") {
dim3 dimGrid(LEN / 512, 1, 1);
dim3 dimBlock(512, 1, 1);
hipLaunchKernelGGL(HipTest::vectorADD, dimGrid, dimBlock,
HipTest::launchKernel<float>(HipTest::vectorADD<float>, dimGrid, dimBlock,
0, 0, static_cast<const float*>(A_d),
static_cast<const float*>(B_d), C_d, LEN);
static_cast<const float*>(B_d), C_d, static_cast<size_t>(LEN));
HIP_CHECK(hipMemcpy(C_h, C_d, LEN*sizeof(float),
hipMemcpyDeviceToHost));
HIP_CHECK(hipDeviceSynchronize());
@@ -148,6 +144,7 @@ TEST_CASE("Unit_hipHostMalloc_Basic") {
HIP_CHECK(hipHostFree(A_h));
HIP_CHECK(hipHostFree(B_h));
HIP_CHECK(hipHostFree(C_h));
TestContext::get().cleanContext();
}
}
/*
@@ -185,6 +182,7 @@ TEST_CASE("Unit_hipHostMalloc_NonCoherent") {
SYNC_STREAM, ptrType);
CheckHostPointer(numElements, A, hipEventReleaseToSystem,
SYNC_EVENT, ptrType);
TestContext::get().cleanContext();
}
/*