Skip to content

Commit

Permalink
Merge pull request #1453 from lucbv/dot_perf_test_backends
Browse files Browse the repository at this point in the history
dot perf test: adding support for HIP and SYCL backend
  • Loading branch information
lucbv authored Jul 5, 2022
2 parents df7cb44 + 41189d4 commit aa1fb58
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
20 changes: 17 additions & 3 deletions perf_test/blas/blas1/KokkosBlas_dot_mv_perf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
struct Params {
int use_cuda = 0;
int use_hip = 0;
int use_sycl = 0;
int use_openmp = 0;
int use_threads = 0;
// m is vector length
Expand All @@ -63,7 +64,8 @@ void print_options() {
std::cerr << "Options:\n" << std::endl;

std::cerr << "\tBACKEND: '--threads[numThreads]' | '--openmp [numThreads]' | "
"'--cuda [cudaDeviceIndex]' | '--hip [hipDeviceIndex]'"
"'--cuda [cudaDeviceIndex]' | '--hip [hipDeviceIndex]' | "
"'--sycl [syclDeviceIndex]'"
<< std::endl;
std::cerr << "\tIf no BACKEND selected, serial is the default." << std::endl;
std::cerr << "\t[Optional] --repeat :: how many times to repeat overall "
Expand All @@ -90,6 +92,8 @@ int parse_inputs(Params& params, int argc, char** argv) {
params.use_cuda = atoi(argv[++i]) + 1;
} else if (0 == Test::string_compare_no_case(argv[i], "--hip")) {
params.use_hip = atoi(argv[++i]) + 1;
} else if (0 == Test::string_compare_no_case(argv[i], "--sycl")) {
params.use_sycl = atoi(argv[++i]) + 1;
} else if (0 == Test::string_compare_no_case(argv[i], "--m")) {
params.m = atoi(argv[++i]);
} else if (0 == Test::string_compare_no_case(argv[i], "--n")) {
Expand Down Expand Up @@ -190,7 +194,8 @@ int main(int argc, char** argv) {
if (parse_inputs(params, argc, argv)) {
return 1;
}
const int device_id = std::max(params.use_cuda, params.use_hip) - 1;
const int device_id =
std::max(std::max(params.use_cuda, params.use_hip), params.use_sycl) - 1;

const int num_threads = std::max(params.use_openmp, params.use_threads);

Expand All @@ -200,7 +205,8 @@ int main(int argc, char** argv) {
bool useOMP = params.use_openmp != 0;
bool useCUDA = params.use_cuda != 0;
bool useHIP = params.use_hip != 0;
bool useSerial = !useThreads && !useOMP && !useCUDA && !useHIP;
bool useSYCL = params.use_sycl != 0;
bool useSerial = !useThreads && !useOMP && !useCUDA && !useHIP && !useSYCL;

if (useThreads) {
#if defined(KOKKOS_ENABLE_THREADS)
Expand Down Expand Up @@ -234,6 +240,14 @@ int main(int argc, char** argv) {
#else
std::cout << "ERROR: HIP requested, but not available.\n";
return 1;
#endif
}
if (useSYCL) {
#if defined(KOKKOS_ENABLE_SYCL)
run<Kokkos::Experimental::SYCL>(params.m, params.n, params.repeat);
#else
std::cout << "ERROR: SYCL requested, but not available.\n";
return 1;
#endif
}
if (useSerial) {
Expand Down
35 changes: 32 additions & 3 deletions perf_test/blas/blas1/KokkosBlas_dot_perf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct Params {
int use_cuda = 0;
int use_openmp = 0;
int use_threads = 0;
int use_hip = 0;
int use_sycl = 0;
// m is vector length
int m = 100000;
int repeat = 1;
Expand All @@ -63,7 +65,8 @@ void print_options() {
std::cerr << "Options:\n" << std::endl;

std::cerr << "\tBACKEND: '--threads[numThreads]' | '--openmp [numThreads]' | "
"'--cuda [cudaDeviceIndex]'"
"'--cuda [cudaDeviceIndex]' | '--hip [hipDeviceIndex]' | "
"'--sycl [syclDeviceIndex]'"
<< std::endl;
std::cerr << "\tIf no BACKEND selected, serial is the default." << std::endl;
std::cerr << "\t[Optional] --repeat :: how many times to repeat overall "
Expand All @@ -86,6 +89,10 @@ int parse_inputs(Params& params, int argc, char** argv) {
params.use_openmp = atoi(argv[++i]);
} else if (0 == Test::string_compare_no_case(argv[i], "--cuda")) {
params.use_cuda = atoi(argv[++i]) + 1;
} else if (0 == Test::string_compare_no_case(argv[i], "--hip")) {
params.use_hip = atoi(argv[++i]) + 1;
} else if (0 == Test::string_compare_no_case(argv[i], "--sycl")) {
params.use_sycl = atoi(argv[++i]) + 1;
} else if (0 == Test::string_compare_no_case(argv[i], "--m")) {
params.m = atoi(argv[++i]);
} else if (0 == Test::string_compare_no_case(argv[i], "--repeat")) {
Expand Down Expand Up @@ -184,7 +191,8 @@ int main(int argc, char** argv) {
if (parse_inputs(params, argc, argv)) {
return 1;
}
const int device_id = params.use_cuda - 1;
const int device_id =
std::max(std::max(params.use_cuda, params.use_hip), params.use_sycl) - 1;

const int num_threads = std::max(params.use_openmp, params.use_threads);

Expand All @@ -193,7 +201,9 @@ int main(int argc, char** argv) {
bool useThreads = params.use_threads != 0;
bool useOMP = params.use_openmp != 0;
bool useCUDA = params.use_cuda != 0;
bool useSerial = !useThreads && !useOMP && !useCUDA;
bool useHIP = params.use_hip != 0;
bool useSYCL = params.use_sycl != 0;
bool useSerial = !useThreads && !useOMP && !useCUDA && !useHIP && !useSYCL;

if (useThreads) {
#if defined(KOKKOS_ENABLE_THREADS)
Expand Down Expand Up @@ -221,6 +231,25 @@ int main(int argc, char** argv) {
return 1;
#endif
}

if (useHIP) {
#if defined(KOKKOS_ENABLE_HIP)
run<Kokkos::Experimental::HIP>(params.m, params.repeat);
#else
std::cout << "ERROR: HIP requested, but not available.\n";
return 1;
#endif
}

if (useSYCL) {
#if defined(KOKKOS_ENABLE_SYCL)
run<Kokkos::Experimental::SYCL>(params.m, params.repeat);
#else
std::cout << "ERROR: SYCL requested, but not available.\n";
return 1;
#endif
}

if (useSerial) {
#if defined(KOKKOS_ENABLE_SERIAL)
run<Kokkos::Serial>(params.m, params.repeat);
Expand Down

0 comments on commit aa1fb58

Please sign in to comment.