Skip to content

Commit

Permalink
Correct initialization/finalization flow (benchmark drivers); includi…
Browse files Browse the repository at this point in the history
…ng a workaround for cp2k#422 (CUDA).
  • Loading branch information
hfp committed Jan 21, 2021
1 parent 4bb3983 commit e6693bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/acc/acc_bench_smm.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int main(int argc, char* argv[])
printf("%s%s%i %i %i %i %i %i %i %i\n", 0 < argc ? argv[0] : "", 0 < argc ? " " : "",
nrepeat, stack_size, m, n, k, nc, na, nb);
CHECK(acc_init(), &result);
/* libsmm_acc_init() should imply acc_init() */
/* note: libsmm_acc_init() may imply acc_init() */
CHECK(libsmm_acc_init(), &result);
CHECK(acc_get_ndevices(&ndevices), &result);
if (0 < ndevices) {
Expand All @@ -117,6 +117,9 @@ int main(int argc, char* argv[])
else {
#if defined(_DEBUG)
fprintf(stderr, "Error: no device found!\n");
#endif
#if !defined(__CUDA)
CHECK(libsmm_acc_finalize(), NULL);
#endif
CHECK(acc_finalize(), NULL);
return result;
Expand Down Expand Up @@ -284,6 +287,9 @@ int main(int argc, char* argv[])
CHECK(acc_dev_mem_deallocate(bmat_dev), NULL);
CHECK(acc_dev_mem_deallocate(cmat_dev), NULL);
CHECK(acc_stream_destroy(stream), NULL);
#if !defined(__CUDA)
CHECK(libsmm_acc_finalize(), NULL);
#endif
CHECK(acc_finalize(), NULL);
if (EXIT_SUCCESS != result) {
fprintf(stderr, "FAILED\n");
Expand Down
4 changes: 3 additions & 1 deletion src/acc/acc_bench_trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main(int argc, char* argv[])
assert(m <= (mn / n) && 0 == (mn % n));
printf("%s%s%i %i %i %i\n", 0 < argc ? argv[0] : "", 0 < argc ? " " : "", nrepeat, stack_size, m, n);
CHECK(acc_init(), &result);
/* libsmm_acc_init() should imply acc_init() */
/* note: libsmm_acc_init() may imply acc_init() */
CHECK(libsmm_acc_init(), &result);
CHECK(acc_get_ndevices(&ndevices), &result);
if (0 < ndevices) {
Expand All @@ -98,6 +98,7 @@ int main(int argc, char* argv[])
#if defined(_DEBUG)
fprintf(stderr, "Error: no device found!\n");
#endif
CHECK(libsmm_acc_finalize(), NULL);
CHECK(acc_finalize(), NULL);
return result;
}
Expand Down Expand Up @@ -207,6 +208,7 @@ int main(int argc, char* argv[])
CHECK(acc_dev_mem_deallocate(stack_dev), NULL);
CHECK(acc_dev_mem_deallocate(mat_dev), NULL);
CHECK(acc_stream_destroy(stream), NULL);
CHECK(libsmm_acc_finalize(), NULL);
CHECK(acc_finalize(), NULL);
if (EXIT_SUCCESS != result) {
fprintf(stderr, "FAILED\n");
Expand Down

0 comments on commit e6693bd

Please sign in to comment.