Merge 'amd-master-next' into 'amd-npi-next'
Change-Id: I935fc8f681fad2df4e932407287a29a6a797351a
This commit is contained in:
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,13 @@ THE SOFTWARE.
|
||||
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS -std=c++11
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS -std=c++11 EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
#include "test_common.h"
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "hip/hip_fp16.h"
|
||||
|
||||
#define test_passed(test_name) \
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* */
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: hipMalloc %cxx -D__HIP_PLATFORM_HCC__ -I%hip-path/include -I/opt/rocm/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/%t -std=c++11 EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD_CMD: hipMalloc %cxx -D__HIP_PLATFORM_HCC__ -I%hip-path/include -I/opt/rocm/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t -std=c++11 EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM nvcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
/* HIT_START
|
||||
* BUILD_CMD: gpu.o %hc -I%hip-path/include -g -c %S/gpu.cpp -o %T/gpu.o EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* BUILD_CMD: launchkernel.o %hc -D__HIP_PLATFORM_HCC__ -g -I%hip-path/include -c %S/LaunchKernel.c -o %T/launchkernel.o EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* BUILD_CMD: LaunchKernel %hc %T/launchkernel.o %T/gpu.o -g -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/%t DEPENDS gpu.o launchkernel.o EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* BUILD_CMD: LaunchKernel %hc %T/launchkernel.o %T/gpu.o -g -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t DEPENDS gpu.o launchkernel.o EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_NVCC__ -I%hip-path/include -I/usr/local/cuda/include %S/%s -o %T/hipMalloc_nv -L/usr/local/cuda/lib64 -lcudart EXCLUDE_HIP_PLATFORM hcc rocclr
|
||||
* BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_HCC__ -I%hip-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_HCC__ -I%hip-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* TEST: hipMalloc_nv EXCLUDE_HIP_PLATFORM hcc rocclr
|
||||
* TEST: hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc rocclr
|
||||
* HIT_END
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -43,6 +43,7 @@ void single_process() {
|
||||
|
||||
// Negative, Make sure we return error when an offset of original ptr is passed
|
||||
ipc_offset_dptr = ipc_dptr + (OFFSET * sizeof(int));
|
||||
// HIP API return value differs from CUDA's return type
|
||||
assert(hipErrorInvalidDevicePointer == hipIpcGetMemHandle(&ipc_offset_handle, ipc_offset_dptr));
|
||||
|
||||
// Get handle for the device_ptr
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11
|
||||
* TEST_NAMED: %t hipDeviceGetPCIBusId-vs-hipDeviceGetAttribute --tests 0x1
|
||||
* TEST_NAMED: %t hipDeviceGetPCIBusId-vs-lspci --tests 0x2
|
||||
* TEST_NAMED: %t hipDeviceGetPCIBusId-vs-lspci --tests 0x2 EXCLUDE_HIP_PLATFORM nvcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -106,8 +106,13 @@ bool compareHipDeviceGetPCIBusIdWithLspci() {
|
||||
getPciBusId(deviceCount, hipDeviceList);
|
||||
|
||||
// Get lspci device list and compare with hip device list
|
||||
#if defined(__CUDA_ARCH__)
|
||||
char const *command = "lspci -D | grep controller | grep NVIDIA | "
|
||||
"cut -d ' ' -f 1";
|
||||
#else
|
||||
char const *command = "lspci -D | grep controller | grep AMD/ATI | "
|
||||
"cut -d ' ' -f 1";
|
||||
#endif
|
||||
fpipe = popen(command, "r");
|
||||
|
||||
if (fpipe == nullptr) {
|
||||
|
||||
@@ -467,6 +467,7 @@ void HipMemcpyWithStreamMultiThreadtests::TestkindDefaultForDtoD(void) {
|
||||
&A_h[0], &B_h[0], &C_h[0], N, false);
|
||||
|
||||
for (int i=1; i < numDevices; ++i) {
|
||||
HIPCHECK(hipSetDevice(i));
|
||||
HIPCHECK(hipMalloc(&A_d[i], Nbytes));
|
||||
HIPCHECK(hipMalloc(&B_d[i], Nbytes));
|
||||
HIPCHECK(hipMalloc(&C_d[i], Nbytes));
|
||||
@@ -476,6 +477,7 @@ void HipMemcpyWithStreamMultiThreadtests::TestkindDefaultForDtoD(void) {
|
||||
|
||||
hipStream_t stream[numDevices];
|
||||
for (int i=0; i < numDevices; ++i) {
|
||||
HIPCHECK(hipSetDevice(i));
|
||||
HIPCHECK(hipStreamCreate(&stream[i]));
|
||||
}
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ bool testhipMemset2AsyncOps() {
|
||||
hipStream_t s;
|
||||
hipStreamCreate(&s);
|
||||
hipMemsetAsync(p2, 0, 32*32*4, s);
|
||||
hipMemsetD32Async(p3, 0x3fe00000, 32*32, s );
|
||||
hipMemsetD32Async((hipDeviceptr_t)p3, 0x3fe00000, 32*32, s );
|
||||
hipStreamSynchronize(s);
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
hipMemsetAsync(p2, 0, 32*32*4, s);
|
||||
hipMemsetD32Async(p3, 0x3fe00000, 32*32, s );
|
||||
hipMemsetD32Async((hipDeviceptr_t)p3, 0x3fe00000, 32*32, s );
|
||||
}
|
||||
hipStreamSynchronize(s);
|
||||
hipDeviceSynchronize();
|
||||
|
||||
@@ -60,8 +60,6 @@ void run(const std::vector<char>& buffer, int deviceNo) {
|
||||
hipSetDevice(deviceNo);
|
||||
hipModule_t Module;
|
||||
hipFunction_t Function;
|
||||
HIPCHECK(hipModuleLoadData(&Module, &buffer[0]));
|
||||
HIPCHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
|
||||
float *A, *B, *Ad, *Bd;
|
||||
A = new float[LEN];
|
||||
@@ -78,6 +76,9 @@ void run(const std::vector<char>& buffer, int deviceNo) {
|
||||
HIPCHECK(hipMemcpy(Ad, A, SIZE, hipMemcpyHostToDevice));
|
||||
HIPCHECK(hipMemcpy(Bd, B, SIZE, hipMemcpyHostToDevice));
|
||||
|
||||
HIPCHECK(hipModuleLoadData(&Module, &buffer[0]));
|
||||
HIPCHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
|
||||
hipStream_t stream;
|
||||
HIPCHECK(hipStreamCreate(&stream));
|
||||
|
||||
|
||||
@@ -56,8 +56,6 @@ std::vector<char> load_file() {
|
||||
void run(const std::vector<char>& buffer) {
|
||||
hipModule_t Module;
|
||||
hipFunction_t Function;
|
||||
HIPCHECK(hipModuleLoadData(&Module, &buffer[0]));
|
||||
HIPCHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
|
||||
float *A, *B, *Ad, *Bd;
|
||||
A = new float[LEN];
|
||||
@@ -74,6 +72,9 @@ void run(const std::vector<char>& buffer) {
|
||||
HIPCHECK(hipMemcpy(Ad, A, SIZE, hipMemcpyHostToDevice));
|
||||
HIPCHECK(hipMemcpy(Bd, B, SIZE, hipMemcpyHostToDevice));
|
||||
|
||||
HIPCHECK(hipModuleLoadData(&Module, &buffer[0]));
|
||||
HIPCHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
|
||||
hipStream_t stream;
|
||||
HIPCHECK(hipStreamCreate(&stream));
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: tex2d_kernel.code %hc --genco %S/tex2d_kernel.cpp -o tex2d_kernel.code EXCLUDE_HIP_PLATFORM rocclr
|
||||
* BUILD_CMD: tex2d_kernel.code %hc --genco %S/tex2d_kernel.cpp -o tex2d_kernel.code EXCLUDE_HIP_PLATFORM rocclr nvcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
|
||||
@@ -81,6 +81,13 @@ static void HIPRT_CB Callback1(hipStream_t stream, hipError_t status,
|
||||
sleep(SECONDS_TO_WAIT);
|
||||
}
|
||||
|
||||
bool rangedCompare(long a, long b) {
|
||||
auto diff = b - a;
|
||||
if (diff < 0) diff *= -1;
|
||||
if (diff < 500) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
float *A_d, *C_d;
|
||||
@@ -139,7 +146,8 @@ int main(int argc, char* argv[]) {
|
||||
// completes the execution. Therefore the hipStreamSynchronize() in the
|
||||
// main thread should hardly take any time to complete.
|
||||
|
||||
if (duration.count() < SECONDS_TO_WAIT * TO_MICROSECONDS) {
|
||||
if ((duration.count() < (SECONDS_TO_WAIT * TO_MICROSECONDS)) ||
|
||||
(rangedCompare(duration.count(), SECONDS_TO_WAIT * TO_MICROSECONDS))) {
|
||||
passed();
|
||||
} else {
|
||||
failed("hipStreamSynchronize is waiting untill Callback() completes.");
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM all
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Check if priorities are indeed supported
|
||||
if ((priority_low + priority_high) != 0) {
|
||||
failed("Priorities are not supported");
|
||||
passed(); // exit the test since priorities are not supported
|
||||
}
|
||||
|
||||
// Checking Priority of default stream
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "timer.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#include <windows.h>
|
||||
#pragma comment(lib, "user32")
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <time.h>
|
||||
#define NANOSECONDS_PER_SEC 1000000000
|
||||
#endif
|
||||
|
||||
CPerfCounter::CPerfCounter() : _clocks(0), _start(0)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
QueryPerformanceFrequency((LARGE_INTEGER *)&_freq);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
_freq = NANOSECONDS_PER_SEC;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
CPerfCounter::~CPerfCounter()
|
||||
{
|
||||
// EMPTY!
|
||||
}
|
||||
|
||||
void
|
||||
CPerfCounter::Start(void)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
if( _start )
|
||||
{
|
||||
MessageBox(NULL, "Bad Perf Counter Start", "Error", MB_OK);
|
||||
exit(0);
|
||||
}
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&_start);
|
||||
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
|
||||
struct timespec s;
|
||||
clock_gettime(CLOCK_MONOTONIC, &s);
|
||||
_start = (i64)s.tv_sec * NANOSECONDS_PER_SEC + (i64)s.tv_nsec ;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CPerfCounter::Stop(void)
|
||||
{
|
||||
i64 n;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
if( !_start )
|
||||
{
|
||||
MessageBox(NULL, "Bad Perf Counter Stop", "Error", MB_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&n);
|
||||
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
|
||||
struct timespec s;
|
||||
clock_gettime(CLOCK_MONOTONIC, &s);
|
||||
n = (i64)s.tv_sec * NANOSECONDS_PER_SEC + (i64)s.tv_nsec ;
|
||||
|
||||
#endif
|
||||
|
||||
n -= _start;
|
||||
_start = 0;
|
||||
_clocks += n;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfCounter::Reset(void)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
if( _start )
|
||||
{
|
||||
MessageBox(NULL, "Bad Perf Counter Reset", "Error", MB_OK);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
_clocks = 0;
|
||||
}
|
||||
|
||||
double
|
||||
CPerfCounter::GetElapsedTime(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if( _start ) {
|
||||
MessageBox(NULL, "Trying to get time while still running.", "Error", MB_OK);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (double)_clocks / (double)_freq;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef _TIMER_H_
|
||||
#define _TIMER_H_
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef __int64 i64 ;
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
typedef long long i64;
|
||||
#endif
|
||||
|
||||
class CPerfCounter {
|
||||
|
||||
public:
|
||||
CPerfCounter();
|
||||
~CPerfCounter();
|
||||
void Start(void);
|
||||
void Stop(void);
|
||||
void Reset(void);
|
||||
double GetElapsedTime(void);
|
||||
|
||||
private:
|
||||
|
||||
i64 _freq;
|
||||
i64 _clocks;
|
||||
i64 _start;
|
||||
};
|
||||
|
||||
#endif // _TIMER_H_
|
||||
Reference in New Issue
Block a user