diff --git a/projects/clr/hipamd/tests/src/kernel/inline_asm_vadd.cpp b/projects/clr/hipamd/tests/src/kernel/inline_asm_vadd.cpp index 481b606e89..7a941d31af 100644 --- a/projects/clr/hipamd/tests/src/kernel/inline_asm_vadd.cpp +++ b/projects/clr/hipamd/tests/src/kernel/inline_asm_vadd.cpp @@ -16,7 +16,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTI THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s EXCLUDE_HIP_PLATFORM nvcc * RUN: %t * HIT_END */ diff --git a/projects/clr/hipamd/tests/src/runtimeApi/event/record_event.cpp b/projects/clr/hipamd/tests/src/runtimeApi/event/record_event.cpp new file mode 100644 index 0000000000..66027b1643 --- /dev/null +++ b/projects/clr/hipamd/tests/src/runtimeApi/event/record_event.cpp @@ -0,0 +1,149 @@ +/* +Copyright (c) 2015-2016 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 WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * RUN: %t + * HIT_END + */ + + +#include "test_common.h" + +enum SyncMode { + syncNone, + syncNullStream, + syncOtherStream, +}; + + +const char *syncModeString(int syncMode) { + switch (syncMode) { + case syncNone: + return "syncNone"; + case syncNullStream: + return "syncNullStream"; + case syncOtherStream: + return "syncOtherStream"; + default: + return "unknown"; + }; +}; + + +void test(int *C_d, int *C_h, int64_t numElements, SyncMode syncMode) +{ + printf ("\ntest: syncMode=%s\n", syncModeString(syncMode)); + + size_t sizeBytes = numElements * sizeof(int); + + int count =100; + int init0 = 0; + HIPCHECK(hipMemset(C_d, init0, sizeBytes)); + for (int i=0; i0.0f); + printf ("time=%6.2f\n", t); + + HIPCHECK(hipEventElapsedTime(&t, stop, start)); + assert (t<0.0f); + printf ("negtime=%6.2f\n", t); + + HIPCHECK(hipEventElapsedTime(&t, start, start)); + assert (t==0.0f); + HIPCHECK(hipEventElapsedTime(&t, stop, stop)); + assert (t==0.0f); + + + if (stream) { + HIPCHECK(hipStreamDestroy(stream)); + } + HIPCHECK(hipEventDestroy(start)); + HIPCHECK(hipEventDestroy(stop)); + + printf ("test: OK \n"); +} + + + +void runTests(int64_t numElements) +{ + size_t sizeBytes = numElements * sizeof(int); + + printf ("test: starting sequence with sizeBytes=%zu bytes, %6.2f MB\n", sizeBytes, sizeBytes/1024.0/1024.0); + + + int *C_h, *C_d; + HIPCHECK(hipMalloc(&C_d, sizeBytes)); + HIPCHECK(hipHostMalloc(&C_h, sizeBytes)); + + + { + test (C_d, C_h, numElements, syncNone); + test (C_d, C_h, numElements, syncNullStream); + test (C_d, C_h, numElements, syncOtherStream); + //test (C_d, C_h, numElements, syncDevice); + } + + + HIPCHECK(hipFree(C_d)); + HIPCHECK(hipHostFree(C_h)); +} + + +int main(int argc, char *argv[]) +{ + HipTest::parseStandardArguments(argc, argv, true /*failOnUndefinedArg*/); + + runTests(4000000); + + passed(); +} diff --git a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp index 47baf5c206..607e2a9f63 100644 --- a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp +++ b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp @@ -21,11 +21,12 @@ */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN: %t * HIT_END */ +#include #include"test_common.h" #define LEN 1024*1024 diff --git a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp deleted file mode 100644 index 34951f0a09..0000000000 --- a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -Copyright (c) 2015-2016 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: %t %s ../../test_common.cpp - * RUN: %t - * HIT_END - */ - -#include"test_common.h" - -#define NUM_ELEMENTS 1024*1024*64 -#define SIZE NUM_ELEMENTS*sizeof(int) - -int p_count = 4; - - -void multiGpuHostAlloc(int allocDevice) -{ - - int numDevices; - HIPCHECK(hipGetDeviceCount(&numDevices)); - - printf ("info: trying multiGpuHostAlloc with allocDevice=%d numDevices=%d\n", allocDevice, numDevices); - - - HIPCHECK(hipSetDevice(allocDevice)); - - int *Ah, *Ch; - hipHostMalloc((void**)&Ah, SIZE); - hipHostMalloc((void**)&Ch, SIZE); - - const int init = -1; - for (size_t i=0; i 1) - { - multiGpuHostAlloc(1); - } - } - - passed(); -} diff --git a/projects/clr/hipamd/tests/src/runtimeApi/stream/hipStreamSync2.cpp b/projects/clr/hipamd/tests/src/runtimeApi/stream/hipStreamSync2.cpp new file mode 100644 index 0000000000..b57e120dcc --- /dev/null +++ b/projects/clr/hipamd/tests/src/runtimeApi/stream/hipStreamSync2.cpp @@ -0,0 +1,169 @@ +/* +Copyright (c) 2015-2016 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 WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * RUN: %t + * HIT_END + */ + + +#include "test_common.h" + +enum SyncMode { + syncNone, + syncNullStream, + syncOtherStream, + syncMarkerThenOtherStream, + syncMarkerThenOtherNonBlockingStream, + syncDevice +}; + + +const char *syncModeString(int syncMode) { + switch (syncMode) { + case syncNone: + return "syncNone"; + case syncNullStream: + return "syncNullStream"; + case syncOtherStream: + return "syncOtherStream"; + case syncMarkerThenOtherStream: + return "syncMarkerThenOtherStream"; + case syncMarkerThenOtherNonBlockingStream: + return "syncMarkerThenOtherNonBlockingStream"; + case syncDevice: + return "syncDevice"; + default: + return "unknown"; + }; +}; + + +void test(int *C_d, int *C_h, int64_t numElements, SyncMode syncMode, bool expectMismatch) +{ + printf ("\ntest: syncMode=%s expectMismatch=%d\n", syncModeString(syncMode), expectMismatch); + + size_t sizeBytes = numElements * sizeof(int); + + int count =100; + int init0 = 0; + HIPCHECK(hipMemset(C_d, init0, sizeBytes)); + for (int i=0; i 0); + } + + + HIPCHECK(hipStreamDestroy(otherStream)); + HIPCHECK(hipEventDestroy(e)); + + printf ("test: OK - %d mismatches (%6.2f%%)\n", mismatches, ((double)(mismatches)*100.0)/numElements); +} + + +void testEventRecord() +{ +} + + +void runTests(int64_t numElements) +{ + size_t sizeBytes = numElements * sizeof(int); + + printf ("\n\ntest: starting sequence with sizeBytes=%zu bytes, %6.2f MB\n", sizeBytes, sizeBytes/1024.0/1024.0); + + + int *C_h, *C_d; + HIPCHECK(hipMalloc(&C_d, sizeBytes)); + HIPCHECK(hipHostMalloc(&C_h, sizeBytes)); + + + { + test (C_d, C_h, numElements, syncNone, true /*expectMismatch*/); + test (C_d, C_h, numElements, syncNullStream, false /*expectMismatch*/); + test (C_d, C_h, numElements, syncOtherStream, true /*expectMismatch*/); + test (C_d, C_h, numElements, syncDevice, false /*expectMismatch*/); + test (C_d, C_h, numElements, syncMarkerThenOtherStream, false /*expectMismatch*/); + test (C_d, C_h, numElements, syncMarkerThenOtherNonBlockingStream, true /*expectMismatch*/); + } + + + HIPCHECK(hipFree(C_d)); + HIPCHECK(hipHostFree(C_h)); +} + + +int main(int argc, char *argv[]) +{ + HipTest::parseStandardArguments(argc, argv, true /*failOnUndefinedArg*/); + + runTests(40000000); + + passed(); +} diff --git a/projects/clr/hipamd/tests/src/test_common.h b/projects/clr/hipamd/tests/src/test_common.h index 81edca4e1e..f585fb8bca 100644 --- a/projects/clr/hipamd/tests/src/test_common.h +++ b/projects/clr/hipamd/tests/src/test_common.h @@ -201,6 +201,20 @@ addCountReverse( const T *A_d, } +template +__global__ void +memsetReverse( T *C_d, T val, + int64_t NELEM) +{ + size_t offset = (hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x); + size_t stride = hipBlockDim_x * hipGridDim_x ; + + for (int64_t i=NELEM-stride+offset; i>=0; i-=stride) { + C_d[i] = val; + } +} + + template void setDefaultData(size_t numElements, T *A_h, T* B_h, T *C_h) {