Rakesh Roy
2024-02-19 15:14:45 +05:30
Se han modificado 101 ficheros con 11970 adiciones y 257 borrados
+2 -1
Ver fichero
@@ -26,8 +26,9 @@ struct CmdOptions {
int iterations = 10;
int warmups = 100;
int cg_extended_run = 5;
int cg_iterations = 5;
bool no_display = false;
bool progress = false;
};
extern CmdOptions cmd_options;
extern CmdOptions cmd_options;
+26
Ver fichero
@@ -78,6 +78,32 @@ struct CPUGrid {
unsigned int thread_count_;
};
struct CPUMultiGrid {
CPUMultiGrid(const unsigned int num_grids, const dim3 grid_dims[], const dim3 block_dims[]) {
thread_count_ = 0;
grid_count_ = num_grids;
grids_.reserve(grid_count_);
for (int i = 0; i < grid_count_; i++) {
grids_.emplace_back(grid_dims[i], block_dims[i]);
thread_count_ += grids_[i].thread_count_;
}
}
inline unsigned int thread0_rank_in_multi_grid(const unsigned int grid_rank) const {
unsigned int multi_grid_thread_rank_0 = 0;
unsigned int multi_grid_thread_count = 0;
for (int i = 0; i <= grid_rank; i++) {
multi_grid_thread_rank_0 = multi_grid_thread_count;
multi_grid_thread_count += grids_[i].thread_count_;
}
return multi_grid_thread_rank_0;
}
std::vector<CPUGrid> grids_;
unsigned int grid_count_;
unsigned int thread_count_;
};
/* Generate dimensions for 1D, 2D and 3D blocks of threads */
inline dim3 GenerateThreadDimensions() {
hipDeviceProp_t props;
@@ -144,6 +144,28 @@ THE SOFTWARE.
* @}
*/
/**
* @defgroup StreamOTest Ordered Memory Allocator
* @{
* This section describes the tests for Stream Ordered Memory Allocator functions of HIP runtime
* API.
* @}
*/
/**
* @defgroup StreamOTest Ordered Memory Allocator
* @{
* This section describes the tests for Stream Ordered Memory Allocator functions of HIP runtime
* API.
*/
/**
* @defgroup StreamOTest Ordered Memory Allocator
* @{
* This section describes the tests for Stream Ordered Memory Allocator functions of HIP runtime
* API.
*/
/**
* @defgroup StreamTest Stream Management
* @{
@@ -171,3 +193,17 @@ THE SOFTWARE.
* This section describes the various Printf use case Scenarios.
* @}
*/
/**
* @defgroup SurfaceTest Surface Management
* @{
* This section describes tests for the surface management functions of HIP runtime API.
* @}
*/
/**
* @defgroup ComplexTest Complex type
* @{
* This section describes tests for the Complex type functions.
* @}
*/
@@ -102,23 +102,25 @@ template <typename T> class LinearAllocGuard {
~LinearAllocGuard() {
// No Catch macros, don't want to possibly throw in the destructor
switch (allocation_type_) {
case LinearAllocs::noAlloc:
break;
case LinearAllocs::malloc:
free(ptr_);
break;
case LinearAllocs::mallocAndRegister:
// Cast to void to suppress nodiscard warnings
static_cast<void>(hipHostUnregister(host_ptr_));
free(host_ptr_);
break;
case LinearAllocs::hipHostMalloc:
static_cast<void>(hipHostFree(ptr_));
break;
case LinearAllocs::hipMalloc:
case LinearAllocs::hipMallocManaged:
static_cast<void>(hipFree(ptr_));
if (ptr_ != nullptr) {
switch (allocation_type_) {
case LinearAllocs::noAlloc:
break;
case LinearAllocs::malloc:
free(ptr_);
break;
case LinearAllocs::mallocAndRegister:
// Cast to void to suppress nodiscard warnings
static_cast<void>(hipHostUnregister(host_ptr_));
free(host_ptr_);
break;
case LinearAllocs::hipHostMalloc:
static_cast<void>(hipHostFree(ptr_));
break;
case LinearAllocs::hipMalloc:
case LinearAllocs::hipMallocManaged:
static_cast<void>(hipFree(ptr_));
}
}
}
@@ -287,7 +289,7 @@ class StreamGuard {
}
~StreamGuard() {
if (stream_type_ == Streams::created) {
if (stream_type_ == Streams::created && stream_ != nullptr) {
static_cast<void>(hipStreamDestroy(stream_));
}
}
@@ -346,3 +348,45 @@ class StreamsGuard {
private:
std::vector<hipStream_t> streams_;
};
enum class MemPools { dev_default, created };
class MemPoolGuard {
public:
MemPoolGuard(const MemPools mempool_type, int device,
hipMemAllocationHandleType handle_type = hipMemHandleTypeNone)
: mempool_type_{mempool_type}, device_{device}, handle_type_{handle_type} {
switch (mempool_type_) {
case MemPools::dev_default:
HIP_CHECK(hipDeviceGetDefaultMemPool(&mempool_, device_));
break;
case MemPools::created:
hipMemPoolProps pool_props;
pool_props.allocType = hipMemAllocationTypePinned;
pool_props.handleTypes = handle_type_;
pool_props.location.type = hipMemLocationTypeDevice;
pool_props.location.id = device_;
pool_props.win32SecurityAttributes = nullptr;
memset(pool_props.reserved, 0, sizeof(pool_props.reserved));
HIP_CHECK(hipMemPoolCreate(&mempool_, &pool_props));
}
}
MemPoolGuard(const MemPoolGuard&) = delete;
MemPoolGuard(MemPoolGuard&&) = delete;
~MemPoolGuard() {
if (mempool_type_ == MemPools::created) {
static_cast<void>(hipMemPoolDestroy(mempool_));
}
}
hipMemPool_t mempool() const { return mempool_; }
private:
const MemPools mempool_type_;
int device_;
hipMemAllocationHandleType handle_type_;
hipMemPool_t mempool_;
};