SWDEV-289401 - Catch2 tests for hip event APIs
Change-Id: I7c28f842282e07c21656fb92ddbb1a9ad32d752c
[ROCm/hip-tests commit: 8093223eec]
This commit is contained in:
@@ -49,6 +49,11 @@ THE SOFTWARE.
|
||||
#define HIP_ASSERT(x) \
|
||||
{ REQUIRE((x)); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#endif
|
||||
|
||||
// Utility Functions
|
||||
namespace HipTest {
|
||||
@@ -57,4 +62,28 @@ static inline int getDeviceCount() {
|
||||
HIP_CHECK(hipGetDeviceCount(&dev));
|
||||
return dev;
|
||||
}
|
||||
|
||||
// Returns the current system time in microseconds
|
||||
static inline long long get_time() {
|
||||
return std::chrono::high_resolution_clock::now().time_since_epoch()
|
||||
/std::chrono::microseconds(1);
|
||||
}
|
||||
|
||||
static inline double elapsed_time(long long startTimeUs, long long stopTimeUs) {
|
||||
return ((double)(stopTimeUs - startTimeUs)) / ((double)(1000));
|
||||
}
|
||||
|
||||
static inline unsigned setNumBlocks(unsigned blocksPerCU, unsigned threadsPerBlock, size_t N) {
|
||||
int device;
|
||||
HIP_CHECK(hipGetDevice(&device));
|
||||
hipDeviceProp_t props;
|
||||
HIP_CHECK(hipGetDeviceProperties(&props, device));
|
||||
|
||||
unsigned blocks = props.multiProcessorCount * blocksPerCU;
|
||||
if (blocks * threadsPerBlock > N) {
|
||||
blocks = (N + threadsPerBlock - 1) / threadsPerBlock;
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user