Support GPU memory test and compute queue test using Rocr

A new diagnostic module librdc_rocr.so is created. The
module uses Rocr to test the memory allocation, memory access
and compute queue ready status.

Change-Id: I9098f4fc3209bf381b7cb3658a4e94c2e22f2fe9


[ROCm/rdc commit: 78e2f2486b]
This commit is contained in:
Bill(Shuzhou) Liu
2021-09-16 15:38:37 -04:00
committed by Shuzhou Liu
parent ed96db8cba
commit 6b700f8005
74 changed files with 4811 additions and 25 deletions
-2
View File
@@ -421,9 +421,7 @@ typedef enum {
RDC_DIAG_TEST_FIRST = 0,
//!< The diagnostic test pass
RDC_DIAG_COMPUTE_PROCESS = RDC_DIAG_TEST_FIRST,
RDC_DIAG_SDMA_QUEUE, //!< The SDMA Queue is ready
RDC_DIAG_COMPUTE_QUEUE, //!< The Compute Queue is ready
RDC_DIAG_VRAM_CHECK, //!< Check VRAM
RDC_DIAG_SYS_MEM_CHECK, //!< Check System memory
RDC_DIAG_NODE_TOPOLOGY, //!< Report node topology
RDC_DIAG_GPU_PARAMETERS, //!< GPU parameters in range
+88
View File
@@ -0,0 +1,88 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef INCLUDE_RDC_LIB_RDCRdcPerfTimer_H_
#define INCLUDE_RDC_LIB_RDCRdcPerfTimer_H_
#include <stdint.h>
#include <iostream>
#include <vector>
#include <string>
/// \file
/// Timer related class.
namespace amd {
namespace rdc {
class RdcPerfTimer {
private:
struct Timer {
std::string name; /* < name name of time object*/
uint64_t _freq; /* < _freq frequency*/
uint64_t _clocks; /* < _clocks number of ticks at end*/
uint64_t _start; /* < _start start point ticks*/
};
std::vector<Timer*> _timers; /*< _timers vector to Timer objects */
double freq_in_100mhz;
public:
RdcPerfTimer(void);
~RdcPerfTimer(void);
/// Create a new timer.
/// \returns A new timer instance index
int CreateTimer(void);
/// Start the timer associated with the given index
/// \param[in] index Index of the timer to start
/// \returns int 0 for success, non-zero otherwise
int StartTimer(int index);
/// Stop the timer associated with the given index
/// \param[in] Index Index of the timer to stop
/// \returns int 0 for success, non-zero otherwise
int StopTimer(int index);
/// Reset the timer to 0
/// param[in] Index of the timer to reset
/// \returns void
void ResetTimer(int index);
/// Read the time value of the timer associated with the provided index.
/// Units are seconds
/// \param[in] index Index of the timer to read
/// \returns double Value of the timer
double ReadTimer(int index);
private:
void Error(std::string str);
uint64_t CoarseTimestampUs();
uint64_t MeasureTSCFreqHz();
};
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_RDCRdcPerfTimer_H_
@@ -29,6 +29,7 @@ THE SOFTWARE.
#include "rdc_lib/RdcDiagnostic.h"
#include "rdc_lib/impl/RdcRasLib.h"
#include "rdc_lib/impl/RdcSmiLib.h"
#include "rdc_lib/impl/RdcRocrLib.h"
namespace amd {
namespace rdc {
@@ -55,7 +56,8 @@ class RdcDiagnosticModule : public RdcDiagnostic {
rdc_status_t rdc_diag_destroy() override;
explicit RdcDiagnosticModule(const RdcSmiLibPtr& smi_lib,
const RdcRasLibPtr& ras_module);
const RdcRasLibPtr& ras_module,
const RdcRocrLibPtr& rocr_module);
private:
//< Helper function to dispatch fields to module
@@ -28,6 +28,7 @@ THE SOFTWARE.
#include "rdc_lib/RdcTelemetry.h"
#include "rdc_lib/impl/RdcRasLib.h"
#include "rdc_lib/impl/RdcSmiLib.h"
#include "rdc_lib/impl/RdcRocrLib.h"
namespace amd {
namespace rdc {
@@ -46,6 +47,7 @@ class RdcModuleMgrImpl: public RdcModuleMgr {
RdcRasLibPtr ras_lib_;
RdcSmiLibPtr smi_lib_;
RdcMetricFetcherPtr fetcher_;
RdcRocrLibPtr rocr_lib_;
};
} // namespace rdc
@@ -0,0 +1,74 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef INCLUDE_RDC_LIB_IMPL_RDCROCRLIB_H_
#define INCLUDE_RDC_LIB_IMPL_RDCROCRLIB_H_
#include <vector>
#include <memory>
#include "rdc_lib/RdcLibraryLoader.h"
#include "rdc_lib/RdcDiagnostic.h"
namespace amd {
namespace rdc {
class RdcRocrLib : public RdcDiagnostic {
public:
rdc_status_t rdc_diag_test_cases_query(
rdc_diag_test_cases_t test_cases[MAX_TEST_CASES],
uint32_t* test_case_count) override;
// Run a specific test case
rdc_status_t rdc_test_case_run(
rdc_diag_test_cases_t test_case,
uint32_t gpu_index[RDC_MAX_NUM_DEVICES],
uint32_t gpu_count,
rdc_diag_test_result_t* result) override;
rdc_status_t rdc_diagnostic_run(
const rdc_group_info_t& gpus,
rdc_diag_level_t level,
rdc_diag_response_t* response) override;
rdc_status_t rdc_diag_init(uint64_t flags) override;
rdc_status_t rdc_diag_destroy() override;
explicit RdcRocrLib(const char* lib_name);
~RdcRocrLib();
private:
RdcLibraryLoader lib_loader_;
rdc_status_t (*test_case_run_)(rdc_diag_test_cases_t,
uint32_t[RDC_MAX_NUM_DEVICES], uint32_t,
rdc_diag_test_result_t*);
rdc_status_t (*diag_test_cases_query_)(
rdc_diag_test_cases_t[MAX_TEST_CASES], uint32_t*);
rdc_status_t (*diag_init_)(uint64_t);
rdc_status_t (*diag_destroy_)();
};
typedef std::shared_ptr<RdcRocrLib> RdcRocrLibPtr;
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_IMPL_RDCROCRLIB_H_
@@ -0,0 +1,127 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2017, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with 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:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* 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 CONTRIBUTORS 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 WITH THE SOFTWARE.
*
*/
/**
* One instance of this kernel call is a thread.
* Each thread finds out the segment in which it should look for the element.
* After that, it checks if the element is between the lower bound and upper
* bound of its segment. If yes, then this segment becomes the total
* searchspace for the next pass.
*
* To achieve this, it writes the lower bound and upper bound to the output
* array. In case the element at the left end (lower bound) matches the element
* we are looking for, that is marked in the output and we no longer need to
* look any further.
*/
__kernel void
binarySearch(__global uint4 * outputArray,
__const __global uint2 * sortedArray,
const unsigned int findMe) {
unsigned int tid = get_global_id(0);
// Then we find the elements for this thread
uint2 element = sortedArray[tid];
// If the element to be found does not lie between
// them, then nothing left to do in this thread
if((element.x > findMe) || (element.y < findMe)) {
return;
} else {
// However, if the element does lie between the lower
// and upper bounds of this thread's searchspace
// we need to narrow down the search further in this
// search space
// The search space for this thread is marked in the
// output as being the total search space for the next pass
outputArray[0].x = tid;
outputArray[0].w = 1;
}
}
__kernel void
binarySearch_mulkeys(__global int *keys,
__global uint *input,
const unsigned int numKeys,
__global int *output) {
int gid = get_global_id(0);
int lBound = gid * 256;
int uBound = lBound + 255;
for(int i = 0; i < numKeys; i++) {
if(keys[i] >= input[lBound] && keys[i] <= input[uBound])
output[i]=lBound;
}
}
__kernel void
binarySearch_mulkeysConcurrent(__global uint *keys,
__global uint *input,
const unsigned int inputSize, // num. of inputs
const unsigned int numSubdivisions,
__global int *output) {
int lBound = (get_global_id(0) % numSubdivisions) * (inputSize / numSubdivisions);
int uBound = lBound + inputSize / numSubdivisions;
int myKey = keys[get_global_id(0) / numSubdivisions];
int mid;
while(uBound >= lBound) {
mid = (lBound + uBound) / 2;
if(input[mid] == myKey) {
output[get_global_id(0) / numSubdivisions] = mid;
return;
} else if(input[mid] > myKey) {
uBound = mid - 1;
} else {
lBound = mid + 1;
}
}
}
@@ -0,0 +1,117 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_ROCR_COMPUTEQUEUETEST_H_
#define RDC_MODULES_RDC_ROCR_COMPUTEQUEUETEST_H_
#include "rdc_modules/rdc_rocr/TestBase.h"
#include "hsa/hsa.h"
namespace amd {
namespace rdc {
// Hold all the info specific to binary search
typedef struct BinarySearch {
// Binary Search parameters
uint32_t length;
uint32_t work_group_size;
uint32_t work_grid_size;
uint32_t num_sub_divisions;
uint32_t find_me;
// Buffers needed for this application
uint32_t* input;
uint32_t* input_arr;
uint32_t* input_arr_local;
uint32_t* output;
// Keneral argument buffers and addresses
void* kern_arg_buffer; // Begin of allocated memory
// this pointer to be deallocated
void* kern_arg_address; // Properly aligned address to be used in aql
// packet (don't use for deallocation)
// Kernel code
std::string kernel_file_name;
std::string kernel_name;
uint32_t kernarg_size;
uint32_t kernarg_align;
// HSA/RocR objects needed for this application
hsa_agent_t gpu_dev;
hsa_agent_t cpu_dev;
hsa_signal_t signal;
hsa_queue_t* queue;
hsa_amd_memory_pool_t cpu_pool;
hsa_amd_memory_pool_t gpu_pool;
hsa_amd_memory_pool_t kern_arg_pool;
// Other items we need to populate AQL packet
uint64_t kernel_object;
uint32_t group_segment_size; ///< Kernel group seg size
uint32_t private_segment_size; ///< Kernel private seg size
} BinarySearch;
class ComputeQueueTest : public TestBase {
public:
explicit ComputeQueueTest(uint32_t gpu_index);
// @Brief: Destructor for test case of ComputeQueueTest
virtual ~ComputeQueueTest();
// @Brief: Setup the environment for measurement
virtual hsa_status_t SetUp();
// @Brief: Core measurement execution
virtual void Run();
// @Brief: Clean up and retrive the resource
virtual void Close();
// @Brief: Display results
virtual void DisplayResults() const;
// @Brief: Display information about what this test does
virtual void DisplayTestInfo(void);
hsa_status_t RunBinarySearchTest(void);
private:
void InitializeBinarySearch(BinarySearch* bs);
hsa_status_t FindPools(BinarySearch* bs);
hsa_status_t AllocateAndInitBuffers(BinarySearch* bs);
hsa_status_t LoadKernelFromObjFile(BinarySearch* bs);
hsa_status_t Run(BinarySearch* bs);
hsa_status_t CleanUp(BinarySearch* bs);
void PopulateAQLPacket(BinarySearch const* bs,
hsa_kernel_dispatch_packet_t* aql);
hsa_status_t AgentMemcpy(void* dst, const void* src,
size_t size, hsa_agent_t dst_ag, hsa_agent_t src_ag);
hsa_status_t AllocAndSetKernArgs(BinarySearch* bs, void* args,
size_t arg_size, void** aql_buf_ptr);
void WriteAQLToQueue(hsa_kernel_dispatch_packet_t const* in_aql,
hsa_queue_t* q);
};
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_COMPUTEQUEUETEST_H_
+72
View File
@@ -0,0 +1,72 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_ROCR_MEMORYACCESS_H_
#define RDC_MODULES_RDC_ROCR_MEMORYACCESS_H_
#include "rdc_modules/rdc_rocr/TestBase.h"
#include "hsa/hsa.h"
namespace amd {
namespace rdc {
class MemoryAccessTest : public TestBase {
public:
explicit MemoryAccessTest(uint32_t gpu_index);
// @Brief: Destructor for test case of MemoryTest
virtual ~MemoryAccessTest();
// @Brief: Setup the environment for measurement
virtual hsa_status_t SetUp();
// @Brief: Core measurement execution
virtual void Run();
// @Brief: Clean up and retrive the resource
virtual void Close();
// @Brief: Display results
virtual void DisplayResults() const;
// @Brief: Display information about what this test does
virtual void DisplayTestInfo(void);
// @Brief: This test verify that CPU is able to Read & write GPU memory
void CPUAccessToGPUMemoryTest(void);
// @Brief: This test verify that GPU is able to Read & write CPU memory
void GPUAccessToCPUMemoryTest(void);
private:
void CPUAccessToGPUMemoryTest(hsa_agent_t cpuAgent,
hsa_agent_t gpuAgent,
hsa_amd_memory_pool_t pool);
void GPUAccessToCPUMemoryTest(hsa_agent_t cpuAgent, hsa_agent_t gpuAgent);
};
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_MEMORYACCESS_H_
+64
View File
@@ -0,0 +1,64 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_ROCR_MEMORYTEST_H_
#define RDC_MODULES_RDC_ROCR_MEMORYTEST_H_
#include "rdc_modules/rdc_rocr/TestBase.h"
#include "hsa/hsa.h"
namespace amd {
namespace rdc {
class MemoryTest : public TestBase {
public:
explicit MemoryTest(uint32_t gpu_index);
// @Brief: Destructor for test case of MemoryTest
virtual ~MemoryTest();
// @Brief: Setup the environment for measurement
virtual hsa_status_t SetUp();
// @Brief: Core measurement execution
virtual void Run();
// @Brief: Clean up and retrive the resource
virtual void Close();
// @Brief: Display results
virtual void DisplayResults() const;
// @Brief: Display information about what this test does
virtual void DisplayTestInfo(void);
hsa_status_t MaxSingleAllocationTest(void);
hsa_status_t TestAllocate(hsa_amd_memory_pool_t pool, size_t sz);
private:
hsa_status_t MaxSingleAllocationTest(hsa_agent_t ag,
hsa_amd_memory_pool_t pool);
};
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_MEMORYTEST_H_
@@ -0,0 +1,28 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
#define RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
#include "rdc/rdc.h"
#include "rdc_lib/RdcDiagnosticLibInterface.h"
#endif // RDC_MODULES_RDC_DIAGNOSTIC_RDCDIAGNOSTICLIB_H_
@@ -0,0 +1,269 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_ROCR_RDCROCRBASE_H_
#define RDC_MODULES_RDC_ROCR_RDCROCRBASE_H_
#include <stdint.h>
#include <stdio.h>
#include <string>
#include "rdc_lib/RdcPerfTimer.h"
#include "hsa/hsa.h"
#include "hsa/hsa_ext_amd.h"
namespace amd {
namespace rdc {
/// Common interface for RocR tests and samples
class RdcRocrBase {
public:
RdcRocrBase(void);
virtual ~RdcRocrBase(void);
///< Setters and Getters
void set_gpu_device1(hsa_agent_t in_dev) {
gpu_device1_.handle = in_dev.handle;
}
hsa_agent_t* gpu_device1(void) {
return &gpu_device1_;
}
void set_cpu_device(hsa_agent_t in_dev) {
cpu_device_.handle = in_dev.handle;
}
hsa_agent_t* cpu_device(void) {
return &cpu_device_;
}
void set_kernel_file_name(const char* in_file_name) {
kernel_file_name_ = in_file_name;
}
std::string const kernel_file_name(void) const {
return kernel_file_name_;
}
void set_kernel_name(std::string in_kernel_name) {
kernel_name_ = in_kernel_name;
}
std::string const kernel_name(void) const {
return kernel_name_;
}
void set_agent_name(std::string in_agent_name) {
agent_name_ = in_agent_name;
}
std::string const get_agent_name(void) const {
return agent_name_;
}
void set_kernel_object(uint64_t in_kernel_object) {
kernel_object_ = in_kernel_object;
}
uint64_t kernel_object(void) const {
return kernel_object_;
}
void set_profile(hsa_profile_t in_prof) {
profile_ = in_prof;
}
hsa_profile_t profile(void) const {
return profile_;
}
uint32_t private_segment_size(void) const {
return private_segment_size_;
}
void set_private_segment_size(uint32_t sz) {
private_segment_size_ = sz;
}
void set_group_segment_size(uint32_t sz) {
group_segment_size_ = sz;
}
uint32_t group_segment_size(void) const {
return group_segment_size_;
}
void set_group_size(uint32_t sz) {
group_size_ = sz;
}
uint32_t group_size(void) const {
return group_size_;
}
void set_main_queue(hsa_queue_t* q) {
main_queue_ = q;
}
hsa_queue_t* main_queue(void) const {
return main_queue_;
}
hsa_kernel_dispatch_packet_t& aql(void) {
return aql_;
}
void set_num_iteration(int num) {
num_iteration_ = num;
}
uint32_t num_iteration(void) const {
return num_iteration_;
}
hsa_amd_memory_pool_t& device_pool(void) {
return device_pool_;
}
hsa_amd_memory_pool_t& cpu_pool(void) {
return cpu_pool_;
}
hsa_amd_memory_pool_t& kern_arg_pool(void) {
return kern_arg_pool_;
}
void set_kernarg_size(uint32_t sz) {
kernarg_size_ = sz;
}
uint32_t kernarg_size(void) const {
return kernarg_size_;
}
void set_kernarg_align(uint32_t align) {
kernarg_align_ = align;
}
uint32_t kernarg_align(void) const {
return kernarg_align_;
}
void* kernarg_buffer(void) const {
return kernarg_buffer_;
}
void set_kernarg_buffer(void* buffer) {
kernarg_buffer_ = buffer;
}
int32_t requires_profile(void) const {
return requires_profile_;
}
char* orig_hsa_enable_interrupt() const {
return orig_hsa_enable_interrupt_;
}
bool enable_interrupt() const {
return enable_interrupt_;
}
void set_title(std::string name) {
title_ = name;
}
std::string title(void) const {
return title_;
}
RdcPerfTimer* hsa_timer(void) {
return &hsa_timer_;
}
void set_verbosity(uint32_t v) {
verbosity_ = v;
}
uint32_t verbosity(void) const {
return verbosity_;
}
void set_monitor_verbosity(uint32_t m) {
monitor_verbosity_ = m;
}
uint32_t monitor_verbosity(void) const {
return monitor_verbosity_;
}
protected:
void set_requires_profile(int32_t reqd_prof) {
requires_profile_ = reqd_prof;
}
void set_enable_interrupt(bool doEnable) {
enable_interrupt_ = doEnable;
}
private:
uint64_t num_iteration_; ///< Number of times to execute test
hsa_queue_t* main_queue_; ///< AQL queue used for packets
hsa_agent_t gpu_device1_; ///< Handle to first GPU found
hsa_agent_t cpu_device_; ///< Handle to CPU
hsa_amd_memory_pool_t device_pool_; ///< Memory pool on gpu pool list
hsa_amd_memory_pool_t cpu_pool_; ///< Memory pool on cpu pool list
hsa_amd_memory_pool_t kern_arg_pool_; ///< Memory pool suitable for args
uint64_t kernel_object_; ///< Handle to kernel code
std::string kernel_file_name_; ///< Code object file name
std::string kernel_name_; ///< Kernel name
std::string agent_name_; ///< Agent name
hsa_kernel_dispatch_packet_t aql_; ///< Kernel dispatch packet
uint32_t group_segment_size_; ///< Kernel group seg size
uint32_t kernarg_size_; ///< Kernarg memory size
uint32_t kernarg_align_; ///< Alignment for kern argument memory
void* kernarg_buffer_; ///< Unaligned allocated kernel arg. buffer
hsa_profile_t profile_; ///< Device profile.
uint32_t group_size_; ///< Number of work items in one group
uint32_t private_segment_size_; ///< Kernel private seg size
int32_t requires_profile_; ///< Profile required by test (-1 if no req.)
char* orig_hsa_enable_interrupt_; ///< Orig. value of HSA_ENABLE_INTERRUPT
bool enable_interrupt_; ///< Whether to enable/disable interrupts for test
std::string title_; ///< Displayed title of test
uint32_t verbosity_; ///< How much additional output to produce
uint32_t monitor_verbosity_; ///< verbose or not
RdcPerfTimer hsa_timer_; ///< Timer to be used for timing parts of test
};
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_RDCROCRBASE_H_
+80
View File
@@ -0,0 +1,80 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_ROCR_TESTBASE_H_
#define RDC_MODULES_RDC_ROCR_TESTBASE_H_
#include <string>
#include <memory>
#include <vector>
#include "rdc_modules/rdc_rocr/RdcRocrBase.h"
namespace amd {
namespace rdc {
class TestBase : public RdcRocrBase {
public:
explicit TestBase(uint32_t gpu_index);
virtual ~TestBase(void);
enum VerboseLevel {VERBOSE_MIN = 0, VERBOSE_STANDARD, VERBOSE_PROGRESS};
// @Brief: Before run the core measure codes, do something to set up
// i.e. init runtime, prepare packet...
virtual hsa_status_t SetUp(void);
// @Brief: Core measurement codes executing here
virtual void Run(void);
// @Brief: Do something clean up
virtual void Close(void);
// @Brief: Display the results
virtual void DisplayResults(void) const;
// @Brief: Display information about the test
virtual void DisplayTestInfo(void);
const std::string & description(void) const {return description_;}
void set_description(std::string d);
const std::string & get_gpu_info() const { return gpu_info_;}
const std::string & get_per_gpu_info() const { return per_gpu_info_;}
hsa_status_t FindGPUIndex(hsa_agent_t agent, void* data);
// Return the agent by GPU index in rocm_smi
hsa_status_t get_agent_by_gpu_index(uint32_t gpu_index, hsa_agent_t* agent);
protected:
uint32_t gpu_index_;
std::string gpu_info_;
std::string per_gpu_info_;
private:
std::string description_;
};
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_TESTBASE_H_
+172
View File
@@ -0,0 +1,172 @@
/*
Copyright (c) 2021 - present 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.
*/
#ifndef RDC_MODULES_RDC_ROCR_BASE_ROCR_UTILS_H_
#define RDC_MODULES_RDC_ROCR_BASE_ROCR_UTILS_H_
/// \file
/// Prototypes of utility functions that act on RdcRocrBase objects.
#include "rdc_modules/rdc_rocr/RdcRocrBase.h"
#include <string>
#include "rdc_modules/rdc_rocr/common.h"
#include "hsa/hsa.h"
namespace amd {
namespace rdc {
/// Open binary kernel object file and set all member data related to the
/// kernel. Assumes that input test already has the kernel file name,
/// agent name and kernel function specifed
/// \param[in] test Test for which the kernel will be loaded.
/// \param[in] agent for which the kernel will be loaded .
/// \returns HSA_STATUS_SUCCESS if no errors
hsa_status_t LoadKernelFromObjFile(RdcRocrBase* test, hsa_agent_t* agent);
/// Do initialization tasks for HSA test program.
/// \param[in] test Test to initialize
/// \returns HSA_STATUS_SUCCESS if no errors
hsa_status_t InitAndSetupHSA(RdcRocrBase* test);
/// Find and set the cpu and gpu agent member variables. Also checks that
/// gpu agent meets test requirements (e.g., FULL profile vs. BASE profile).
hsa_status_t SetDefaultAgents(RdcRocrBase* test);
/// For the provided device agent, create an AQL queue
/// \param[in] device Device for which a queue is to be created
/// \param[out] queue Address to which created queue pointer will be written
/// \param[in] num_pkts Size of the queue to create
/// \param[in] do_profile [Optional] Specificy whether profiled queue should
/// be created
/// \returns HSA_STATUS_SUCCESS if no errors encountered
hsa_status_t CreateQueue(hsa_agent_t device, hsa_queue_t** queue,
uint32_t num_pkts = 0);
/// This function sets some reasonable default values for an AQL packet.
/// Override any field as necessary after calling this function.
/// \param[in] test Test from which information to populate aql packet can
/// be drawn.
/// \param[inout] aql Caller provided pointer to aql packet that will be
/// populated
/// \returns Appropriate hsa_status_t
hsa_status_t InitializeAQLPacket(const RdcRocrBase* test,
hsa_kernel_dispatch_packet_t* aql);
/// This function writes all of the aql packet fields to the queue besides
/// "setup" and "header". This assumes all the aql fields have be set
/// appropriately.
/// \param[in] test Test containing the queue and aql packet to be written.
/// \returns Pointer to dispatch packet in queue that was written to
hsa_kernel_dispatch_packet_t* WriteAQLToQueue(RdcRocrBase* test, uint64_t *ind);
void WriteAQLToQueueLoc(hsa_queue_t *queue, uint64_t indx,
hsa_kernel_dispatch_packet_t *aql_pkt);
/// This function writes the first 32 bits of an aql packet to the provided
/// aql packet. This function is meant to be called immediately before
/// ringing door_bell signal.
/// \param[in] header Value to be written to header field
/// \param[in] setup Value to be written to setup field
/// \param[in] queue_packet Start address of in queue memory of aql packet to
/// be written
/// \returns void
inline void AtomicSetPacketHeader(uint16_t header, uint16_t setup,
hsa_kernel_dispatch_packet_t* queue_packet) {
__atomic_store_n(reinterpret_cast<uint32_t*>(queue_packet),
header | (setup <<16), __ATOMIC_RELEASE);
}
/// Perform common operations to clean up after executing a test. Specifically,
/// hsa_shut_down() is called and environment variables that were changed are
/// reset to their original values.
/// \param[in] test Test for which clean up with be performed
/// \returns HSA_STATUS_SUCCESS if everything cleaned up ok, or appropriate HSA
/// error code otherwise.
hsa_status_t CommonCleanUp(RdcRocrBase* test);
/// Check to see if target machine has the necessary profile to run the
/// provided test.
/// \param[1] test The test that specifies the required profile.
bool CheckProfile(RdcRocrBase const* test);
/// Allocate memory from the kernel args pool and write the provided argument
/// data to the kernel arg memory. Assumes kern_arg memory pool has been
/// assigned. The amount of memory allocated will actually be \p arg_size
/// plus the alignment required by the kernel arguments. The argument will
/// be written with the proper alignment within the allocated buffer.
/// \p test kernarg_buffer() will point to the allocated buffer, and it should
/// be freed when the kernel is no longer being used.
/// \param test Test from which to find kern_arg pool to write arguments
/// \param args pointer to block of data containing kernel arguments to be
/// written. Arguments are assumed to be of the correct placement, length,
/// and with any padding that is expected by the OpenCL kernel
/// \param arg_size Size of the kernel arg data (including padding) to be
/// written
/// \returns HSA_STATUS_SUCCESS if no errors
hsa_status_t AllocAndSetKernArgs(RdcRocrBase* test, void* args,
size_t arg_size);
/// Verify that the machine running the test has the required profile.
/// This function will verify that the execution machine meets any specific
/// test requirement for a profile (HSA_PROFILE_BASE or HSA_PROFILE_FULL).
/// \param[in] test Test that provides profile requirements.
/// \returns bool
/// - true Machine meets test requirements
/// - false Machine does not meet test requirements
bool CheckProfileAndInform(RdcRocrBase* test);
/// This function will set the cpu and gpu memory pools to the type used in
/// many applications.
/// \param[in] test Test that provides profile requirements.
/// \returns HSA_STATUS_SUCCESS if everything cleaned up ok, or appropriate HSA
/// error code otherwise.
hsa_status_t SetPoolsTypical(RdcRocrBase* test);
/// Work-around for hsa_amd_memory_fill, which is currently broken.
/// \param[in] ptr Pointer to start of memory location to be filled
/// \param[in] value Value to write to each byte of input buffer
/// \param[in] count Size of buffer to fill
/// \param[in] dst_ag Agent owning the buffer to be filled
/// \param[in] src_ag Agent wanting to do the fill
/// \param[in] test Test that has handles to cpu and gpu agents that can own
/// either source or destination of fill
/// \returns HSA_STATUS_OK if not errors
hsa_status_t hsa_memory_fill_workaround_gen(void* ptr, uint32_t value,
size_t count, hsa_agent_t dst_ag, hsa_agent_t src_ag, RdcRocrBase* test);
/// Get the library directory which is loaded by current process.
/// It will search /proc/self/maps for it.
/// return empty string if fail.
std::string get_lib_dir(const char* lib_name);
/// Get the app dir by looking at link of /proc/self/exe
std::string get_app_dir();
// Search multiple folder for the hsaco file
// Return empty if cannot find it.
std::string search_hsaco_full_path(const char* hsaco_file_name,
const char* agent_name);
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_BASE_ROCR_UTILS_H_
+231
View File
@@ -0,0 +1,231 @@
/*
Copyright (c) 2021 - present 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.
*/
/// \file
/// RocR related helper functions for sequeneces that come up frequently
#ifndef RDC_MODULES_RDC_ROCR_COMMON_H_
#define RDC_MODULES_RDC_ROCR_COMMON_H_
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <memory>
#include "hsa/hsa.h"
#include "hsa/hsa_ext_amd.h"
namespace amd {
namespace rdc {
#if defined(_MSC_VER)
#define ALIGNED_(x) __declspec(align(x))
#else
#if defined(__GNUC__)
#define ALIGNED_(x) __attribute__ ((aligned(x)))
#endif // __GNUC__
#endif // _MSC_VER
#define MULTILINE(...) # __VA_ARGS__
#define ASSERT_EQ(a, b) (a==b)
void SetEnv(const char* env_var_name, const char* env_var_value);
intptr_t AlignDown(intptr_t value, size_t alignment);
void* AlignDown(void* value, size_t alignment);
void* AlignUp(void* value, size_t alignment);
// define below should be deleted. Leaving in commented out until code that
// refers to it has been corrected
// #define HSA_ARGUMENT_ALIGN_BYTES 16
// This structure holds memory pool information acquired through hsa info
// related calls, and is later used for reference when displaying the
// information.
typedef struct pool_info_t_ {
uint32_t segment;
size_t size;
bool alloc_allowed;
size_t alloc_granule;
size_t alloc_alignment;
bool accessible_by_all;
uint32_t global_flag;
uint64_t aggregate_alloc_max;
inline bool operator==(const pool_info_t_ &a) {
if (a.segment == segment && a.size == size
&& a.alloc_allowed == alloc_allowed
&& a.alloc_granule == alloc_granule
&& a.alloc_alignment == alloc_alignment
&& a.accessible_by_all == accessible_by_all
&& a.aggregate_alloc_max == aggregate_alloc_max
&& a.global_flag == global_flag )
return true;
else
return false;
}
} pool_info_t;
struct agent_pools_t{
hsa_agent_t agent;
std::vector<hsa_amd_memory_pool_t> pools;
};
/// Fill in the pool_info_t structure for the provided pool.
/// \param[in] pool Pool for which information will be retrieved
/// \param[out] pool_i Pointer to structure where pool info will be stored
/// \returns HSA_STATUS_SUCCESS if no errors are encountered.
hsa_status_t AcquirePoolInfo(hsa_amd_memory_pool_t pool, pool_info_t *pool_i);
/// If the provided agent is associated with a GPU, return that agent through
/// output parameter. This function is meant to be the call-back function used
/// with hsa_iterate_agents to find GPU agents.
/// \param[in] agent Agent to evaluate if GPU
/// \param[out] data If agent is associated with a GPU, this pointer will point
/// to the agent upon return
/// \returns HSA_STATUS_SUCCESS if no errors are encountered.
hsa_status_t FindGPUDevice(hsa_agent_t agent, void* data);
/// If the provided agent is associated with a CPU, return that agent through
/// output parameter. This function is meant to be the call-back function used
/// with hsa_iterate_agents to find CPU agents.
/// \param[in] agent Agent to evaluate if CPU
/// \param[out] data If agent is associated with a CPU, this pointer will point
/// to the agent upon return
/// \returns HSA_STATUS_SUCCESS if no errors are encountered.
hsa_status_t FindCPUDevice(hsa_agent_t agent, void* data);
// TODO(cfreehil): get rid of FindGlobalPool and replace with FindStandardPool
hsa_status_t FindGlobalPool(hsa_amd_memory_pool_t pool, void* data);
/// If the provided agent is associated with a CPU, return that agent through
/// output parameter. This function is meant to be the call-back function used
/// with hsa_iterate_agents to find all the CPU agents.
/// \param[in] agent Agent to evaluate if CPU
/// \param[out] data If agent is associated with a CPU, this pointer will point
/// to the agent upon return
/// \returns HSA_STATUS_SUCCESS if no errors are encountered.
hsa_status_t IterateCPUAgents(hsa_agent_t agent, void *data);
/// If the provided agent is associated with a GPU, return that agent through
/// output parameter. This function is meant to be the call-back function used
/// with hsa_iterate_agents to find all the GPU agents.
/// \param[in] agent Agent to evaluate if GPU
/// \param[out] data If agent is associated with a GPU, this pointer will point
/// to the agent upon return
/// \returns HSA_STATUS_SUCCESS if no errors are encountered.
hsa_status_t IterateGPUAgents(hsa_agent_t agent, void *data);
/// Find a GLOBAL memory pool. By this, we mean not a kernel args pool.
/// This function is meant to be the call-back function used
/// with hsa_amd_agent_iterate_memory_pools.
/// \param[in] pool Pool to evaluate for required properties
/// \param[in] data If pool meets criteria, this pointer will point
/// to the pool upon return
/// \returns hsa_status_t
/// -HSA_STATUS_INFO_BREAK - we found a pool that meets criteria
/// -HSA_STATUS_SUCCESS - we did not find a pool that meets the criteria
/// -else return an appropriate error code for any error encountered
hsa_status_t GetGlobalMemoryPool(hsa_amd_memory_pool_t pool, void* data);
/// Find a "kernel arg" pool.
/// This function is meant to be the call-back function used
/// with hsa_amd_agent_iterate_memory_pools.
/// \param[in] pool Pool to evaluate for required properties
/// \param[in] data If pool meets criteria, this pointer will point
/// to the pool upon return
/// \returns hsa_status_t
/// -HSA_STATUS_INFO_BREAK - we found a pool that meets criteria
/// -HSA_STATUS_SUCCESS - we did not find a pool that meets the criteria
/// -else return an appropriate error code for any error encountered
hsa_status_t GetKernArgMemoryPool(hsa_amd_memory_pool_t pool, void* data);
/// Find a "standard" pool. By this, we mean not a kernel args pool.
/// The pool found will have the following properties:
/// HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL: Don't care
/// HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT: Off
/// HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED: Don't care
/// This function is meant to be the call-back function used
/// with hsa_amd_agent_iterate_memory_pools.
/// \param[in] pool Pool to evaluate for required properties
/// \param[in] data If pool meets criteria, this pointer will point
/// to the pool upon return
/// \returns hsa_status_t
/// -HSA_STATUS_INFO_BREAK - we found a pool that meets criteria
/// -HSA_STATUS_SUCCESS - we did not find a pool that meets the criteria
/// -else return an appropriate error code for any error encountered
hsa_status_t FindStandardPool(hsa_amd_memory_pool_t pool, void* data);
hsa_status_t FindAPUStandardPool(hsa_amd_memory_pool_t pool, void* data);
/// Find a "kernel arg" pool.
/// The pool found will have the following properties:
/// HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL: Don't care
/// HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT: On
/// HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED: Don't care
/// This function is meant to be the call-back function used
/// with hsa_amd_agent_iterate_memory_pools.
/// \param[in] pool Pool to evaluate for required properties
/// \param[in] data If pool meets criteria, this pointer will point
/// to the pool upon return
/// \returns hsa_status_t
/// -HSA_STATUS_INFO_BREAK - we found a pool that meets criteria
/// -HSA_STATUS_SUCCESS - we did not find a pool that meets the criteria
/// -else return an appropriate error code for any error encountered
hsa_status_t FindKernArgPool(hsa_amd_memory_pool_t pool, void* data);
/// Dump information about provided memory pool to STDOUT
/// \param[in] pool Pool to gather and dump information for
/// \param[in] indent Number of spaces to indent output.
/// \returns hsa_status_t HSA_STATUS_SUCCESS if no errors
hsa_status_t DumpMemoryPoolInfo(const pool_info_t *pool_i,
uint32_t indent = 0);
/// Dump information about a provided pointer to STDOUT.
/// \param[in] ptr Pointer about which information is dumped.
/// \returns HSA_STATUS_SUCCESS if there are no errors
hsa_status_t DumpPointerInfo(void* ptr);
hsa_status_t GetAgentPools(
std::vector<std::shared_ptr<agent_pools_t>> *agent_pools);
void throw_if_error(hsa_status_t err, const std::string& msg = "");
void throw_if_skip(const std::string& msg);
// The customize exception when the test has to be skipped
class SkipException : public std::exception {
public:
explicit SkipException(const char* msg): _msg(msg) {}
virtual const char* what() const noexcept { return _msg.c_str(); }
private:
std::string _msg;
};
} // namespace rdc
} // namespace amd
#endif // RDC_MODULES_RDC_ROCR_COMMON_H_