Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
rocm_bandwidth_test
Commits
80050ad5
Unverified
Commit
80050ad5
authored
Jun 20, 2019
by
Ramesh Errabolu
Committed by
GitHub
Jun 20, 2019
Browse files
Merge pull request #40 from RadeonOpenCompute/xtndBufferInit
Extend buffer initialization choice
parents
c06f3680
84c8d33e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
24 deletions
+61
-24
rocm_bandwidth_test.cpp
rocm_bandwidth_test.cpp
+27
-17
rocm_bandwidth_test.hpp
rocm_bandwidth_test.hpp
+1
-1
rocm_bandwidth_test_parse.cpp
rocm_bandwidth_test_parse.cpp
+32
-5
rocm_bandwidth_test_print.cpp
rocm_bandwidth_test_print.cpp
+1
-1
No files found.
rocm_bandwidth_test.cpp
View file @
80050ad5
...
...
@@ -48,6 +48,7 @@
#include <algorithm>
#include <unistd.h>
#include <cctype>
#include <cmath>
#include <sstream>
#include <limits>
...
...
@@ -105,7 +106,11 @@ void RocmBandwidthTest::InitializeSrcBuffer(size_t size, void* buf_cpy,
if
(
init_src_
==
NULL
)
{
err_
=
hsa_amd_memory_pool_allocate
(
sys_pool_
,
size
,
0
,
(
void
**
)
&
init_src_
);
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_
);
ErrorCheck
(
err_
);
}
...
...
@@ -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
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_
;
if
(
cpy_dev_type
==
HSA_DEVICE_TYPE_GPU
)
{
AcquireAccess
(
cpy_agent
,
validate_dst_
);
...
...
@@ -216,6 +221,9 @@ void RocmBandwidthTest::AllocateConcurrentCopyResources(bool bidir,
dev_list
.
push_back
(
dst_dev
);
dev_idx_list
.
push_back
(
src_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
// and signal for reverse direction as well
...
...
@@ -237,6 +245,9 @@ void RocmBandwidthTest::AllocateConcurrentCopyResources(bool bidir,
dev_list
.
push_back
(
src_dev
);
dev_idx_list
.
push_back
(
dst_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,14 +537,11 @@ void RocmBandwidthTest::RunCopyBenchmark(async_trans_t& trans) {
}
// Initialize source buffers with data that could be verified
if
((
init_
)
||
(
validate_
))
{
InitializeSrcBuffer
(
max_size
,
buf_src_fwd
,
src_dev_idx_fwd
,
src_agent_fwd
);
if
(
bidir
)
{
InitializeSrcBuffer
(
max_size
,
buf_src_rev
,
src_dev_idx_rev
,
src_agent_rev
);
}
InitializeSrcBuffer
(
max_size
,
buf_src_fwd
,
src_dev_idx_fwd
,
src_agent_fwd
);
if
(
bidir
)
{
InitializeSrcBuffer
(
max_size
,
buf_src_rev
,
src_dev_idx_rev
,
src_agent_rev
);
}
// Setup access to destination buffers for
...
...
@@ -760,15 +768,15 @@ RocmBandwidthTest::RocmBandwidthTest(int argc, char** argv) : BaseTest() {
validate_
=
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
init_val_
=
0x23
;
init_val_
=
11.231926
;
init_src_
=
NULL
;
validate_dst_
=
NULL
;
// Initialize version of the test
version_
.
major_id
=
2
;
version_
.
minor_id
=
2
;
version_
.
minor_id
=
3
;
version_
.
step_id
=
0
;
version_
.
reserved
=
0
;
...
...
@@ -794,12 +802,14 @@ RocmBandwidthTest::~RocmBandwidthTest() {
delete
link_type_matrix_
;
delete
link_weight_matrix_
;
delete
active_agents_list_
;
if
(
init_
)
{
if
(
init_src_
!=
NULL
)
{
hsa_signal_destroy
(
init_signal_
);
hsa_amd_memory_pool_free
(
init_src_
);
if
(
validate_
)
{
hsa_amd_memory_pool_free
(
validate_dst_
);
}
}
if
(
validate_
)
{
hsa_amd_memory_pool_free
(
validate_dst_
);
}
}
...
...
rocm_bandwidth_test.hpp
View file @
80050ad5
...
...
@@ -517,7 +517,7 @@ class RocmBandwidthTest : public BaseTest {
// Determines if user has requested validation
bool
validate_
;
uint8_t
init_val_
;
long
double
init_val_
;
// Handles to buffer used to initialize and validate
void
*
init_src_
;
...
...
rocm_bandwidth_test_parse.cpp
View file @
80050ad5
...
...
@@ -46,15 +46,41 @@
#include <assert.h>
#include <algorithm>
#include <sstream>
#include <iomanip>
#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
// value as in example: -i
0x33
static
bool
ParseInitValue
(
char
*
value_str
,
uint8_t
&
value
)
{
// value as in example: -i
11.231926
static
bool
ParseInitValue
(
char
*
value_str
,
long
double
&
value
)
{
// Capture the option value string
uint32_t
value_read
=
strto
u
l
(
value_str
,
NULL
,
0
);
return
((
value
=
value_read
)
&&
(
value_read
>
255
))
?
false
:
true
;
value
=
strtol
d
(
value_str
,
NULL
);
return
true
;
}
// Parse option value string. The string has one more decimal
...
...
@@ -456,7 +482,8 @@ void RocmBandwidthTest::ParseArguments() {
case
'?'
:
std
::
cout
<<
"Argument is illegal or needs value: "
<<
'?'
<<
std
::
endl
;
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
;
}
print_help
=
true
;
...
...
rocm_bandwidth_test_print.cpp
View file @
80050ad5
...
...
@@ -59,7 +59,7 @@ void RocmBandwidthTest::PrintHelpScreen() {
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
-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
-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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment