From 8b496e4715efed5bb3e1dbd8d657d8c239cea94e Mon Sep 17 00:00:00 2001 From: amd-lthakur Date: Thu, 24 Oct 2019 15:06:28 +0530 Subject: [PATCH] Adding a directed test case for hipExtModuleLaunchKernel() api. --- .../module/hipExtModuleLaunchKernel.cpp | 143 ++++++++++++++++++ tests/src/runtimeApi/module/matmul.cpp | 47 ++++++ 2 files changed, 190 insertions(+) create mode 100755 tests/src/runtimeApi/module/hipExtModuleLaunchKernel.cpp create mode 100755 tests/src/runtimeApi/module/matmul.cpp diff --git a/tests/src/runtimeApi/module/hipExtModuleLaunchKernel.cpp b/tests/src/runtimeApi/module/hipExtModuleLaunchKernel.cpp new file mode 100755 index 0000000000..456bd53282 --- /dev/null +++ b/tests/src/runtimeApi/module/hipExtModuleLaunchKernel.cpp @@ -0,0 +1,143 @@ +/* +Copyright (c) 2015-2019 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR +IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD_CMD: matmul.code %hc --genco %S/matmul.cpp -o matmul.code + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 + * TEST: %t + * HIT_END + */ + + + + +#include +#include "hip/hip_runtime.h" +#include "hip/hip_hcc.h" +#include "test_common.h" +using namespace std::chrono; + +#define fileName "matmul.code" +#define kernel_name1 "matmulK" +#define kernel_name2 "WaitKernel" + +//hipDeviceReset() call is used to clear all the allocations in case of any api failure. +#define HIP_CHECK(status) \ + if (status != hipSuccess) { \ + std::cout << "Got Status: " << hipGetErrorString(status) << " at Line: " << __LINE__ << std::endl; \ + hipDeviceReset(); \ + exit(0); \ + } + +int main() +{ + +int N=16384; +int SIZE=N*N; + +int *A=new int[N*N*sizeof(int)]; +int *B=new int[N*N*sizeof(int)]; +int *C; + +hipDeviceptr_t *Ad,*Bd; + +for(int i=0;i(stop-start); + + start=high_resolution_clock::now(); +HIP_CHECK(hipExtModuleLaunchKernel(Function2, 1,1, 1, 1,1 ,1 , 0, stream1, NULL, (void**)&config2, NULL, NULL,1 )); +HIP_CHECK(hipExtModuleLaunchKernel(Function1, N,N, 1, 32,32 ,1 , 0, stream1, NULL, (void**)&config1, NULL, NULL,1 )); +HIP_CHECK(hipStreamSynchronize(stream1)); + + stop=high_resolution_clock::now(); +auto duration2=duration_cast(stop-start); + +bool TEST_STATUS = true; + +if(! (duration2.count() < duration1.count())){ + std::cout<<"Test failed as there was no time gain observed when two kernels were launched using hipExtModuleLaunchKernel() with flag 1."<