From b12b740fdc0b2a41b6db1f4db34e386c39c428ea Mon Sep 17 00:00:00 2001 From: Hans Pabst Date: Wed, 11 Sep 2024 09:24:47 +0200 Subject: [PATCH] ocl: updated tuned parameters (#842) * ocl: updated tuned parameters * tune_multiply.py - Make certain resources unique on a per-rank basis. - Only save JSON-file in case of tangible result. - Create DB-directory without prior removal - Reset label when input stems from file. - Avoid caching kernels. * Code cleanup - Disabled ACC_OPENCL_PROFILE (c_dbcsr_acc_set_active_device), as it is potentially too early to use the timer facility. - NULL-device refers to device 0 (c_dbcsr_acc_opencl_device_name). - Print separate error message (acc_bench_smm). - Improved OPENCL_LIBSMM_VALIDATE. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/acc/acc_bench_smm.c | 5 +- src/acc/opencl/acc_opencl.c | 7 +- src/acc/opencl/smm/opencl_libsmm.c | 122 +++++++----------- .../opencl/smm/params/tune_multiply_PVC.csv | 26 +++- src/acc/opencl/smm/tune_multiply.py | 47 +++---- 5 files changed, 105 insertions(+), 102 deletions(-) diff --git a/src/acc/acc_bench_smm.c b/src/acc/acc_bench_smm.c index 79bf0625f03..61bfba29927 100644 --- a/src/acc/acc_bench_smm.c +++ b/src/acc/acc_bench_smm.c @@ -280,7 +280,7 @@ int main(int argc, char* argv[]) { #if defined(USE_LIBXSMM) libxsmm_timer_tickint start; int print_offset = 0; - char print_buffer[1024]; + char print_buffer[1024] = ""; # if defined(__OPENCL) const char* const env_smm_repeat = getenv("SMM_NREPEAT"); const int smm_nrepeat = (NULL == env_smm_repeat ? 1 : MAX(atoi(env_smm_repeat), 1)); @@ -497,7 +497,7 @@ int main(int argc, char* argv[]) { if (maxdiff < epsilon && NULL != file) maxdiff = epsilon; if (0 < epsilon) { if (LIBXSMM_NOTNAN(diff.v_tst)) { - PRINTF(" (|%g-%g|=%g)\n", diff.v_ref, diff.v_tst, fabs(diff.v_ref - diff.v_tst)); + PRINTF(" (|%g-%g|=%g)\n", diff.v_ref, diff.v_tst, diff.linf_abs); } else { PRINTF(" (%g)\n", diff.v_tst); @@ -508,6 +508,7 @@ int main(int argc, char* argv[]) { } if (0 < check && check < epsilon) result = EXIT_FAILURE; } + else fprintf(stderr, "ERROR: failed to validate!\n"); } # endif } diff --git a/src/acc/opencl/acc_opencl.c b/src/acc/opencl/acc_opencl.c index 6ea4f1d1f83..ac19bb59bd9 100644 --- a/src/acc/opencl/acc_opencl.c +++ b/src/acc/opencl/acc_opencl.c @@ -843,6 +843,9 @@ int c_dbcsr_acc_opencl_device_name( cl_device_id device, char name[], size_t name_maxlen, char platform[], size_t platform_maxlen, int cleanup) { int result_name = 0, result_platform = 0; assert(NULL != name || NULL != platform); + if (NULL == device && 0 < c_dbcsr_acc_opencl_config.ndevices) { + device = c_dbcsr_acc_opencl_config.devices[0]; /* NULL-device refers to device 0 */ + } if (NULL != name && 0 != name_maxlen) { result_name = clGetDeviceInfo(device, CL_DEVICE_NAME, name_maxlen, name, NULL); if (0 != cleanup && EXIT_SUCCESS == result_name) { @@ -1157,7 +1160,7 @@ int c_dbcsr_acc_opencl_set_active_device(ACC_OPENCL_LOCKTYPE* lock, int device_i int c_dbcsr_acc_set_active_device(int device_id) { int result = EXIT_SUCCESS; -# if defined(__DBCSR_ACC) && defined(ACC_OPENCL_PROFILE) +# if defined(__DBCSR_ACC) && defined(ACC_OPENCL_PROFILE) && 0 int routine_handle; static const char* const routine_name_ptr = LIBXSMM_FUNCNAME; static const int routine_name_len = (int)sizeof(LIBXSMM_FUNCNAME) - 1; @@ -1177,7 +1180,7 @@ int c_dbcsr_acc_set_active_device(int device_id) { # if !defined(NDEBUG) else result = EXIT_FAILURE; # endif -# if defined(__DBCSR_ACC) && defined(ACC_OPENCL_PROFILE) +# if defined(__DBCSR_ACC) && defined(ACC_OPENCL_PROFILE) && 0 c_dbcsr_timestop(&routine_handle); # endif ACC_OPENCL_RETURN(result); diff --git a/src/acc/opencl/smm/opencl_libsmm.c b/src/acc/opencl/smm/opencl_libsmm.c index 97a0e84a891..f34bcf96db2 100644 --- a/src/acc/opencl/smm/opencl_libsmm.c +++ b/src/acc/opencl/smm/opencl_libsmm.c @@ -28,15 +28,20 @@ libxsmm_gemm_descriptor_dinit(BLOB, PREC, M, N, K, LDA, LDB, LDC, 1.0, 1.0, FLAGS, PREFETCH) # endif -# if !defined(OPENCL_LIBSMM_VALIDATE_TRANS) && defined(OPENCL_LIBSMM_VALIDATE) && \ - (1 < OPENCL_LIBSMM_VALIDATE || 0 > OPENCL_LIBSMM_VALIDATE) -# define OPENCL_LIBSMM_VALIDATE_TRANS -# endif -# if !defined(OPENCL_LIBSMM_VALIDATE_SMM) && defined(OPENCL_LIBSMM_VALIDATE) -# define OPENCL_LIBSMM_VALIDATE_SMM -# endif -# if !defined(OPENCL_LIBSMM_VALIDATE_EXIT) && defined(OPENCL_LIBSMM_VALIDATE) && 1 -# define OPENCL_LIBSMM_VALIDATE_EXIT +# if defined(OPENCL_LIBSMM_VALIDATE) +# if !defined(OPENCL_LIBSMM_VALIDATE_TRANS) && (1 < OPENCL_LIBSMM_VALIDATE || 0 > OPENCL_LIBSMM_VALIDATE) +# define OPENCL_LIBSMM_VALIDATE_TRANS +# endif +# if !defined(OPENCL_LIBSMM_VALIDATE_SMM) +# define OPENCL_LIBSMM_VALIDATE_SMM +# endif +# if !defined(OPENCL_LIBSMM_VALIDATE_EXIT) && 1 +# define OPENCL_LIBSMM_VALIDATE_EXIT +# endif +# if !defined(OPENCL_LIBSMM_VALIDATE_SCRATCH) +# define OPENCL_LIBSMM_VALIDATE_SCRATCH(SIZE, ALIGN) /*libxsmm_aligned_scratch(SIZE, ALIGN)*/ malloc(SIZE) +# define OPENCL_LIBSMM_VALIDATE_FREE(PTR) /*libxsmm_free(PTR)*/ free(PTR) +# endif # endif # if !defined(OPENCL_LIBSMM_KERNELNAME_TRANS) # define OPENCL_LIBSMM_KERNELNAME_TRANS "trans" @@ -111,31 +116,6 @@ int opencl_libsmm_use_cmem(cl_device_id device) { } -# if defined(OPENCL_LIBSMM_VALIDATE) && (0 != OPENCL_LIBSMM_VALIDATE) -void opencl_libsmm_print_matrix(FILE* ostream, const char* label, libsmm_acc_data_t type, const void* mat, int m, int n) { - int i, j; - const char* const s = (NULL != label ? label : ""); - const int len = (int)strlen(s); - for (i = 0; i < m; ++i) { - if (0 < i) { - fprintf(ostream, "%*s", len, " "); - } - else { - fprintf(ostream, "%s", s); - } - for (j = 0; j < n; ++j) { - switch (type) { - case dbcsr_type_real_8: fprintf(ostream, "%.2f ", ((const double*)mat)[i * n + j]); break; - case dbcsr_type_real_4: fprintf(ostream, "%.2f ", ((const float*)mat)[i * n + j]); break; - default: fprintf(ostream, "? "); - } - } - fprintf(ostream, "\n"); - } -} -# endif - - int opencl_libsmm_write_trans_params(FILE* stream, int only_key, const opencl_libsmm_transkey_t* key, const opencl_libsmm_trans_t* config, const char* delim, const char* begin, const char* close) { int result = 0; @@ -786,7 +766,7 @@ int libsmm_acc_transpose(const int* dev_trs_stack, int offset, int stack_size, v const size_t scratch_size = (sizeof(int) * offset_stack_size) /*stack*/ + data_size /*imat*/ + data_size /*omat*/ + (mn * typesize) /*gold*/ + 3 * (LIBXSMM_ALIGNMENT - 1) /*alignments*/; - scratch = libxsmm_aligned_scratch(scratch_size, LIBXSMM_ALIGNMENT); + scratch = OPENCL_LIBSMM_VALIDATE_SCRATCH(scratch_size, LIBXSMM_ALIGNMENT); if (NULL != scratch) { stack = (int*)scratch; imat = (char*)LIBXSMM_UP2((uintptr_t)stack + sizeof(int) * offset_stack_size, LIBXSMM_ALIGNMENT); @@ -855,20 +835,15 @@ int libsmm_acc_transpose(const int* dev_trs_stack, int offset, int stack_size, v } # if defined(OPENCL_LIBSMM_VALIDATE_TRANS) ACC_OPENCL_CHECK(c_dbcsr_acc_memcpy_d2h(dev_data, omat, data_size, stream), "transfer validation test", result); -# endif -# if defined(OPENCL_LIBSMM_VALIDATE_TRANS) ACC_OPENCL_CHECK(c_dbcsr_acc_stream_sync(stream), "sync stream", result); -# endif -# if defined(OPENCL_LIBSMM_VALIDATE_TRANS) if (EXIT_SUCCESS == result) { - int i, j; - LIBXSMM_STDIO_ACQUIRE(); + char print_buffer[2048] = ""; + int print_offset = 0, i, j; if (0 != c_dbcsr_acc_opencl_config.verbosity) { - fprintf(stderr, - "libsmm_acc_transpose(" - "offset=%i, size=%i, type=%s, m=%i, n=%i, max=%i, stream=%p)", - offset, stack_size, dbcsr_type_real_8 == datatype ? "f64" : (dbcsr_type_real_4 == datatype ? "f32" : "unknown"), m, n, - max_kernel_dim, stream); + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, + "libsmm_acc_transpose(offset=%i, size=%i, type=%s, m=%i, n=%i, max=%i, stream=%p)", offset, stack_size, + dbcsr_type_real_8 == datatype ? "f64" : (dbcsr_type_real_4 == datatype ? "f32" : "unknown"), m, n, max_kernel_dim, + stream); } for (i = offset; i < offset_stack_size; ++i) { const size_t index = stack[i]; @@ -879,20 +854,12 @@ int libsmm_acc_transpose(const int* dev_trs_stack, int offset, int stack_size, v libxsmm_itrans(gold, typesize, m, n, m, n); if (0 != memcmp(gold, test, mn * typesize)) { if (0 == c_dbcsr_acc_opencl_config.verbosity) { - fprintf(stderr, - "libsmm_acc_transpose(" - "offset=%i, size=%i, type=%s, m=%i, n=%i, max=%i, stream=%p)", - offset, stack_size, dbcsr_type_real_8 == datatype ? "f64" : (dbcsr_type_real_4 == datatype ? "f32" : "unknown"), m, - n, max_kernel_dim, stream); - } - fprintf(stderr, " => ERROR\n"); - if (3 <= c_dbcsr_acc_opencl_config.verbosity || 0 > c_dbcsr_acc_opencl_config.verbosity) { - fprintf(stderr, "stackposition = %i (index=%llu)\n", i, (unsigned long long)index); - opencl_libsmm_print_matrix(stderr, "orig = ", datatype, orig, m, n); - opencl_libsmm_print_matrix(stderr, "gold = ", datatype, gold, n, m); - opencl_libsmm_print_matrix(stderr, "test = ", datatype, test, n, m); - fprintf(stderr, "\n"); + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, + "libsmm_acc_transpose(offset=%i, size=%i, type=%s, m=%i, n=%i, max=%i, stream=%p)", offset, stack_size, + dbcsr_type_real_8 == datatype ? "f64" : (dbcsr_type_real_4 == datatype ? "f32" : "unknown"), m, n, max_kernel_dim, + stream); } + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, " => ERROR\n"); # if defined(OPENCL_LIBSMM_VALIDATE_EXIT) exit(EXIT_FAILURE); # else @@ -903,7 +870,7 @@ int libsmm_acc_transpose(const int* dev_trs_stack, int offset, int stack_size, v for (j = offset; j < i; ++j) { const size_t duplicate = stack[j]; if (index == duplicate) { - fprintf(stderr, " => ERROR\n"); + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, " => ERROR\n"); # if defined(OPENCL_LIBSMM_VALIDATE_EXIT) exit(EXIT_FAILURE); # else @@ -915,8 +882,10 @@ int libsmm_acc_transpose(const int* dev_trs_stack, int offset, int stack_size, v } } if (0 != c_dbcsr_acc_opencl_config.verbosity && EXIT_SUCCESS == result) { - fprintf(stderr, " => OK\n"); + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, " => OK\n"); } + LIBXSMM_STDIO_ACQUIRE(); + fputs(print_buffer, stderr); LIBXSMM_STDIO_RELEASE(); } libxsmm_free(scratch); @@ -1342,7 +1311,7 @@ int libsmm_acc_process(const int* host_param_stack, const int* dev_param_stack, &blob, precision, m_max, n_max, k_max, m_max, k_max, m_max, LIBXSMM_GEMM_FLAG_NONE, LIBXSMM_PREFETCH_NONE); const size_t scratch_size = psize + asize + bsize + csize + csize + k_max * n_max * typesize + 5 * (LIBXSMM_ALIGNMENT - 1) /*alignments*/; - scratch = libxsmm_aligned_scratch(scratch_size, LIBXSMM_ALIGNMENT); + scratch = OPENCL_LIBSMM_VALIDATE_SCRATCH(scratch_size, LIBXSMM_ALIGNMENT); if (NULL != desc && NULL != scratch) { pinp = (int*)scratch; ainp = (char*)LIBXSMM_UP2((uintptr_t)pinp + psize, LIBXSMM_ALIGNMENT); @@ -1429,10 +1398,12 @@ int libsmm_acc_process(const int* host_param_stack, const int* dev_param_stack, const char* const env_tol = getenv("OPENCL_LIBSMM_SMM_TOLERANCE"); const double tolerance = ((NULL == env_tol || '\0' == *env_tol) ? 1E-3 : atof(env_tol)); const int* const params = pinp + (4 <= nparams ? (nparams - 4) : 0); + char print_buffer[2048] = ""; + int print_offset = 0; size_t i; - LIBXSMM_STDIO_ACQUIRE(); if (0 != c_dbcsr_acc_opencl_config.verbosity) { - fprintf(stderr, "libsmm_acc_process(size=%i, type=%s, m=%i, n=%i, k=%i, max=%i, stream=%p)", stack_size, + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, + "libsmm_acc_process(size=%i, type=%s, m=%i, n=%i, k=%i, max=%i, stream=%p)", stack_size, dbcsr_type_real_8 == datatype ? "f64" : (dbcsr_type_real_4 == datatype ? "f32" : "unknown"), m_max, n_max, k_max, max_kernel_dim, stream); } @@ -1458,20 +1429,21 @@ int libsmm_acc_process(const int* host_param_stack, const int* dev_param_stack, # endif if (tolerance < epsilon) { if (0 == c_dbcsr_acc_opencl_config.verbosity) { - fprintf(stderr, "libsmm_acc_process(size=%i, type=%s, m=%i, n=%i, k=%i, max=%i, stream=%p)", stack_size, + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, + "libsmm_acc_process(size=%i, type=%s, m=%i, n=%i, k=%i, max=%i, stream=%p)", stack_size, dbcsr_type_real_8 == datatype ? "f64" : (dbcsr_type_real_4 == datatype ? "f32" : "unknown"), m_max, n_max, k_max, max_kernel_dim, stream); } # if LIBXSMM_VERSION4(1, 17, 0, 0) < LIBXSMM_VERSION_NUMBER - fprintf(stderr, " => ERROR diff=%g (%g != %g)\n", diff.linf_abs, diff.v_ref, diff.v_tst); -# else - fprintf(stderr, " => ERROR diff=%g\n", diff.linf_abs); + if (LIBXSMM_NOTNAN(diff.v_tst)) { + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, + " => ERROR diff=%g (|%g-%g|=%g)\n", epsilon, diff.v_ref, diff.v_tst, diff.linf_abs); + } + else # endif - if (3 <= c_dbcsr_acc_opencl_config.verbosity || 0 > c_dbcsr_acc_opencl_config.verbosity) { - fprintf(stderr, "stackposition = %llu (index=%llu)\n", (unsigned long long)i, (unsigned long long)ic); - opencl_libsmm_print_matrix(stderr, "gold = ", datatype, gold + ic, m_max, n_max); - opencl_libsmm_print_matrix(stderr, "test = ", datatype, test + ic, m_max, n_max); - fprintf(stderr, "\n"); + { + print_offset += LIBXSMM_SNPRINTF( + print_buffer + print_offset, sizeof(print_buffer) - print_offset, " => ERROR diff=%g\n", epsilon); } # if defined(OPENCL_LIBSMM_VALIDATE_EXIT) exit(EXIT_FAILURE); @@ -1482,8 +1454,10 @@ int libsmm_acc_process(const int* host_param_stack, const int* dev_param_stack, } } if (0 != c_dbcsr_acc_opencl_config.verbosity && EXIT_SUCCESS == result) { - fprintf(stderr, " => OK\n"); + print_offset += LIBXSMM_SNPRINTF(print_buffer + print_offset, sizeof(print_buffer) - print_offset, " => OK\n"); } + LIBXSMM_STDIO_ACQUIRE(); + fputs(print_buffer, stderr); LIBXSMM_STDIO_RELEASE(); } libxsmm_free(scratch); diff --git a/src/acc/opencl/smm/params/tune_multiply_PVC.csv b/src/acc/opencl/smm/params/tune_multiply_PVC.csv index 34e16e0b964..3240739ef49 100644 --- a/src/acc/opencl/smm/params/tune_multiply_PVC.csv +++ b/src/acc/opencl/smm/params/tune_multiply_PVC.csv @@ -430,6 +430,7 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;10;15;4;30000;0;24;10;1;1;15;-1;-2; Intel(R) Data Center GPU Max 1550 [0x0bd5];3;10;15;10;30000;0;16;10;1;3;15;-2;-1;0;0;0;1;0;1;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;10;15;15;30000;0;15;10;1;1;15;1;-1;0;0;0;1;0;0;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;12;12;12;30000;0;8;12;1;12;12;-2;-1;1;1;1;1;1;2;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;1;11;30000;0;8;13;1;1;13;-1;1;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;4;4;30000;0;16;13;1;1;1;-2;-2;0;0;0;1;0;2;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;4;5;30000;0;13;13;1;1;1;-1;-2;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;4;7;30000;0;13;13;1;2;1;1;0;0;0;0;1;0;0;2;0;0 @@ -448,12 +449,15 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;9;30000;0;13;13;1;3;13;-1;-1;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;13;30000;0;8;13;1;3;1;-1;1;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;16;30000;0;8;13;1;1;1;-2;0;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;17;30000;0;8;13;1;7;1;-2;-2;0;1;0;1;1;0;2;1;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;20;30000;0;8;13;1;1;13;-2;-1;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;24;30000;0;8;13;1;1;1;-2;1;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;25;30000;0;8;13;1;1;13;1;-2;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;26;30000;0;8;13;1;10;1;-1;-2;0;0;0;1;0;0;2;1;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;28;30000;0;8;13;1;1;13;-2;0;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;32;30000;0;8;13;1;1;1;-2;0;0;1;0;1;0;0;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;5;45;30000;0;8;13;1;1;13;-1;0;0;0;0;1;0;2;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;6;20;30000;0;8;13;1;1;13;-1;0;0;0;0;1;0;2;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;6;32;30000;0;8;13;1;1;13;-1;-1;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;7;4;30000;0;17;13;1;1;1;-2;-2;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;7;5;30000;0;16;13;1;1;1;-2;0;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;7;7;30000;0;13;13;1;12;1;-2;1;0;0;0;1;0;2;2;0;0 @@ -481,11 +485,12 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;9;30000;0;24;13;1;1;13;-1;-2; Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;13;30000;0;8;13;1;4;1;-1;-2;0;1;1;1;1;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;14;30000;0;18;13;1;1;13;-1;1;0;0;0;1;0;0;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;17;30000;0;15;13;1;1;1;-1;1;0;0;0;1;0;0;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;20;30000;0;24;13;1;1;13;-1;0;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;24;30000;0;12;13;1;1;13;-1;-1;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;25;30000;0;8;13;1;1;13;-1;0;1;0;1;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;26;30000;0;14;13;1;1;13;-1;-2;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;28;30000;0;8;13;1;1;13;-1;-1;1;1;0;1;1;0;0;0;0 -Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;32;30000;0;8;13;1;1;1;-1;0;1;0;0;1;0;0;2;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;32;30000;0;8;13;1;1;1;-2;1;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;13;45;30000;0;8;13;1;1;13;-2;0;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;14;13;30000;0;15;13;1;1;14;-2;1;0;0;0;1;0;0;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;14;14;30000;0;15;13;1;1;14;-2;1;0;0;0;1;0;2;0;0;0 @@ -498,6 +503,11 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;17;5;30000;0;19;13;1;10;1;0;-1;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;17;13;30000;0;9;13;1;9;1;1;-1;1;1;0;1;1;2;0;1;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;17;17;30000;0;8;13;1;1;1;-2;1;1;0;1;1;1;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;17;32;30000;0;8;13;1;1;1;1;-2;1;0;0;1;1;2;0;1;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;20;5;30000;0;17;13;1;8;20;0;1;0;0;0;1;0;1;1;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;20;6;30000;0;9;13;1;12;20;-1;-2;0;0;0;1;0;1;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;20;13;30000;0;11;13;1;9;20;1;-1;0;0;0;1;0;1;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;20;20;30000;0;15;8;1;1;20;-1;-2;0;0;0;1;0;1;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;20;32;30000;0;15;8;1;1;20;-2;1;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;24;5;30000;0;22;13;1;5;1;1;-1;1;1;0;1;0;1;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;24;13;30000;0;13;13;1;10;24;-1;0;0;0;0;1;0;1;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;24;24;30000;0;8;13;1;1;24;1;1;1;0;0;1;1;0;0;0;0 @@ -538,11 +548,13 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;28;32;30000;0;15;13;1;1;28;1;-2; Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;28;45;30000;0;15;13;1;1;28;0;1;0;0;0;1;0;0;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;4;30000;0;25;13;1;7;1;-1;0;0;0;0;1;0;1;1;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;5;30000;0;25;13;1;11;1;0;-2;0;0;0;1;0;1;1;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;6;30000;0;26;13;1;3;32;0;0;0;0;0;1;0;1;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;7;30000;0;25;13;1;4;32;0;0;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;9;30000;0;16;13;1;7;32;-2;0;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;13;30000;0;13;13;1;13;1;-1;-1;0;0;0;1;0;1;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;14;30000;0;13;13;1;12;32;-2;-1;0;0;0;1;0;1;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;17;30000;0;8;13;1;1;1;-1;1;1;1;0;1;1;0;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;20;30000;0;15;13;1;1;32;-1;2;0;0;0;1;0;1;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;24;30000;0;16;13;1;1;32;-2;-2;1;1;0;1;0;2;2;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;25;30000;0;15;13;1;1;32;0;-2;0;0;0;1;0;0;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;13;32;26;30000;0;15;13;1;1;32;0;-2;0;0;0;1;0;0;0;0;1 @@ -671,7 +683,15 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;17;32;35;30000;0;15;17;1;1;1;-1;-1; Intel(R) Data Center GPU Max 1550 [0x0bd5];3;17;35;17;30000;0;30;17;1;1;1;-2;1;0;0;0;1;0;0;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;17;35;32;30000;0;30;17;1;1;1;1;-2;0;1;0;1;1;0;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;17;35;35;30000;0;30;17;1;1;1;0;-2;1;1;1;1;1;2;0;0;1 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;20;5;30000;0;13;20;1;11;20;-2;1;0;0;0;1;0;2;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;20;6;30000;0;15;8;1;14;20;-2;-2;0;0;0;1;0;1;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;20;20;30000;0;8;20;1;1;1;-1;1;0;1;0;1;0;0;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;20;32;30000;0;15;20;1;1;20;0;3;0;0;0;1;0;2;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;32;5;30000;0;21;20;1;14;32;-2;1;0;0;0;1;0;2;2;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;32;6;30000;0;18;20;1;9;32;1;0;0;0;0;1;0;1;2;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;32;13;30000;0;18;8;1;7;32;-1;2;0;0;0;1;0;1;2;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;32;20;30000;0;16;20;1;4;32;1;2;0;0;0;1;0;1;2;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;20;32;32;30000;0;28;20;1;1;32;0;3;0;0;0;1;0;2;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;22;9;9;30000;0;14;22;1;1;1;-1;-1;1;1;0;1;1;0;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;22;9;16;30000;0;10;22;1;1;1;-2;-2;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;22;9;22;30000;0;8;22;1;1;1;-1;0;0;0;0;1;1;0;2;0;0 @@ -1137,6 +1157,10 @@ Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;17;5;30000;0;29;8;1;31;1;1;1;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;17;13;30000;0;27;8;1;23;1;0;-1;0;0;0;1;0;1;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;17;17;30000;0;15;32;1;1;1;-1;1;1;0;1;1;1;2;0;0;1 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;17;32;30000;0;7;8;1;1;1;-2;4;0;0;0;1;0;2;1;0;1 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;20;5;30000;0;32;32;1;1;32;-2;4;0;0;0;1;0;1;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;20;13;30000;0;27;32;1;2;32;-1;4;0;0;0;1;0;1;2;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;20;20;30000;0;12;32;1;1;32;1;4;0;0;0;1;0;0;0;0;0 +Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;20;32;30000;0;3;32;1;22;32;-2;4;0;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;22;9;30000;0;27;8;1;8;32;1;-1;0;0;0;1;0;1;2;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;22;22;30000;0;12;8;1;1;1;1;4;1;0;0;1;0;0;0;0;0 Intel(R) Data Center GPU Max 1550 [0x0bd5];3;32;22;32;30000;0;9;8;1;1;1;-1;-1;0;0;0;1;0;1;1;0;1 diff --git a/src/acc/opencl/smm/tune_multiply.py b/src/acc/opencl/smm/tune_multiply.py index 40d68c82f6f..c930b9b4bea 100755 --- a/src/acc/opencl/smm/tune_multiply.py +++ b/src/acc/opencl/smm/tune_multiply.py @@ -14,8 +14,7 @@ from opentuner import MeasurementInterface from opentuner import Result from signal import signal, SIGINT -import tempfile -import shutil +import tempfile # , shutil import copy import json import glob @@ -123,6 +122,10 @@ def __init__(self, args): device = re.search(devicepat, str(self.run_result["stderr"])) self.ndevices = int(device.group(1)) if device and device.group(1) else 0 self.device = device.group(2) if device and device.group(2) else "" + # idevice: make certain resources/names unique on a per-rank basis + envrank = os.getenv("PMI_RANK", os.getenv("OMPI_COMM_WORLD_LOCAL_RANK")) + if envrank: + self.idevice = int(envrank) % self.ndevices elif self.args.update is not None and "" != self.args.update: self.device = self.args.update if self.run_result and 0 == self.run_result["returncode"]: @@ -198,14 +201,15 @@ def __init__(self, args): and (self.size and 0 < self.size) ): # setup database (DB) if self.args.database is None: # adjust DB-location - envrank = os.getenv("PMI_RANK", os.getenv("OMPI_COMM_WORLD_LOCAL_RANK")) tmpdir = os.path.join(tempfile.gettempdir(), "opentuner") - if envrank: - self.idevice = int(envrank) % self.ndevices + if self.idevice is not None: tmpdir += str(self.idevice) - if os.path.isdir(tmpdir): - shutil.rmtree(tmpdir) - os.mkdir(tmpdir) + # if os.path.isdir(tmpdir): + # shutil.rmtree(tmpdir) + try: + os.mkdir(tmpdir) + except: # noqa: E722 + pass self.args.database = "sqlite:///" + os.path.join( tmpdir, "{}.db".format(os.getpid()) ) @@ -267,7 +271,7 @@ def launch(self, envs, check, nrep=None, verbose=None): if verbose is not None and 0 != int(verbose): msg = env_exe.replace("OPENCL_LIBSMM_SMM_", "") print("{}: {}".format("x".join(map(str, mnk)), msg)) - env_std = "OMP_PROC_BIND=TRUE OPENCL_LIBSMM_SMM_S=0 NEO_CACHE_PERSISTENT=0" + env_std = "OMP_PROC_BIND=TRUE OPENCL_LIBSMM_SMM_S=0 NEO_CACHE_PERSISTENT=0 CUDA_CACHE_DISABLE=1" env_check = "CHECK={}".format(check if check is not None else 1) env_intrn = "{} {}".format( # consider device-id "" if self.idevice is None else "ACC_OPENCL_DEVICE={}".format(self.idevice), @@ -587,18 +591,15 @@ def save_final_config(self, configuration, final=True): except: # noqa: E722 pass gflops = data["GFLOPS"] if data and "GFLOPS" in data else 0 - filename = os.path.join( - self.args.jsondir, - ( - "{}-{}gflops.json".format(self.args.label, round(gflops)) - if 0 < gflops - else "{}.json".format(self.args.label) - ), - ) - try: - os.rename(filedot, filename) - except: # noqa: E722 - pass + if 0 < gflops: + filename = os.path.join( + self.args.jsondir, + "{}-{}gflops.json".format(self.args.label, round(gflops)), + ) + try: + os.rename(filedot, filename) + except: # noqa: E722 + pass # self.manipulator().save_to_file(config, filename) with open(filedot, "w") as file: cfg = config @@ -614,7 +615,7 @@ def save_final_config(self, configuration, final=True): mnk = "x".join(map(str, self.mnk)) print("FAILED[{}] {}: {}".format(result, mnk, failed), flush=True) return - if final and os.path.exists(filedot): + if final and 0 < self.gflops and os.path.exists(filedot): filepattern = "{}-*.json".format(default_basename) fileglobs = glob.glob( os.path.normpath(os.path.join(self.args.jsondir, filepattern)) @@ -932,7 +933,7 @@ def handle_sigint(self, signum, frame): line = file.readline() if not line: break - args.mnk = line.strip() + args.mnk, args.label = line.strip(), "" if args.mnk: start(args) print("")