Unverified Commit a1a217aa authored by Ramesh Errabolu's avatar Ramesh Errabolu Committed by GitHub
Browse files

Merge pull request #28 from RadeonOpenCompute/fixBufferSizeType

Update data type used for buffer size
parents 8de8c1b2 0d790334
...@@ -52,25 +52,25 @@ ...@@ -52,25 +52,25 @@
#include <limits> #include <limits>
// The values are in megabytes at allocation time // The values are in megabytes at allocation time
const uint32_t RocmBandwidthTest::SIZE_LIST[] = { 1 * 1024, const size_t RocmBandwidthTest::SIZE_LIST[] = { 1 * 1024,
2 * 1024, 4 * 1024, 8 * 1024, 2 * 1024, 4 * 1024, 8 * 1024,
16 * 1024, 32 * 1024, 64 * 1024, 16 * 1024, 32 * 1024, 64 * 1024,
128 * 1024, 256 * 1024, 512 * 1024, 128 * 1024, 256 * 1024, 512 * 1024,
1 * 1024 * 1024, 2 * 1024 * 1024, 1 * 1024 * 1024, 2 * 1024 * 1024,
4 * 1024 * 1024, 8 * 1024 * 1024, 4 * 1024 * 1024, 8 * 1024 * 1024,
16 * 1024 * 1024, 32 * 1024 * 1024, 16 * 1024 * 1024, 32 * 1024 * 1024,
64 * 1024 * 1024, 128 * 1024 * 1024, 64 * 1024 * 1024, 128 * 1024 * 1024,
256 * 1024 * 1024, 512 * 1024 * 1024}; 256 * 1024 * 1024, 512 * 1024 * 1024};
const uint32_t RocmBandwidthTest::LATENCY_SIZE_LIST[] = { 1, const size_t RocmBandwidthTest::LATENCY_SIZE_LIST[] = { 1,
2, 4, 8, 2, 4, 8,
16, 32, 64, 16, 32, 64,
128, 256, 512, 128, 256, 512,
1 * 1024, 2 * 1024, 1 * 1024, 2 * 1024,
4 * 1024, 8 * 1024, 4 * 1024, 8 * 1024,
16 * 1024, 32 * 1024, 16 * 1024, 32 * 1024,
64 * 1024, 128 * 1024, 64 * 1024, 128 * 1024,
256 * 1024, 512 * 1024 }; 256 * 1024, 512 * 1024 };
uint32_t RocmBandwidthTest::GetIterationNum() { uint32_t RocmBandwidthTest::GetIterationNum() {
return (validate_) ? 1 : (num_iteration_ * 1.2 + 1); return (validate_) ? 1 : (num_iteration_ * 1.2 + 1);
...@@ -97,7 +97,7 @@ void RocmBandwidthTest::AcquirePoolAcceses(uint32_t src_dev_idx, ...@@ -97,7 +97,7 @@ void RocmBandwidthTest::AcquirePoolAcceses(uint32_t src_dev_idx,
return; return;
} }
void RocmBandwidthTest::AllocateHostBuffers(uint32_t size, void RocmBandwidthTest::AllocateHostBuffers(size_t size,
uint32_t src_dev_idx, uint32_t src_dev_idx,
uint32_t dst_dev_idx, uint32_t dst_dev_idx,
void*& src, void*& dst, void*& src, void*& dst,
...@@ -132,7 +132,7 @@ void RocmBandwidthTest::AllocateHostBuffers(uint32_t size, ...@@ -132,7 +132,7 @@ void RocmBandwidthTest::AllocateHostBuffers(uint32_t size,
return; return;
} }
void RocmBandwidthTest::AllocateCopyBuffers(uint32_t size, void RocmBandwidthTest::AllocateCopyBuffers(size_t size,
uint32_t src_dev_idx, uint32_t dst_dev_idx, uint32_t src_dev_idx, uint32_t dst_dev_idx,
void*& src, hsa_amd_memory_pool_t src_pool, void*& src, hsa_amd_memory_pool_t src_pool,
void*& dst, hsa_amd_memory_pool_t dst_pool, void*& dst, hsa_amd_memory_pool_t dst_pool,
...@@ -222,8 +222,8 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) { ...@@ -222,8 +222,8 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) {
bool bidir = trans.copy.bidir_; bool bidir = trans.copy.bidir_;
// Initialize size of buffer to equal the largest element of allocation // Initialize size of buffer to equal the largest element of allocation
size_t max_size = size_list_.back();
uint32_t size_len = size_list_.size(); uint32_t size_len = size_list_.size();
uint32_t max_size = size_list_.back();
// Bind to resources such as pool and agents that are involved // Bind to resources such as pool and agents that are involved
// in both forward and reverse copy operations // in both forward and reverse copy operations
...@@ -299,7 +299,7 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) { ...@@ -299,7 +299,7 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) {
for (uint32_t idx = 0; idx < size_len; idx++) { for (uint32_t idx = 0; idx < size_len; idx++) {
// This should not be happening // This should not be happening
uint32_t curr_size = size_list_[idx]; size_t curr_size = size_list_[idx];
if (curr_size > max_size) { if (curr_size > max_size) {
break; break;
} }
......
...@@ -268,16 +268,16 @@ class RocmBandwidthTest : public BaseTest { ...@@ -268,16 +268,16 @@ class RocmBandwidthTest : public BaseTest {
bool ValidateArguments(); bool ValidateArguments();
bool ValidateReadReq(); bool ValidateReadReq();
bool ValidateWriteReq(); bool ValidateWriteReq();
bool ValidateReadOrWriteReq(vector<uint32_t>& in_list); bool ValidateReadOrWriteReq(vector<size_t>& in_list);
bool ValidateBidirCopyReq(); bool ValidateBidirCopyReq();
bool ValidateUnidirCopyReq(); bool ValidateUnidirCopyReq();
bool ValidateCopyReq(vector<uint32_t>& in_list); bool ValidateCopyReq(vector<size_t>& in_list);
void PrintIOAccessError(uint32_t agent_idx, uint32_t pool_idx); void PrintIOAccessError(uint32_t agent_idx, uint32_t pool_idx);
void PrintCopyAccessError(uint32_t src_pool_idx, uint32_t dst_pool_idx); void PrintCopyAccessError(uint32_t src_pool_idx, uint32_t dst_pool_idx);
bool PoolIsPresent(vector<uint32_t>& in_list); bool PoolIsPresent(vector<size_t>& in_list);
bool PoolIsDuplicated(vector<uint32_t>& in_list); bool PoolIsDuplicated(vector<size_t>& in_list);
// @brief: Builds a list of transaction per user request // @brief: Builds a list of transaction per user request
void ComputeCopyTime(async_trans_t& trans); void ComputeCopyTime(async_trans_t& trans);
...@@ -289,12 +289,12 @@ class RocmBandwidthTest : public BaseTest { ...@@ -289,12 +289,12 @@ class RocmBandwidthTest : public BaseTest {
bool BuildAllPoolsBidirCopyTrans(); bool BuildAllPoolsBidirCopyTrans();
bool BuildAllPoolsUnidirCopyTrans(); bool BuildAllPoolsUnidirCopyTrans();
bool BuildReadOrWriteTrans(uint32_t req_type, bool BuildReadOrWriteTrans(uint32_t req_type,
vector<uint32_t>& in_list); vector<size_t>& in_list);
bool BuildCopyTrans(uint32_t req_type, bool BuildCopyTrans(uint32_t req_type,
vector<uint32_t>& src_list, vector<size_t>& src_list,
vector<uint32_t>& dst_list); vector<size_t>& dst_list);
void AllocateCopyBuffers(uint32_t size, void AllocateCopyBuffers(size_t size,
uint32_t src_dev_idx, uint32_t dst_dev_idx, uint32_t src_dev_idx, uint32_t dst_dev_idx,
void*& src, hsa_amd_memory_pool_t src_pool, void*& src, hsa_amd_memory_pool_t src_pool,
void*& dst, hsa_amd_memory_pool_t dst_pool, void*& dst, hsa_amd_memory_pool_t dst_pool,
...@@ -305,7 +305,7 @@ class RocmBandwidthTest : public BaseTest { ...@@ -305,7 +305,7 @@ class RocmBandwidthTest : public BaseTest {
void* dst_fwd, void* dst_rev, void* dst_fwd, void* dst_rev,
hsa_signal_t signal_fwd, hsa_signal_t signal_rev); hsa_signal_t signal_fwd, hsa_signal_t signal_rev);
double GetGpuCopyTime(bool bidir, hsa_signal_t signal_fwd, hsa_signal_t signal_rev); double GetGpuCopyTime(bool bidir, hsa_signal_t signal_fwd, hsa_signal_t signal_rev);
void AllocateHostBuffers(uint32_t size, void AllocateHostBuffers(size_t size,
uint32_t src_dev_idx, uint32_t src_dev_idx,
uint32_t dst_dev_idx, uint32_t dst_dev_idx,
void*& src, void*& dst, void*& src, void*& dst,
...@@ -352,6 +352,7 @@ class RocmBandwidthTest : public BaseTest { ...@@ -352,6 +352,7 @@ class RocmBandwidthTest : public BaseTest {
// Used to pack space for structure alignment // Used to pack space for structure alignment
uint32_t reserved; uint32_t reserved;
}; };
RocmBandwidthVersion version_; RocmBandwidthVersion version_;
void PrintVersion() const; void PrintVersion() const;
std::string GetVersion() const; std::string GetVersion() const;
...@@ -377,31 +378,31 @@ class RocmBandwidthTest : public BaseTest { ...@@ -377,31 +378,31 @@ class RocmBandwidthTest : public BaseTest {
// List of agents involved in a bidrectional copy operation // List of agents involved in a bidrectional copy operation
// Size of the list cannot exceed the number of agents // Size of the list cannot exceed the number of agents
// reported by the system // reported by the system
vector<uint32_t> bidir_list_; vector<size_t> bidir_list_;
// List of source agents in a unidrectional copy operation // List of source agents in a unidrectional copy operation
// Size of the list cannot exceed the number of agents // Size of the list cannot exceed the number of agents
// reported by the system // reported by the system
vector<uint32_t> src_list_; vector<size_t> src_list_;
// List of destination agents in a unidrectional copy operation // List of destination agents in a unidrectional copy operation
// Size of the list cannot exceed the number of agents // Size of the list cannot exceed the number of agents
// reported by the system // reported by the system
vector<uint32_t> dst_list_; vector<size_t> dst_list_;
// List of agents involved in read operation. Has // List of agents involved in read operation. Has
// two agents, the first agent hosts the memory pool // two agents, the first agent hosts the memory pool
// while the second agent executes the read operation // while the second agent executes the read operation
vector<uint32_t> read_list_; vector<size_t> read_list_;
// List of agents involved in write operation. Has // List of agents involved in write operation. Has
// two agents, the first agent hosts the memory pool // two agents, the first agent hosts the memory pool
// while the second agent executes the write operation // while the second agent executes the write operation
vector<uint32_t> write_list_; vector<size_t> write_list_;
// List of sizes to use in copy and read/write transactions // List of sizes to use in copy and read/write transactions
// Size is specified in terms of Megabytes // Size is specified in terms of Megabytes
vector<uint32_t> size_list_; vector<size_t> size_list_;
// Type of service requested by user // Type of service requested by user
uint32_t req_read_; uint32_t req_read_;
...@@ -469,8 +470,8 @@ class RocmBandwidthTest : public BaseTest { ...@@ -469,8 +470,8 @@ class RocmBandwidthTest : public BaseTest {
// System region // System region
hsa_amd_memory_pool_t sys_pool_; hsa_amd_memory_pool_t sys_pool_;
static const uint32_t SIZE_LIST[20]; static const size_t SIZE_LIST[20];
static const uint32_t LATENCY_SIZE_LIST[20]; static const size_t LATENCY_SIZE_LIST[20];
// Exit value to return in case of error // Exit value to return in case of error
int32_t exit_value_; int32_t exit_value_;
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
// Parse option value string. The string has one more decimal // Parse option value string. The string has one more decimal
// values separated by comma - "3,6,9,12,15". // values separated by comma - "3,6,9,12,15".
static bool ParseOptionValue(char* value, vector<uint32_t>&value_list) { static bool ParseOptionValue(char* value, vector<size_t>&value_list) {
// Capture the option value string // Capture the option value string
std::stringstream stream; std::stringstream stream;
...@@ -60,6 +60,9 @@ static bool ParseOptionValue(char* value, vector<uint32_t>&value_list) { ...@@ -60,6 +60,9 @@ static bool ParseOptionValue(char* value, vector<uint32_t>&value_list) {
// Read the option value // Read the option value
stream >> token; stream >> token;
if (stream.fail()) {
exit(-1);
}
// Update output list with values // Update output list with values
value_list.push_back(token); value_list.push_back(token);
......
...@@ -169,9 +169,12 @@ void RocmBandwidthTest::PrintAccessMatrix() const { ...@@ -169,9 +169,12 @@ void RocmBandwidthTest::PrintAccessMatrix() const {
for (uint32_t dst_idx = 0; dst_idx < agent_index_; dst_idx++) { for (uint32_t dst_idx = 0; dst_idx < agent_index_; dst_idx++) {
uint32_t path_exists = access_matrix_[(src_idx * agent_index_) + dst_idx]; uint32_t path_exists = access_matrix_[(src_idx * agent_index_) + dst_idx];
std::cout.width(format); std::cout.width(format);
/* Remove this block - as it is not always correct
* i.e. access path can be asymmetric
if (path_exists == 2) { if (path_exists == 2) {
path_exists = 1; path_exists = 1;
} }
*/
std::cout << path_exists; std::cout << path_exists;
} }
std::cout << std::endl; std::cout << std::endl;
...@@ -309,8 +312,6 @@ void RocmBandwidthTest::PrintCopyAccessError(uint32_t src_idx, uint32_t dst_idx) ...@@ -309,8 +312,6 @@ void RocmBandwidthTest::PrintCopyAccessError(uint32_t src_idx, uint32_t dst_idx)
hsa_device_type_t dst_dev_type = agent_list_[dst_dev_idx].device_type_; hsa_device_type_t dst_dev_type = agent_list_[dst_dev_idx].device_type_;
std::cout << std::endl; std::cout << std::endl;
//std::cout << "Index of Src Memory: " << src_idx << std::endl;
//std::cout << "Index of Dst Memory: " << dst_idx << std::endl;
std::cout << "Src Device: Index " std::cout << "Src Device: Index "
<< src_dev_idx << src_dev_idx
<< ", Type: " << ", Type: "
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
static void printRecord(uint32_t size, double avg_time, static void printRecord(size_t size, double avg_time,
double avg_bandwidth, double min_time, double avg_bandwidth, double min_time,
double peak_bandwidth) { double peak_bandwidth) {
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "rocm_bandwidth_test.hpp" #include "rocm_bandwidth_test.hpp"
bool RocmBandwidthTest::BuildReadOrWriteTrans(uint32_t req_type, bool RocmBandwidthTest::BuildReadOrWriteTrans(uint32_t req_type,
vector<uint32_t>& in_list) { vector<size_t>& in_list) {
// Validate the list of pool-agent tuples // Validate the list of pool-agent tuples
hsa_status_t status; hsa_status_t status;
...@@ -118,8 +118,8 @@ bool RocmBandwidthTest::FilterCpuPool(uint32_t req_type, ...@@ -118,8 +118,8 @@ bool RocmBandwidthTest::FilterCpuPool(uint32_t req_type,
} }
bool RocmBandwidthTest::BuildCopyTrans(uint32_t req_type, bool RocmBandwidthTest::BuildCopyTrans(uint32_t req_type,
vector<uint32_t>& src_list, vector<size_t>& src_list,
vector<uint32_t>& dst_list) { vector<size_t>& dst_list) {
// bool filter_out; // bool filter_out;
uint32_t src_size = src_list.size(); uint32_t src_size = src_list.size();
...@@ -281,7 +281,7 @@ void RocmBandwidthTest::ComputeCopyTime(async_trans_t& trans) { ...@@ -281,7 +281,7 @@ void RocmBandwidthTest::ComputeCopyTime(async_trans_t& trans) {
double avg_time = 0; double avg_time = 0;
double min_time = 0; double min_time = 0;
uint32_t data_size = 0; size_t data_size = 0;
double avg_bandwidth = 0; double avg_bandwidth = 0;
double peak_bandwidth = 0; double peak_bandwidth = 0;
uint32_t size_len = size_list_.size(); uint32_t size_len = size_list_.size();
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <cctype> #include <cctype>
#include <sstream> #include <sstream>
bool RocmBandwidthTest::PoolIsPresent(vector<uint32_t>& in_list) { bool RocmBandwidthTest::PoolIsPresent(vector<size_t>& in_list) {
bool is_present; bool is_present;
uint32_t idx1 = 0; uint32_t idx1 = 0;
...@@ -72,7 +72,7 @@ bool RocmBandwidthTest::PoolIsPresent(vector<uint32_t>& in_list) { ...@@ -72,7 +72,7 @@ bool RocmBandwidthTest::PoolIsPresent(vector<uint32_t>& in_list) {
return true; return true;
} }
bool RocmBandwidthTest::PoolIsDuplicated(vector<uint32_t>& in_list) { bool RocmBandwidthTest::PoolIsDuplicated(vector<size_t>& in_list) {
uint32_t idx1 = 0; uint32_t idx1 = 0;
uint32_t idx2 = 0; uint32_t idx2 = 0;
...@@ -87,7 +87,7 @@ bool RocmBandwidthTest::PoolIsDuplicated(vector<uint32_t>& in_list) { ...@@ -87,7 +87,7 @@ bool RocmBandwidthTest::PoolIsDuplicated(vector<uint32_t>& in_list) {
return true; return true;
} }
bool RocmBandwidthTest::ValidateReadOrWriteReq(vector<uint32_t>& in_list) { bool RocmBandwidthTest::ValidateReadOrWriteReq(vector<size_t>& in_list) {
// Determine read / write request is even // Determine read / write request is even
// Request is specified as a list of memory // Request is specified as a list of memory
...@@ -120,7 +120,7 @@ bool RocmBandwidthTest::ValidateWriteReq() { ...@@ -120,7 +120,7 @@ bool RocmBandwidthTest::ValidateWriteReq() {
return ValidateReadOrWriteReq(write_list_); return ValidateReadOrWriteReq(write_list_);
} }
bool RocmBandwidthTest::ValidateCopyReq(vector<uint32_t>& in_list) { bool RocmBandwidthTest::ValidateCopyReq(vector<size_t>& in_list) {
// Determine pool list length is valid // Determine pool list length is valid
uint32_t count = in_list.size(); uint32_t count = in_list.size();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment