SWDEV-353807 - Fixes multiple catch issues (#2912)

- enforcing c++17 for all tests
- Warning as error: ignoring return value

Change-Id: I3d171540403f74222e631d1a8e393386461c9729
이 커밋은 다음에 포함됨:
ROCm CI Service Account
2022-08-31 05:23:21 +05:30
커밋한 사람 GitHub
부모 ba5a0b9af5
커밋 d0aaed906d
24개의 변경된 파일100개의 추가작업 그리고 99개의 파일을 삭제
+3 -3
파일 보기
@@ -33,8 +33,8 @@ TEMPLATE_TEST_CASE("ABM_AddKernel_MultiTypeMultiSize", "", int, long, float, lon
res = hipMemcpy(a.data(), d_c, sizeof(TestType) * size, hipMemcpyDeviceToHost);
REQUIRE(res == hipSuccess);
hipFree(d_a);
hipFree(d_b);
hipFree(d_c);
HIP_CHECK(hipFree(d_a));
HIP_CHECK(hipFree(d_b));
HIP_CHECK(hipFree(d_c));
REQUIRE(a == c);
}
+2 -1
파일 보기
@@ -63,7 +63,8 @@ else()
OUTPUT_VARIABLE HIP_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# enforce c++17 for all tests
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++17")
string(REPLACE "." ";" VERSION_LIST ${HIP_VERSION})
list(GET VERSION_LIST 0 HIP_VERSION_MAJOR)
+4 -4
파일 보기
@@ -53,7 +53,7 @@ TEST_CASE("Unit_hipManagedKeyword_SingleGpu") {
hipLaunchKernelGGL(add, dimGrid, dimBlock, 0, 0, static_cast<const float*>(A),
static_cast<float*>(B));
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
float maxError = 0.0f;
for (int i = 0; i < N; i++)
@@ -64,12 +64,12 @@ TEST_CASE("Unit_hipManagedKeyword_SingleGpu") {
TEST_CASE("Unit_hipManagedKeyword_MultiGpu") {
int numDevices = 0;
hipGetDeviceCount(&numDevices);
HIP_CHECK(hipGetDeviceCount(&numDevices));
for (int i = 0; i < numDevices; i++) {
hipSetDevice(i);
HIP_CHECK(hipSetDevice(i));
GPU_func<<< 1, 1 >>>();
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
}
REQUIRE(x == numDevices);
}
+2 -2
파일 보기
@@ -246,7 +246,7 @@ static bool testDeviceMemMulProc(bool testmalloc) {
}
// close the read-descriptor
close(fd[0]);
hipFree(result_d);
HIP_CHECK(hipFree(result_d));
free(result_h);
// wait for child exit
wait(NULL);
@@ -279,7 +279,7 @@ static bool testDeviceMemMulProc(bool testmalloc) {
write(fd[1], result_h, sizeof(int));
// close the write descriptor:
close(fd[1]);
hipFree(result_d);
HIP_CHECK(hipFree(result_d));
free(result_h);
exit(0);
}
+3 -3
파일 보기
@@ -190,7 +190,7 @@ static bool validatePageTableAllocations(const char *devList, int visDevCnt) {
setenv("HIP_VISIBLE_DEVICES", devList, 1);
// First Call to initialize hip api
hipGetDeviceCount(&tmpdev);
HIP_CHECK(hipGetDeviceCount(&tmpdev));
// Get memory snapshot before hostmalloc
@@ -214,7 +214,7 @@ static bool validatePageTableAllocations(const char *devList, int visDevCnt) {
printf("Error while running rsmi_dev_memory_usage_get func\n");
dlclose(rocm_smi_h);
rsmi_shut_down_fp();
hipHostFree(ptr);
HIP_CHECK(hipHostFree(ptr));
return false;
}
current.push_back(used);
@@ -236,7 +236,7 @@ static bool validatePageTableAllocations(const char *devList, int visDevCnt) {
testPassed = false;
}
hipHostFree(ptr);
HIP_CHECK(hipHostFree(ptr));
// writing only, no need for read-descriptor
close(fd[0]);
+1 -1
파일 보기
@@ -33,7 +33,7 @@ __global__ void warpvote(int* device_any, int* device_all, int pshift) {
TEST_CASE("Unit_AnyAll_CompileTest") {
int warpSize, pshift;
hipDeviceProp_t devProp;
hipGetDeviceProperties(&devProp, 0);
HIP_CHECK(hipGetDeviceProperties(&devProp, 0));
warpSize = devProp.warpSize;
int w = warpSize;
+12 -12
파일 보기
@@ -411,7 +411,7 @@ static bool TestAllocInAllThread(int test_type,
break;
}
}
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -443,7 +443,7 @@ static bool TestMemoryAccessInAllThread(int test_type, int thread_idx) {
break;
}
}
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -502,7 +502,7 @@ static bool TestMemoryAcrossMulKernels(int test_type,
break;
}
}
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -562,7 +562,7 @@ static bool TestDevMemAllocMulKerMulThrd(int test_type) {
break;
}
}
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -592,7 +592,7 @@ static bool TestMemoryAccessInAllThread_CmplxStr(int test_type) {
break;
}
}
hipFree(result_d);
HIP_CHECK(hipFree(result_d));
free(result_h);
return bPassed;
}
@@ -648,7 +648,7 @@ static bool TestMemoryAccessInAllThread_Union(int test_type) {
}
if (bPassed == false) break;
}
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -706,7 +706,7 @@ static bool TestAlloc_Load_SingleKer_AllocFree(int test_type,
}
HIP_CHECK(hipModuleUnload(Module));
HIP_CHECK(hipStreamDestroy(stream));
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -808,8 +808,8 @@ static bool TestAlloc_Load_MultKernels(int test_type,
HIP_CHECK(hipModuleUnload(ModuleWrite));
HIP_CHECK(hipModuleUnload(ModuleFree));
HIP_CHECK(hipStreamDestroy(stream));
hipFree(dev_addr);
hipFree(outputVec_d);
HIP_CHECK(hipFree(dev_addr));
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -895,7 +895,7 @@ static bool TestMemoryAcrossMulKernelsUsingGraph(int test_type) {
}
HIP_CHECK(hipStreamDestroy(streamForGraph));
HIP_CHECK(hipGraphExecDestroy(graphExec));
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -924,7 +924,7 @@ static bool TestAllocInDeviceFunc(int test_type) {
break;
}
}
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
return bPassed;
}
@@ -1367,7 +1367,7 @@ TEST_CASE("Unit_deviceAllocation_VirtualFunction") {
}
}
REQUIRE(true == bPassed);
hipFree(outputVec_d);
HIP_CHECK(hipFree(outputVec_d));
free(outputVec_h);
}
+4 -4
파일 보기
@@ -114,16 +114,16 @@ TEST_CASE("Unit_unsafeAtomicAdd") {
void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_d, HIP_LAUNCH_PARAM_BUFFER_SIZE,
&size_d, HIP_LAUNCH_PARAM_END};
hipModuleLaunchKernel(f_kernel, 10, 1, 1, 100, 1, 1, 0, nullptr, nullptr, config_f);
hipModuleLaunchKernel(d_kernel, 10, 1, 1, 100, 1, 1, 0, nullptr, nullptr, config_d);
HIP_CHECK(hipModuleLaunchKernel(f_kernel, 10, 1, 1, 100, 1, 1, 0, nullptr, nullptr, config_f));
HIP_CHECK(hipModuleLaunchKernel(d_kernel, 10, 1, 1, 100, 1, 1, 0, nullptr, nullptr, config_d));
float res_f = 0.0f;
double res_d = 0.0;
HIP_CHECK(hipMemcpy(&res_f, fX, sizeof(float), hipMemcpyDeviceToHost));
HIP_CHECK(hipMemcpy(&res_d, dX, sizeof(double), hipMemcpyDeviceToHost));
hipFree(dX);
hipFree(fX);
HIP_CHECK(hipFree(dX));
HIP_CHECK(hipFree(fX));
HIP_CHECK(hipModuleUnload(module));
+1 -1
파일 보기
@@ -316,7 +316,7 @@ TEST_CASE("Unit_hipGraph_BasicFunctional") {
INFO("Elements : " << size << " ThreadsPerBlock : " << THREADS_PER_BLOCK);
INFO("Graph Launch iterations = " << GRAPH_LAUNCH_ITERATIONS);
hipSetDevice(0);
HIP_CHECK(hipSetDevice(0));
inputVec_h = reinterpret_cast<float*>(malloc(sizeof(float) * size));
REQUIRE(inputVec_h != nullptr);
HIP_CHECK(hipMalloc(&inputVec_d, sizeof(float) * size));
+8 -8
파일 보기
@@ -161,12 +161,12 @@ TEST_CASE("Unit_hipGraphAddMemcpyNode_Negative") {
myparams.dstArray = devArray2;
ret = hipGraphAddMemcpyNode(&memcpyNode, graph, nullptr, 0, &myparams);
REQUIRE(hipErrorInvalidValue == ret);
hipFreeArray(devArray2);
HIP_CHECK(hipFreeArray(devArray2));
}
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
hipFreeArray(devArray1);
HIP_CHECK(hipFreeArray(devArray1));
free(hData);
free(hOutputData);
}
@@ -268,8 +268,8 @@ static void validateMemcpyNode3DArray(bool peerAccess = false) {
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
hipFreeArray(devArray1);
hipFreeArray(devArray2);
HIP_CHECK(hipFreeArray(devArray1));
HIP_CHECK(hipFreeArray(devArray2));
free(hData);
free(hOutputData);
}
@@ -369,8 +369,8 @@ static void validateMemcpyNode2DArray(bool peerAccess = false) {
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
hipFreeArray(devArray1);
hipFreeArray(devArray2);
HIP_CHECK(hipFreeArray(devArray1));
HIP_CHECK(hipFreeArray(devArray2));
}
static void validateMemcpyNode1DArray(bool peerAccess = false) {
@@ -464,8 +464,8 @@ static void validateMemcpyNode1DArray(bool peerAccess = false) {
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
hipFreeArray(devArray1);
hipFreeArray(devArray2);
HIP_CHECK(hipFreeArray(devArray1));
HIP_CHECK(hipFreeArray(devArray2));
}
/**
+4 -4
파일 보기
@@ -144,8 +144,8 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative") {
}
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
hipFreeArray(devArray);
hipFreeArray(devArray2);
HIP_CHECK(hipFreeArray(devArray));
HIP_CHECK(hipFreeArray(devArray2));
free(hData);
}
@@ -254,6 +254,6 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Functional") {
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
hipFreeArray(devArray1);
hipFreeArray(devArray2);
HIP_CHECK(hipFreeArray(devArray1));
HIP_CHECK(hipFreeArray(devArray2));
}
+1 -1
파일 보기
@@ -347,7 +347,7 @@ TEST_CASE("Unit_hipGraphRemoveDependencies_ChangeComputeFunc") {
kernelNodeParams.extra = nullptr;
HIP_CHECK(hipGraphAddKernelNode(&kernel_square, graph, nullptr, 0,
&kernelNodeParams));
hipGraphRemoveDependencies(graph, &memcpyH2D_B, &kernel_vecAdd, 1);
HIP_CHECK(hipGraphRemoveDependencies(graph, &memcpyH2D_B, &kernel_vecAdd, 1));
// Add new dependencies
HIP_CHECK(hipGraphAddDependencies(graph, &memcpyH2D_B, &kernel_square, 1));
HIP_CHECK(hipGraphAddDependencies(graph, &kernel_square,
+5 -5
파일 보기
@@ -60,18 +60,18 @@ static void hipTestWithGraph() {
hipGraph_t graph;
hipGraphExec_t instance;
hipStreamBeginCapture(stream, hipStreamCaptureModeGlobal);
HIP_CHECK(hipStreamBeginCapture(stream, hipStreamCaptureModeGlobal));
for (int ikrnl = 0; ikrnl < NKERNEL; ikrnl++) {
simpleKernel<<<dim3(N / 512, 1, 1), dim3(512, 1, 1),
0, stream>>>(out_d, in_d);
}
hipStreamEndCapture(stream, &graph);
hipGraphInstantiate(&instance, graph, nullptr, nullptr, 0);
HIP_CHECK(hipStreamEndCapture(stream, &graph));
HIP_CHECK(hipGraphInstantiate(&instance, graph, nullptr, nullptr, 0));
auto start1 = std::chrono::high_resolution_clock::now();
for (int istep = 0; istep < NSTEP; istep++) {
hipGraphLaunch(instance, stream);
hipStreamSynchronize(stream);
HIP_CHECK(hipGraphLaunch(instance, stream));
HIP_CHECK(hipStreamSynchronize(stream));
}
auto stop = std::chrono::high_resolution_clock::now();
auto withInit = std::chrono::duration<double, std::milli>(stop - start);
+4 -4
파일 보기
@@ -98,13 +98,13 @@ TEST_CASE("Unit_hiprtc_saxpy") {
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
HIP_LAUNCH_PARAM_END};
hipModuleLaunchKernel(kernel, NUM_BLOCKS, 1, 1, NUM_THREADS, 1, 1, 0, nullptr, nullptr, config);
HIP_CHECK(hipModuleLaunchKernel(kernel, NUM_BLOCKS, 1, 1, NUM_THREADS, 1, 1, 0, nullptr, nullptr, config));
HIP_CHECK(hipMemcpy(hOut.get(), dOut, bufferSize, hipMemcpyDeviceToHost));
hipFree(dX);
hipFree(dY);
hipFree(dOut);
HIP_CHECK(hipFree(dX));
HIP_CHECK(hipFree(dY));
HIP_CHECK(hipFree(dOut));
HIP_CHECK(hipModuleUnload(module));
+1 -1
파일 보기
@@ -50,7 +50,7 @@ TEST_CASE("Unit_hiprtc_warpsize") {
hipDeviceProp_t props;
int device = 0;
hipGetDeviceProperties(&props, device);
HIP_CHECK(hipGetDeviceProperties(&props, device));
#ifdef __HIP_PLATFORM_AMD__
std::string sarg = std::string("--gpu-architecture=") + props.gcnArchName;
#else
+8 -8
파일 보기
@@ -495,10 +495,10 @@ TEST_CASE("Unit_hipStreamPerThread_CoopLaunchMDev") {
// Calculate the device occupancy to know how many blocks can be
// run concurrently
hipGetDeviceProperties(&deviceProp[i], 0);
HIP_CHECK(hipGetDeviceProperties(&deviceProp[i], 0));
if (!deviceProp[i].cooperativeMultiDeviceLaunch) {
WARN("Device doesn't support cooperative launch!");
SUCCEED("");
return;
}
size_t SIZE = copySizeInDwords * sizeof(uint);
@@ -511,7 +511,7 @@ TEST_CASE("Unit_hipStreamPerThread_CoopLaunchMDev") {
}
HIPCHECK(hipMemcpy(dA[i], &init[i * copySizeInDwords] , SIZE,
hipMemcpyHostToDevice));
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
}
dim3 dimBlock;
@@ -560,7 +560,7 @@ TEST_CASE("Unit_hipStreamPerThread_CoopLaunchMDev") {
}
system_clock::time_point start = system_clock::now();
hipLaunchCooperativeKernelMultiDevice(launchParamsList, nGpu, 0);
HIP_CHECK(hipLaunchCooperativeKernelMultiDevice(launchParamsList, nGpu, 0));
for (int i = 0; i < nGpu; i++) {
HIP_CHECK(hipSetDevice(i));
HIP_CHECK(hipDeviceSynchronize());
@@ -586,11 +586,11 @@ TEST_CASE("Unit_hipStreamPerThread_CoopLaunchMDev") {
WARN("finished computation at " << std::ctime(&end_time));
WARN("elapsed time: " << time << "s\n");
hipSetDevice(0);
hipFree(dC);
HIP_CHECK(hipSetDevice(0));
HIP_CHECK(hipFree(dC));
for (int i = 0; i < nGpu; i++) {
hipFree(dA[i]);
hipFree(dB[i]);
HIP_CHECK(hipFree(dA[i]));
HIP_CHECK(hipFree(dB[i]));
}
delete [] init;
}
+5 -5
파일 보기
@@ -41,8 +41,8 @@ static void Copy_to_device() {
for(unsigned int i = 0; i < ele_size; ++i) {
A_h[i] = 123;
}
hipMemcpyAsync(A_d, A_h, ele_size * sizeof(int), hipMemcpyHostToDevice,
hipStreamPerThread);
HIP_CHECK(hipMemcpyAsync(A_d, A_h, ele_size * sizeof(int), hipMemcpyHostToDevice,
hipStreamPerThread));
}
TEST_CASE("Unit_hipStreamPerThread_DeviceReset_1") {
@@ -80,9 +80,9 @@ TEST_CASE("Unit_hipStreamPerThread_DeviceReset_2") {
status = hipMemcpyAsync(A_d, A_h, ele_size * sizeof(int), hipMemcpyHostToDevice,
hipStreamPerThread);
if (status != hipSuccess) return;
hipStreamSynchronize(hipStreamPerThread);
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
hipDeviceReset();
HIP_CHECK(hipDeviceReset());
// After reset all memory objects will be destroyed hence allocating them again
// Intension is to use hipStreamPerThread successfully after reset hence not validating
@@ -95,5 +95,5 @@ TEST_CASE("Unit_hipStreamPerThread_DeviceReset_2") {
status = hipMemcpyAsync(A_d, A_h, ele_size * sizeof(int), hipMemcpyHostToDevice,
hipStreamPerThread);
if (status != hipSuccess) return;
hipStreamSynchronize(hipStreamPerThread);
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
}
+4 -4
파일 보기
@@ -26,14 +26,14 @@ static void Copy_to_device() {
int* A_h = nullptr;
int* A_d = nullptr;
hipHostMalloc(&A_h, ele_size*sizeof(int));
hipMalloc(&A_d, ele_size * sizeof(int));
HIP_CHECK(hipHostMalloc(&A_h, ele_size*sizeof(int)));
HIP_CHECK(hipMalloc(&A_d, ele_size * sizeof(int)));
for (unsigned int i = 0; i < ele_size; ++i) {
A_h[i] = 123;
}
hipMemcpyAsync(A_d, A_h, ele_size * sizeof(int), hipMemcpyHostToDevice,
hipStreamPerThread);
HIP_CHECK(hipMemcpyAsync(A_d, A_h, ele_size * sizeof(int), hipMemcpyHostToDevice,
hipStreamPerThread));
}
/*
+3 -3
파일 보기
@@ -66,13 +66,13 @@ TEST_CASE("Unit_hipBindTexture2D_Pitch") {
hipLaunchKernelGGL(texture2dCopyKernel, dim3(4, 4, 1), dim3(32, 32, 1),
0, 0, devPtrB);
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
HIP_CHECK(hipMemcpy2D(B, SIZE_W*sizeof(TYPE_t), devPtrB,
SIZE_W*sizeof(TYPE_t), SIZE_W*sizeof(TYPE_t),
SIZE_H, hipMemcpyDeviceToHost));
HipTest::checkArray(A, B, SIZE_H, SIZE_W);
delete []A;
delete []B;
hipFree(devPtrA);
hipFree(devPtrB);
HIP_CHECK(hipFree(devPtrA));
HIP_CHECK(hipFree(devPtrB));
}
+2 -2
파일 보기
@@ -93,6 +93,6 @@ TEMPLATE_TEST_CASE("Unit_hipTexObjPitch_texture2D", "", float, int,
HipTest::checkArray(A, B, SIZE_H, SIZE_W);
delete []A;
delete []B;
hipFree(devPtrA);
hipFree(devPtrB);
HIP_CHECK(hipFree(devPtrA));
HIP_CHECK(hipFree(devPtrB));
}
+7 -7
파일 보기
@@ -44,7 +44,7 @@ void runTest(const int width, const float offsetX) {
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(
32, 0, 0, 0, hipChannelFormatKindFloat);
hipArray *hipArray;
hipMallocArray(&hipArray, &channelDesc, width);
HIP_CHECK(hipMallocArray(&hipArray, &channelDesc, width));
HIP_CHECK(hipMemcpy2DToArray(hipArray, 0, 0, hData, width * sizeof(float), width * sizeof(float), 1, hipMemcpyHostToDevice));
@@ -66,7 +66,7 @@ void runTest(const int width, const float offsetX) {
HIP_CHECK(hipCreateTextureObject(&textureObject, &resDesc, &texDesc, NULL));
float *dData = nullptr;
hipMalloc((void**) &dData, size);
HIP_CHECK(hipMalloc((void**) &dData, size));
dim3 dimBlock(16, 1, 1);
dim3 dimGrid((width + dimBlock.x - 1)/ dimBlock.x, 1, 1);
@@ -74,11 +74,11 @@ void runTest(const int width, const float offsetX) {
hipLaunchKernelGGL(tex1DKernel<normalizedCoords>, dimGrid, dimBlock, 0, 0, dData,
textureObject, width, offsetX);
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
float *hOutputData = (float*) malloc(size);
memset(hOutputData, 0, size);
hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost);
HIP_CHECK(hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost));
bool result = true;
for (int j = 0; j < width; j++) {
@@ -91,9 +91,9 @@ void runTest(const int width, const float offsetX) {
}
}
hipDestroyTextureObject(textureObject);
hipFree(dData);
hipFreeArray(hipArray);
HIP_CHECK(hipDestroyTextureObject(textureObject));
HIP_CHECK(hipFree(dData));
HIP_CHECK(hipFreeArray(hipArray));
free(hData);
free(hOutputData);
REQUIRE(result);
+7 -7
파일 보기
@@ -51,7 +51,7 @@ void runTest(const int width, const int height, const float offsetX, const float
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(
32, 0, 0, 0, hipChannelFormatKindFloat);
hipArray *hipArray;
hipMallocArray(&hipArray, &channelDesc, width, height);
HIP_CHECK(hipMallocArray(&hipArray, &channelDesc, width, height));
HIP_CHECK(hipMemcpy2DToArray(hipArray, 0, 0, hData, width * sizeof(float), width * sizeof(float), height, hipMemcpyHostToDevice));
@@ -74,7 +74,7 @@ void runTest(const int width, const int height, const float offsetX, const float
HIP_CHECK(hipCreateTextureObject(&textureObject, &resDesc, &texDesc, NULL));
float *dData = nullptr;
hipMalloc((void**) &dData, size);
HIP_CHECK(hipMalloc((void**) &dData, size));
dim3 dimBlock(16, 16, 1);
dim3 dimGrid((width + dimBlock.x - 1) / dimBlock.x, (height + dimBlock.y -1)/ dimBlock.y, 1);
@@ -82,11 +82,11 @@ void runTest(const int width, const int height, const float offsetX, const float
hipLaunchKernelGGL(tex2DKernel<normalizedCoords>, dimGrid, dimBlock, 0, 0, dData,
textureObject, width, height, offsetX, offsetY);
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
float *hOutputData = (float*) malloc(size);
memset(hOutputData, 0, size);
hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost);
HIP_CHECK(hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost));
bool result = true;
for (int i = 0; i < height; i++) {
@@ -103,9 +103,9 @@ void runTest(const int width, const int height, const float offsetX, const float
}
}
line1:
hipDestroyTextureObject(textureObject);
hipFree(dData);
hipFreeArray(hipArray);
HIP_CHECK(hipDestroyTextureObject(textureObject));
HIP_CHECK(hipFree(dData));
HIP_CHECK(hipFreeArray(hipArray));
free(hData);
free(hOutputData);
REQUIRE(result);
+8 -8
파일 보기
@@ -93,7 +93,7 @@ void runTest(const int width, const int height, const int depth, const float off
hipTextureObject_t textureObject = 0;
hipError_t res = hipCreateTextureObject(&textureObject, &resDesc, &texDesc, NULL);
if (res != hipSuccess) {
hipFreeArray(arr);
HIP_CHECK(hipFreeArray(arr));
free(hData);
if (res == hipErrorNotSupported && isGfx90a) {
printf("gfx90a doesn't support 3D linear filter! Skipped!\n");
@@ -105,8 +105,8 @@ void runTest(const int width, const int height, const int depth, const float off
}
float *dData = nullptr;
hipMalloc((void**) &dData, size);
hipMemset(dData, 0, size);
HIP_CHECK(hipMalloc((void**) &dData, size));
HIP_CHECK(hipMemset(dData, 0, size));
dim3 dimBlock(8, 8, 8); // 512 threads
dim3 dimGrid((width + dimBlock.x - 1) / dimBlock.x, (height + dimBlock.y -1)/ dimBlock.y,
(depth + dimBlock.z - 1) / dimBlock.z);
@@ -114,11 +114,11 @@ void runTest(const int width, const int height, const int depth, const float off
hipLaunchKernelGGL(tex3DKernel<normalizedCoords>, dimGrid, dimBlock, 0, 0, dData,
textureObject, width, height, depth, offsetX, offsetY, offsetZ);
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
float *hOutputData = (float*) malloc(size);
memset(hOutputData, 0, size);
hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost);
HIP_CHECK(hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost));
for (int i = 0; i < depth; i++) {
for (int j = 0; j < height; j++) {
@@ -137,10 +137,10 @@ void runTest(const int width, const int height, const int depth, const float off
}
}
line1:
hipDestroyTextureObject(textureObject);
HIP_CHECK(hipDestroyTextureObject(textureObject));
free(hOutputData);
hipFree(dData);
hipFreeArray(arr);
HIP_CHECK(hipFree(dData));
HIP_CHECK(hipFreeArray(arr));
free(hData);
REQUIRE(result);
+1 -1
파일 보기
@@ -69,7 +69,7 @@ TEST_CASE("Unit_hipTextureRef2D_Check") {
dim3 dimGrid(width / dimBlock.x, height / dimBlock.y, 1);
hipLaunchKernelGGL(tex2DKernel, dim3(dimGrid), dim3(dimBlock), 0, 0,
dData, width);
hipDeviceSynchronize();
HIP_CHECK(hipDeviceSynchronize());
float* hOutputData = reinterpret_cast<float*>(malloc(size));
REQUIRE(hOutputData != nullptr);