Commit 84c8d33e authored by Ramesh Errabolu's avatar Ramesh Errabolu
Browse files

Extend buffer initialization choice

parent c06f3680
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <algorithm> #include <algorithm>
#include <unistd.h> #include <unistd.h>
#include <cctype> #include <cctype>
#include <cmath>
#include <sstream> #include <sstream>
#include <limits> #include <limits>
...@@ -105,7 +106,11 @@ void RocmBandwidthTest::InitializeSrcBuffer(size_t size, void* buf_cpy, ...@@ -105,7 +106,11 @@ void RocmBandwidthTest::InitializeSrcBuffer(size_t size, void* buf_cpy,
if (init_src_ == NULL) { if (init_src_ == NULL) {
err_ = hsa_amd_memory_pool_allocate(sys_pool_, size, 0, (void**)&init_src_); err_ = hsa_amd_memory_pool_allocate(sys_pool_, size, 0, (void**)&init_src_);
ErrorCheck(err_); ErrorCheck(err_);
memset(init_src_, init_val_, size); long double* src_buf = (long double*) init_src_;
uint32_t count = (size / sizeof(long double));
for (uint32_t idx = 0; idx < count; idx++) {
src_buf[idx] = (init_) ? init_val_ : sin(idx);
}
err_ = hsa_signal_create(0, 0, NULL, &init_signal_); err_ = hsa_signal_create(0, 0, NULL, &init_signal_);
ErrorCheck(err_); ErrorCheck(err_);
} }
...@@ -136,7 +141,7 @@ bool RocmBandwidthTest::ValidateDstBuffer(size_t max_size, size_t curr_size, voi ...@@ -136,7 +141,7 @@ bool RocmBandwidthTest::ValidateDstBuffer(size_t max_size, size_t curr_size, voi
} }
// If Copy device is a Gpu setup buffer access // If Copy device is a Gpu setup buffer access
memset(validate_dst_, ~init_val_, curr_size); memset(validate_dst_, ~(0x23), curr_size);
hsa_device_type_t cpy_dev_type = agent_list_[cpy_dev_idx].device_type_; hsa_device_type_t cpy_dev_type = agent_list_[cpy_dev_idx].device_type_;
if (cpy_dev_type == HSA_DEVICE_TYPE_GPU) { if (cpy_dev_type == HSA_DEVICE_TYPE_GPU) {
AcquireAccess(cpy_agent, validate_dst_); AcquireAccess(cpy_agent, validate_dst_);
...@@ -217,6 +222,9 @@ void RocmBandwidthTest::AllocateConcurrentCopyResources(bool bidir, ...@@ -217,6 +222,9 @@ void RocmBandwidthTest::AllocateConcurrentCopyResources(bool bidir,
dev_idx_list.push_back(src_dev_idx); dev_idx_list.push_back(src_dev_idx);
dev_idx_list.push_back(dst_dev_idx); dev_idx_list.push_back(dst_dev_idx);
// Initialize source buffers with data that could be verified
InitializeSrcBuffer(max_size, buf_src, src_dev_idx, src_dev);
// For bidirectional copies allocate buffers // For bidirectional copies allocate buffers
// and signal for reverse direction as well // and signal for reverse direction as well
if (bidir) { if (bidir) {
...@@ -237,6 +245,9 @@ void RocmBandwidthTest::AllocateConcurrentCopyResources(bool bidir, ...@@ -237,6 +245,9 @@ void RocmBandwidthTest::AllocateConcurrentCopyResources(bool bidir,
dev_list.push_back(src_dev); dev_list.push_back(src_dev);
dev_idx_list.push_back(dst_dev_idx); dev_idx_list.push_back(dst_dev_idx);
dev_idx_list.push_back(src_dev_idx); dev_idx_list.push_back(src_dev_idx);
// Initialize source buffers with data that could be verified
InitializeSrcBuffer(max_size, buf_src, dst_dev_idx, dst_dev);
} }
} }
} }
...@@ -526,15 +537,12 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) { ...@@ -526,15 +537,12 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) {
} }
// Initialize source buffers with data that could be verified // Initialize source buffers with data that could be verified
if ((init_) || (validate_)) {
InitializeSrcBuffer(max_size, buf_src_fwd, InitializeSrcBuffer(max_size, buf_src_fwd,
src_dev_idx_fwd, src_agent_fwd); src_dev_idx_fwd, src_agent_fwd);
if (bidir) { if (bidir) {
InitializeSrcBuffer(max_size, buf_src_rev, InitializeSrcBuffer(max_size, buf_src_rev,
src_dev_idx_rev, src_agent_rev); src_dev_idx_rev, src_agent_rev);
} }
}
// Setup access to destination buffers for // Setup access to destination buffers for
// both unidirectional and bidirectional copies // both unidirectional and bidirectional copies
...@@ -760,15 +768,15 @@ RocmBandwidthTest::RocmBandwidthTest(int argc, char** argv) : BaseTest() { ...@@ -760,15 +768,15 @@ RocmBandwidthTest::RocmBandwidthTest(int argc, char** argv) : BaseTest() {
validate_ = false; validate_ = false;
print_cpu_time_ = false; print_cpu_time_ = false;
// Set initial value to 0x23 in case // Set initial value to 11.231926 in case
// user does not have a preference // user does not have a preference
init_val_ = 0x23; init_val_ = 11.231926;
init_src_ = NULL; init_src_ = NULL;
validate_dst_ = NULL; validate_dst_ = NULL;
// Initialize version of the test // Initialize version of the test
version_.major_id = 2; version_.major_id = 2;
version_.minor_id = 2; version_.minor_id = 3;
version_.step_id = 0; version_.step_id = 0;
version_.reserved = 0; version_.reserved = 0;
...@@ -794,13 +802,15 @@ RocmBandwidthTest::~RocmBandwidthTest() { ...@@ -794,13 +802,15 @@ RocmBandwidthTest::~RocmBandwidthTest() {
delete link_type_matrix_; delete link_type_matrix_;
delete link_weight_matrix_; delete link_weight_matrix_;
delete active_agents_list_; delete active_agents_list_;
if (init_) {
if (init_src_ != NULL) {
hsa_signal_destroy(init_signal_); hsa_signal_destroy(init_signal_);
hsa_amd_memory_pool_free(init_src_); hsa_amd_memory_pool_free(init_src_);
}
if (validate_) { if (validate_) {
hsa_amd_memory_pool_free(validate_dst_); hsa_amd_memory_pool_free(validate_dst_);
} }
}
} }
std::string RocmBandwidthTest::GetVersion() const { std::string RocmBandwidthTest::GetVersion() const {
......
...@@ -517,7 +517,7 @@ class RocmBandwidthTest : public BaseTest { ...@@ -517,7 +517,7 @@ class RocmBandwidthTest : public BaseTest {
// Determines if user has requested validation // Determines if user has requested validation
bool validate_; bool validate_;
uint8_t init_val_; long double init_val_;
// Handles to buffer used to initialize and validate // Handles to buffer used to initialize and validate
void* init_src_; void* init_src_;
......
...@@ -46,15 +46,41 @@ ...@@ -46,15 +46,41 @@
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <iomanip>
#include <unistd.h> #include <unistd.h>
//#include <strings.h>
// Parse option value string. The string has to be either
// sin or cos literal
// value as in example: -I sin or -I cos
/*
static bool ParseTrigValue(char* value_str, uint32_t&value) {
// Capture the option value string
std::cout << "Value of Trig: " << value_str << std::endl;
int32_t cmp = strncasecmp("sin", value_str, 3);
if (cmp == 0) {
value = 1;
return true;
}
cmp = strncasecmp("cos", value_str, 3);
if (cmp == 0) {
value = 2;
return true;
}
return false;
}
*/
// Parse option value string. The string has one decimal // Parse option value string. The string has one decimal
// value as in example: -i 0x33 // value as in example: -i 11.231926
static bool ParseInitValue(char* value_str, uint8_t&value) { static bool ParseInitValue(char* value_str, long double&value) {
// Capture the option value string // Capture the option value string
uint32_t value_read = strtoul(value_str, NULL, 0); value = strtold(value_str, NULL);
return ((value = value_read) && (value_read > 255)) ? false : true; return true;
} }
// Parse option value string. The string has one more decimal // Parse option value string. The string has one more decimal
...@@ -456,7 +482,8 @@ void RocmBandwidthTest::ParseArguments() { ...@@ -456,7 +482,8 @@ void RocmBandwidthTest::ParseArguments() {
case '?': case '?':
std::cout << "Argument is illegal or needs value: " << '?' << std::endl; std::cout << "Argument is illegal or needs value: " << '?' << std::endl;
if ((optopt == 'b') || (optopt == 's') || if ((optopt == 'b') || (optopt == 's') ||
(optopt == 'd') || (optopt == 'm') || (optopt == 'i')) { (optopt == 'd') || (optopt == 'm') ||
(optopt == 'i') || (false)) {
std::cout << "Error: Options -b -s -d -m -i -k and -K require argument" << std::endl; std::cout << "Error: Options -b -s -d -m -i -k and -K require argument" << std::endl;
} }
print_help = true; print_help = true;
......
...@@ -59,7 +59,7 @@ void RocmBandwidthTest::PrintHelpScreen() { ...@@ -59,7 +59,7 @@ void RocmBandwidthTest::PrintHelpScreen() {
std::cout << "\t -v Run the test in validation mode" << std::endl; std::cout << "\t -v Run the test in validation mode" << std::endl;
std::cout << "\t -l Run test to collect Latency data" << std::endl; std::cout << "\t -l Run test to collect Latency data" << std::endl;
std::cout << "\t -c Time the operation using CPU Timers" << std::endl; std::cout << "\t -c Time the operation using CPU Timers" << std::endl;
std::cout << "\t -i Initialize copy buffer with specified byte pattern" << std::endl; std::cout << "\t -i Initialize copy buffer with specified 'long double' pattern" << std::endl;
std::cout << "\t -t Prints system topology and allocatable memory info" << std::endl; std::cout << "\t -t Prints system topology and allocatable memory info" << std::endl;
std::cout << "\t -m List of buffer sizes to use, specified in Megabytes" << std::endl; std::cout << "\t -m List of buffer sizes to use, specified in Megabytes" << std::endl;
std::cout << "\t -b List devices to use in bidirectional copy operations" << std::endl; std::cout << "\t -b List devices to use in bidirectional copy operations" << std::endl;
......
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