Resubmitted added and modified common utilities functions for rocrtest with faile to open file fix
Change-Id: Ie45668df1a15c1be7e8bdb10b967b98fb3024252
このコミットが含まれているのは:
@@ -98,6 +98,13 @@ class BaseRocR {
|
||||
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;
|
||||
}
|
||||
@@ -251,6 +258,8 @@ class BaseRocR {
|
||||
|
||||
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
|
||||
|
||||
@@ -261,13 +261,23 @@ bool CheckProfile(BaseRocR const* test) {
|
||||
// -group_segment_size()
|
||||
// -kernarg_size()
|
||||
// -kernarg_align()
|
||||
hsa_status_t LoadKernelFromObjFile(BaseRocR* test) {
|
||||
hsa_status_t LoadKernelFromObjFile(BaseRocR* test, hsa_agent_t* agent) {
|
||||
hsa_status_t err;
|
||||
hsa_code_object_reader_t code_obj_rdr = {0};
|
||||
hsa_executable_t executable = {0};
|
||||
|
||||
assert(test != nullptr);
|
||||
hsa_agent_t* agent = test->gpu_device1(); // Assume GPU agent for now
|
||||
if (agent == nullptr) {
|
||||
agent = test->gpu_device1(); // Assume GPU agent for now
|
||||
}
|
||||
|
||||
// if agent name is not set, then set the agent name
|
||||
if (!test->get_agent_name().size()) {
|
||||
char agent_name[64];
|
||||
err = hsa_agent_get_info(*agent, HSA_AGENT_INFO_NAME, agent_name);
|
||||
RET_IF_HSA_UTILS_ERR(err);
|
||||
test->set_agent_name(agent_name);
|
||||
}
|
||||
std::string obj_file = "./" + test->kernel_file_name();
|
||||
std::string kern_name = test->kernel_name();
|
||||
|
||||
|
||||
@@ -55,11 +55,12 @@
|
||||
namespace rocrtst {
|
||||
|
||||
/// Open binary kernel object file and set all member data related to the
|
||||
/// kernel. Assumes that input test already has the kernel file name and
|
||||
/// kernel function specifed
|
||||
/// 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(BaseRocR* test);
|
||||
hsa_status_t LoadKernelFromObjFile(BaseRocR* test, hsa_agent_t* agent);
|
||||
|
||||
/// Do initialization tasks for HSA test program.
|
||||
/// \param[in] test Test to initialize
|
||||
|
||||
@@ -83,6 +83,104 @@ static hsa_status_t FindAgent(hsa_agent_t agent, void* data,
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Find CPU Agents
|
||||
hsa_status_t IterateCPUAgents(hsa_agent_t agent, void *data) {
|
||||
hsa_status_t status;
|
||||
assert(data != nullptr);
|
||||
if (data == nullptr) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
std::vector<hsa_agent_t>* cpus = static_cast<std::vector<hsa_agent_t>*>(data);
|
||||
hsa_device_type_t device_type;
|
||||
status = hsa_agent_get_info(agent, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
RET_IF_HSA_COMMON_ERR(status);
|
||||
if (HSA_STATUS_SUCCESS == status && HSA_DEVICE_TYPE_CPU == device_type) {
|
||||
cpus->push_back(agent);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Find GPU Agents
|
||||
hsa_status_t IterateGPUAgents(hsa_agent_t agent, void *data) {
|
||||
hsa_status_t status;
|
||||
assert(data != nullptr);
|
||||
if (data == nullptr) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
std::vector<hsa_agent_t>* gpus = static_cast<std::vector<hsa_agent_t>*>(data);
|
||||
hsa_device_type_t device_type;
|
||||
status = hsa_agent_get_info(agent, HSA_AGENT_INFO_DEVICE, &device_type);
|
||||
RET_IF_HSA_COMMON_ERR(status);
|
||||
if (HSA_STATUS_SUCCESS == status && HSA_DEVICE_TYPE_GPU == device_type) {
|
||||
gpus->push_back(agent);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// Find coarse grained system memory.
|
||||
hsa_status_t GetGlobalMemoryPool(hsa_amd_memory_pool_t pool, void* data) {
|
||||
hsa_amd_segment_t segment;
|
||||
hsa_status_t err;
|
||||
err = hsa_amd_memory_pool_get_info(pool,
|
||||
HSA_AMD_MEMORY_POOL_INFO_SEGMENT,
|
||||
&segment);
|
||||
if (HSA_AMD_SEGMENT_GLOBAL != segment)
|
||||
return err;
|
||||
|
||||
hsa_amd_memory_pool_global_flag_t flags;
|
||||
err = hsa_amd_memory_pool_get_info(pool,
|
||||
HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS,
|
||||
&flags);
|
||||
RET_IF_HSA_COMMON_ERR(err);
|
||||
|
||||
// this is valid for dGPUs. But on APUs, it has to be FINE_GRAINED
|
||||
if (flags & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED) {
|
||||
hsa_amd_memory_pool_t* ret =
|
||||
reinterpret_cast<hsa_amd_memory_pool_t*>(data);
|
||||
*ret = pool;
|
||||
} else { // this is for APUs
|
||||
if (flags & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED) {
|
||||
hsa_amd_memory_pool_t* ret =
|
||||
reinterpret_cast<hsa_amd_memory_pool_t*>(data);
|
||||
*ret = pool;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
// Find a memory pool that can be used for kernarg locations.
|
||||
hsa_status_t GetKernArgMemoryPool(hsa_amd_memory_pool_t pool, void* data) {
|
||||
hsa_status_t err;
|
||||
if (nullptr == data) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
hsa_amd_segment_t segment;
|
||||
err = hsa_amd_memory_pool_get_info(pool,
|
||||
HSA_AMD_MEMORY_POOL_INFO_SEGMENT,
|
||||
&segment);
|
||||
RET_IF_HSA_COMMON_ERR(err);
|
||||
if (HSA_AMD_SEGMENT_GLOBAL != segment) {
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_amd_memory_pool_global_flag_t flags;
|
||||
err = hsa_amd_memory_pool_get_info(pool,
|
||||
HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS,
|
||||
&flags);
|
||||
RET_IF_HSA_COMMON_ERR(err);
|
||||
|
||||
if (flags & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT) {
|
||||
hsa_amd_memory_pool_t* ret =
|
||||
reinterpret_cast<hsa_amd_memory_pool_t*>(data);
|
||||
*ret = pool;
|
||||
}
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t FindGPUDevice(hsa_agent_t agent, void* data) {
|
||||
return FindAgent(agent, data, HSA_DEVICE_TYPE_GPU);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,49 @@ 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
|
||||
|
||||
@@ -136,7 +136,7 @@ void DispatchTime::SetUp() {
|
||||
num_batch_ = num_batch_ > size ? size : num_batch_;
|
||||
}
|
||||
|
||||
err = rocrtst::LoadKernelFromObjFile(this);
|
||||
err = rocrtst::LoadKernelFromObjFile(this, gpu_dev);
|
||||
ASSERT_EQ(err, HSA_STATUS_SUCCESS);
|
||||
|
||||
// Fill up the kernel packet except header
|
||||
|
||||
@@ -197,7 +197,7 @@ void TestExample::SetUp(void) {
|
||||
ASSERT_NE(q, nullptr);
|
||||
set_main_queue(q);
|
||||
|
||||
err = rocrtst::LoadKernelFromObjFile(this);
|
||||
err = rocrtst::LoadKernelFromObjFile(this, gpu_dev);
|
||||
ASSERT_EQ(err, HSA_STATUS_SUCCESS);
|
||||
|
||||
// Fill up the kernel packet (except header) with some values we've
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする