From 061789c3fdbbca659f5dbbc83fbd149a32193bf2 Mon Sep 17 00:00:00 2001 From: Kent Russell Date: Fri, 15 Dec 2017 07:04:30 -0400 Subject: [PATCH] Revert "added and modified common utilities functions for rocrtest" This reverts commit 4c4869bf506f26b1194bf8337f6872fbbf23447b. Change-Id: I825b210ce4fc831f8a978faf1c7d83d54408efa4 [ROCm/ROCR-Runtime commit: c3a880db7db4c9130f8a9905878677417bc3d0f5] --- .../rocr-runtime/rocrtst/common/base_rocr.h | 9 -- .../rocrtst/common/base_rocr_utils.cc | 18 +--- .../rocrtst/common/base_rocr_utils.h | 7 +- .../rocr-runtime/rocrtst/common/common.cc | 98 ------------------- projects/rocr-runtime/rocrtst/common/common.h | 43 -------- .../suites/performance/dispatch_time.cc | 2 +- .../suites/test_common/test_case_template.cc | 2 +- 7 files changed, 8 insertions(+), 171 deletions(-) diff --git a/projects/rocr-runtime/rocrtst/common/base_rocr.h b/projects/rocr-runtime/rocrtst/common/base_rocr.h index 74e76d318a..cdaf43a34b 100755 --- a/projects/rocr-runtime/rocrtst/common/base_rocr.h +++ b/projects/rocr-runtime/rocrtst/common/base_rocr.h @@ -98,13 +98,6 @@ 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; } @@ -258,8 +251,6 @@ 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 diff --git a/projects/rocr-runtime/rocrtst/common/base_rocr_utils.cc b/projects/rocr-runtime/rocrtst/common/base_rocr_utils.cc index e83ad22fb7..2630a24bb6 100755 --- a/projects/rocr-runtime/rocrtst/common/base_rocr_utils.cc +++ b/projects/rocr-runtime/rocrtst/common/base_rocr_utils.cc @@ -261,28 +261,16 @@ bool CheckProfile(BaseRocR const* test) { // -group_segment_size() // -kernarg_size() // -kernarg_align() -hsa_status_t LoadKernelFromObjFile(BaseRocR* test, hsa_agent_t* agent) { +hsa_status_t LoadKernelFromObjFile(BaseRocR* test) { hsa_status_t err; hsa_code_object_reader_t code_obj_rdr = {0}; hsa_executable_t executable = {0}; assert(test != nullptr); - 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->get_agent_name() - +"/" + test->kernel_file_name(); + hsa_agent_t* agent = test->gpu_device1(); // Assume GPU agent for now + std::string obj_file = "./" + test->kernel_file_name(); std::string kern_name = test->kernel_name(); - hsa_file_t file_handle = open(obj_file.c_str(), O_RDONLY); if (file_handle == -1) { diff --git a/projects/rocr-runtime/rocrtst/common/base_rocr_utils.h b/projects/rocr-runtime/rocrtst/common/base_rocr_utils.h index 55cd7051f5..40c0b50026 100755 --- a/projects/rocr-runtime/rocrtst/common/base_rocr_utils.h +++ b/projects/rocr-runtime/rocrtst/common/base_rocr_utils.h @@ -55,12 +55,11 @@ 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, -/// agent name and kernel function specifed +/// kernel. Assumes that input test already has the kernel file 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_agent_t* agent); +hsa_status_t LoadKernelFromObjFile(BaseRocR* test); /// Do initialization tasks for HSA test program. /// \param[in] test Test to initialize diff --git a/projects/rocr-runtime/rocrtst/common/common.cc b/projects/rocr-runtime/rocrtst/common/common.cc index ea95f02f75..21445ef671 100755 --- a/projects/rocr-runtime/rocrtst/common/common.cc +++ b/projects/rocr-runtime/rocrtst/common/common.cc @@ -83,104 +83,6 @@ 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* cpus = static_cast*>(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* gpus = static_cast*>(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(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(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(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); } diff --git a/projects/rocr-runtime/rocrtst/common/common.h b/projects/rocr-runtime/rocrtst/common/common.h index 475ab2113b..b5cc92a5b2 100755 --- a/projects/rocr-runtime/rocrtst/common/common.h +++ b/projects/rocr-runtime/rocrtst/common/common.h @@ -123,49 +123,6 @@ 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 diff --git a/projects/rocr-runtime/rocrtst/suites/performance/dispatch_time.cc b/projects/rocr-runtime/rocrtst/suites/performance/dispatch_time.cc index 79735e9b34..400c314906 100755 --- a/projects/rocr-runtime/rocrtst/suites/performance/dispatch_time.cc +++ b/projects/rocr-runtime/rocrtst/suites/performance/dispatch_time.cc @@ -136,7 +136,7 @@ void DispatchTime::SetUp() { num_batch_ = num_batch_ > size ? size : num_batch_; } - err = rocrtst::LoadKernelFromObjFile(this, gpu_dev); + err = rocrtst::LoadKernelFromObjFile(this); ASSERT_EQ(err, HSA_STATUS_SUCCESS); // Fill up the kernel packet except header diff --git a/projects/rocr-runtime/rocrtst/suites/test_common/test_case_template.cc b/projects/rocr-runtime/rocrtst/suites/test_common/test_case_template.cc index 51e81ed261..9d002bf4cd 100755 --- a/projects/rocr-runtime/rocrtst/suites/test_common/test_case_template.cc +++ b/projects/rocr-runtime/rocrtst/suites/test_common/test_case_template.cc @@ -197,7 +197,7 @@ void TestExample::SetUp(void) { ASSERT_NE(q, nullptr); set_main_queue(q); - err = rocrtst::LoadKernelFromObjFile(this, gpu_dev); + err = rocrtst::LoadKernelFromObjFile(this); ASSERT_EQ(err, HSA_STATUS_SUCCESS); // Fill up the kernel packet (except header) with some values we've