Merge commit '0dde3ce5898815296008b8461a5396a5c3c25a07' into develop

Tá an tiomantas seo le fáil i:
systems-assistant[bot]
2025-08-12 00:25:16 +00:00
tuismitheoir 2dc8e2f2d4 0dde3ce589
tiomantas d5d702a0cd
D'athraigh 4 comhad le 50 breiseanna agus 53 scriosta
@@ -44,6 +44,26 @@ THE SOFTWARE.
#define HIP_PRINT_STATUS(status) INFO(hipGetErrorName(status) << " at line: " << __LINE__);
#define CHAR_BUF_SIZE 512
#define CONSOLE_PRINT(fmt, ...) \
do { \
std::printf(fmt "\n", ##__VA_ARGS__); \
} while (0)
// DEBUG_PRINT: If ENABLE_DEBUG is defined, prints immediately to console.
// Otherwise, uses Catch2 INFO() - debug messages will only appear if the test fails.
#if defined(ENABLE_DEBUG)
#define DEBUG_PRINT(fmt, ...) CONSOLE_PRINT("[DEBUG]: " fmt, ##__VA_ARGS__)
#else
#define DEBUG_PRINT(fmt, ...) \
do { \
char buf[CHAR_BUF_SIZE]; \
std::snprintf(buf, CHAR_BUF_SIZE, "[INFO]: " fmt, ##__VA_ARGS__); \
INFO(buf); \
} while (0)
#endif
// Not thread-safe
#define HIP_CHECK(error) \
{ \
@@ -23,18 +23,12 @@
* @ingroup perfDispatchTest
*/
// #define ENABLE_DEBUG 1
#include <hip_test_common.hh>
#include <string.h>
#include <complex>
// Quiet pesky warnings
#ifdef WIN_OS
#define SNPRINTF sprintf_s
#else
#define SNPRINTF snprintf
#endif
#define CHAR_BUF_SIZE 512
typedef struct {
unsigned int iterations;
int flushEvery;
@@ -96,6 +90,8 @@ TEST_CASE("Perf_hipPerfDispatchSpeed") {
int numTests = (p_tests == -1) ? (2*2*testListSize - 1) : p_tests;
int test = (p_tests == -1) ? 0 : p_tests;
DEBUG_PRINT("numTests %d", numTests);
float* srcBuffer = NULL;
unsigned int bufSize_ = 64*sizeof(float);
err = hipMalloc(&srcBuffer, bufSize_);
@@ -159,17 +155,14 @@ TEST_CASE("Perf_hipPerfDispatchSpeed") {
n = "n";
extraChar = " ";
}
char buf[256];
if (testList[openTest].flushEvery > 0) {
SNPRINTF(buf, sizeof(buf), "HIPPerfDispatchSpeed[%3d] %7d dispatches %s%sing every %5d (us/disp) %3f",
test, testList[openTest].iterations,
waitType, n, testList[openTest].flushEvery, (float)perf);
CONSOLE_PRINT("HIPPerfDispatchSpeed[%3d] %7d dispatches %s%sing every %5d (us/disp) %3f",
test, testList[openTest].iterations, waitType, n, testList[openTest].flushEvery,
(float)perf);
} else {
SNPRINTF(buf, sizeof(buf), "HIPPerfDispatchSpeed[%3d] %7d dispatches (%s%s) (us/disp) %3f",
test, testList[openTest].iterations,
waitType, extraChar, (float)perf);
CONSOLE_PRINT("HIPPerfDispatchSpeed[%3d] %7d dispatches (%s%s) (us/disp) %3f",
test, testList[openTest].iterations, waitType, extraChar, (float)perf);
}
printf("%s\n", buf);
}
HIP_CHECK(hipFree(srcBuffer));
}
@@ -17,12 +17,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
// Quiet pesky warnings
#ifdef WIN_OS
#define SNPRINTF sprintf_s
#else
#define SNPRINTF snprintf
#endif
#define NUM_SIZES 6
// 256 Bytes, 512 Bytes, 1024 Bytes, 2048 Bytes, 3072 Bytes, 4096 Bytes
@@ -38,9 +32,9 @@ void checkData(void* ptr, unsigned int size, char value) {
char* ptr2 = (char*)ptr;
for (unsigned int i = 0; i < size; i++) {
if (ptr2[i] != value) {
printf("Data validation failed at %d! Got 0x%08x\n", i, ptr2[i]);
printf("Expected 0x%08x\n", value);
printf("Data validation failed!");
CONSOLE_PRINT("Data validation failed at %d! Got 0x%08x\n", i, ptr2[i]);
CONSOLE_PRINT("Expected 0x%08x\n", value);
CONSOLE_PRINT("Data validation failed!");
break;
}
}
@@ -50,7 +44,7 @@ bool extraWarmup = true;
TEST_CASE("Perf_hipPerfMemcpyAsyncSpeed_test") {
hipDeviceProp_t props;
HIP_CHECK(hipGetDeviceProperties(&props, 0));
printf("Set device to %d : %s\n", 0, props.name);
CONSOLE_PRINT("Set device to %d : %s\n", 0, props.name);
HIP_CHECK(hipSetDevice(0));
unsigned int bufSize_;
@@ -66,9 +60,9 @@ TEST_CASE("Perf_hipPerfMemcpyAsyncSpeed_test") {
int test = 0;
uint32_t kMaxSize = (t == 0) ? 128 * 1024 * 1024 : 1024 * 1024 * 1024;
if (t < 2) {
printf("----- Global buffer (MiB): %d\n", kMaxSize / (1024 * 1024));
CONSOLE_PRINT("\n----- Global buffer (MiB): %d", kMaxSize / (1024 * 1024));
} else {
printf("----- Same buffer copy repeat\n");
CONSOLE_PRINT("\n----- Same buffer copy repeat");
}
for (; test <= numTests; test++) {
bufSize_ = Sizes[test % NUM_SIZES];
@@ -131,12 +125,11 @@ TEST_CASE("Perf_hipPerfMemcpyAsyncSpeed_test") {
// Double results when src and dst are both on device
perf *= 2.0;
char buf[256];
SNPRINTF(buf, sizeof(buf),
"hipMemcpyAsync[%d]\t(%8d bytes)\ts:%s d:%s\ti:%4d\t(GB/s) "
"perf\t%.2f, time per iter(us):\t%.1f, time per iter CPU (us):\t%.1f",
test, bufSize_, strSrc, strDst, numIter, (float)perf,
sec.count() / numIter * 1000 * 1000, sec_cpu.count() / numIter * 1000 * 1000);
printf("%s\n", buf);
CONSOLE_PRINT(
"hipMemcpyAsync[%d]\t(%8d bytes)\ts:%s d:%s\ti:%4d\t(GB/s) "
"perf\t%.2f, time per iter(us):\t%.1f, time per iter CPU (us):\t%.1f",
test, bufSize_, strSrc, strDst, numIter, (float)perf, sec.count() / numIter * 1000 * 1000,
sec_cpu.count() / numIter * 1000 * 1000);
// Verification
void* temp = malloc(bufSize_ + 4096);
@@ -18,13 +18,6 @@ THE SOFTWARE.
*/
#include <hip_test_common.hh>
// Quiet pesky warnings
#ifdef WIN_OS
#define SNPRINTF sprintf_s
#else
#define SNPRINTF snprintf
#endif
#define NUM_SIZES 6
// 256 Bytes, 512 Bytes, 1024 Bytes, 2048 Bytes, 3072 Bytes, 4096 Bytes
constexpr uint32_t Mi = 1024 * 1024;
@@ -39,9 +32,9 @@ void checkData_(void* ptr, unsigned int size, char value) {
char* ptr2 = (char*)ptr;
for (unsigned int i = 0; i < size; i++) {
if (ptr2[i] != value) {
printf("Data validation failed at %d! Got 0x%08x\n", i, ptr2[i]);
printf("Expected 0x%08x\n", value);
printf("Data validation failed!");
CONSOLE_PRINT("Data validation failed at %d! Got 0x%08x\n", i, ptr2[i]);
CONSOLE_PRINT("Expected 0x%08x\n", value);
CONSOLE_PRINT("Data validation failed!");
break;
}
}
@@ -51,7 +44,7 @@ bool extraWarmup_ = true;
TEST_CASE("Perf_hipPerfMemsetAsyncSpeed_test") {
hipDeviceProp_t props;
HIP_CHECK(hipGetDeviceProperties(&props, 0));
printf("Set device to %d : %s\n", 0, props.name);
CONSOLE_PRINT("Set device to %d : %s", 0, props.name);
HIP_CHECK(hipSetDevice(0));
unsigned int bufSize_;
@@ -66,7 +59,7 @@ TEST_CASE("Perf_hipPerfMemsetAsyncSpeed_test") {
int numTests = (NUM_SIZES * NUM_SUBTESTS - 1);
int test = 0;
uint32_t kMaxSize = (t == 0) ? 128 * 1024 * 1024 : 1024 * 1024 * 1024;
printf("----- Global buffer (MiB): %d\n", kMaxSize / (1024 * 1024));
CONSOLE_PRINT("\n----- Global buffer (MiB): %d", kMaxSize / (1024 * 1024));
for (; test <= numTests; test++) {
bufSize_ = Sizes[test % NUM_SIZES];
hostMalloc[0] = hostMalloc[1] = false;
@@ -123,13 +116,11 @@ TEST_CASE("Perf_hipPerfMemsetAsyncSpeed_test") {
const char* strSrc = "dM";
const char* strDst = "dM";
char buf[256];
SNPRINTF(buf, sizeof(buf),
"hipMemsetAsync[%d]\t(%8d bytes)\ts:%s d:%s\ti:%4d\t(GB/s) "
"perf\t%.2f, time per iter(us):\t%.1f, time per iter CPU (us):\t%.1f",
test, bufSize_, strSrc, strDst, numIter, (float)perf,
sec.count() / numIter * 1000 * 1000, sec_cpu.count() / numIter * 1000 * 1000);
printf("%s\n", buf);
CONSOLE_PRINT(
"hipMemsetAsync[%d]\t(%8d bytes)\ts:%s d:%s\ti:%4d\t(GB/s) "
"perf\t%.2f, time per iter(us):\t%.1f, time per iter CPU (us):\t%.1f",
test, bufSize_, strSrc, strDst, numIter, (float)perf, sec.count() / numIter * 1000 * 1000,
sec_cpu.count() / numIter * 1000 * 1000);
// Verification
void* temp = malloc(bufSize_ + 4096);