Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HIP support to src/ and perf_test/ #828

Merged
merged 18 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion perf_test/batched/KokkosBatched_Test_BlockCrs_Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using namespace KokkosBatched;
int main (int argc, char *argv[]) {
Kokkos::initialize(argc, argv);

#if !defined(__CUDA_ARCH__)
#if !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
typedef Kokkos::DefaultHostExecutionSpace HostSpaceType;
const bool detail = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {

Kokkos::initialize(argc, argv);

#if !defined(__CUDA_ARCH__)
#if !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
const int ntest = 1;
//const int N[6] = { 256, 512, 768, 1024, 1280, 1536 };
int N[1] = { 128*128 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void run(const int N) {
int main(int argc, char *argv[]) {

Kokkos::initialize(argc, argv);
#if !defined(__CUDA_ARCH__)
#if !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
const int ntest = 1;
//const int N[6] = { 256, 512, 768, 1024, 1280, 1536 };
int N[1] = { 128*128 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void run(const int N) {
int main(int argc, char *argv[]) {

Kokkos::initialize(argc, argv);
#if !defined(__CUDA_ARCH__)
#if !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
const int ntest = 1;
//const int N[6] = { 256, 512, 768, 1024, 1280, 1536 };
const int N[1] = { 128*128 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {

Kokkos::initialize(argc, argv);

#if !defined(__CUDA_ARCH__)
#if !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
int N = 128*128;

for (int i=1;i<argc;++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void run(const int N) {
int main(int argc, char *argv[]) {

Kokkos::initialize(argc, argv);
#if !defined(__CUDA_ARCH__)
#if !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__)
int N = 128*128;

for (int i=1;i<argc;++i) {
Expand Down
9 changes: 9 additions & 0 deletions perf_test/graph/KokkosGraph_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,15 @@ int main (int argc, char ** argv){

#endif

#if defined( KOKKOS_ENABLE_HIP )
if (params.use_hip) {
KokkosKernels::Experiment::run_multi_mem_experiment
<size_type, idx, Kokkos::Experimental::HIP, Kokkos::Experimental::HIPSpace, Kokkos::Experimental::HIPSpace>(
params
);
}
#endif

#if defined( KOKKOS_ENABLE_SERIAL )
if (params.use_serial) {
#ifdef KOKKOSKERNELS_MULTI_MEM
Expand Down
23 changes: 22 additions & 1 deletion perf_test/graph/KokkosGraph_color_d2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct D2Parameters
int use_threads;
int use_openmp;
int use_cuda;
int use_hip;
int use_serial;
const char* mtx_file;
ColoringMode d2_color_type;
Expand All @@ -93,6 +94,7 @@ struct D2Parameters
use_threads = 0;
use_openmp = 0;
use_cuda = 0;
use_hip = 0;
use_serial = 0;
mtx_file = NULL;
d2_color_type = MODE_D2_SYMMETRIC;
Expand Down Expand Up @@ -147,6 +149,9 @@ void print_options(std::ostream &os, const char *app_name, unsigned int indent =
#endif
#ifdef KOKKOS_ENABLE_CUDA
<< spaces << " --cuda <device id> Use given CUDA device" << std::endl
#endif
#ifdef KOKKOS_ENABLE_HIP
<< spaces << " --hip <device id> Use given HIP device" << std::endl
#endif
<< std::endl
<< spaces << " Coloring modes:" << std::endl
Expand Down Expand Up @@ -199,6 +204,10 @@ int parse_inputs(D2Parameters &params, int argc, char **argv)
{
params.use_cuda = 1 + atoi(getNextArg(i, argc, argv));
}
else if(0 == strcasecmp(argv[i], "--hip"))
{
params.use_hip = 1 + atoi(getNextArg(i, argc, argv));
}
else if(0 == strcasecmp(argv[i], "--repeat"))
{
params.repeat = atoi(getNextArg(i, argc, argv));
Expand Down Expand Up @@ -273,7 +282,7 @@ int parse_inputs(D2Parameters &params, int argc, char **argv)
print_options(std::cout, argv[0]);
return 1;
}
if(!params.use_serial && !params.use_threads && !params.use_openmp && !params.use_cuda)
if(!params.use_serial && !params.use_threads && !params.use_openmp && !params.use_cuda && !params.use_hip)
{
print_options(std::cout, argv[0]);
return 1;
Expand Down Expand Up @@ -603,6 +612,8 @@ int main(int argc, char *argv[])
int device_id = 0;
if(params.use_cuda)
device_id = params.use_cuda - 1;
else if(params.use_hip)
device_id = params.use_hip - 1;
Kokkos::initialize(Kokkos::InitArguments(num_threads, -1, device_id));

// Print out verbose information about the configuration of the run.
Expand Down Expand Up @@ -645,6 +656,16 @@ int main(int argc, char *argv[])
}
#endif

#if defined(KOKKOS_ENABLE_HIP)
if(params.use_hip)
{
if(!use_multi_mem)
{
KokkosKernels::Experiment::experiment_driver<kk_size_type, kk_lno_t, Kokkos::Experimental::HIP, Kokkos::Experimental::HIPSpace>(params);
}
}
#endif

#if defined(KOKKOS_ENABLE_SERIAL)
if(params.use_serial)
{
Expand Down
18 changes: 17 additions & 1 deletion perf_test/graph/KokkosGraph_mis_d2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct MIS2Parameters
int use_threads = 0;
int use_openmp = 0;
int use_cuda = 0;
int use_hip = 0;
int use_serial = 0;
const char* mtx_file = NULL;
MIS2_Algorithm algo = MIS2_FAST;
Expand Down Expand Up @@ -163,6 +164,9 @@ void print_options(std::ostream &os, const char *app_name, unsigned int indent =
#endif
#ifdef KOKKOS_ENABLE_CUDA
<< spaces << " --cuda Use CUDA.\n"
#endif
#ifdef KOKKOS_ENABLE_HIP
<< spaces << " --hip Use HIP.\n"
#endif
<< std::endl
<< spaces << " Optional Parameters:" << std::endl
Expand Down Expand Up @@ -205,6 +209,10 @@ int parse_inputs(MIS2Parameters &params, int argc, char **argv)
{
params.use_cuda = 1;
}
else if(0 == strcasecmp(argv[i], "--hip"))
{
params.use_hip = 1;
}
else if(0 == strcasecmp(argv[i], "--repeat"))
{
params.repeat = atoi(getNextArg(i, argc, argv));
Expand Down Expand Up @@ -252,7 +260,7 @@ int parse_inputs(MIS2Parameters &params, int argc, char **argv)
print_options(std::cout, argv[0]);
return 1;
}
if(!params.use_serial && !params.use_threads && !params.use_openmp && !params.use_cuda)
if(!params.use_serial && !params.use_threads && !params.use_openmp && !params.use_cuda && !params.use_hip)
{
print_options(std::cout, argv[0]);
return 1;
Expand Down Expand Up @@ -362,6 +370,14 @@ int main(int argc, char *argv[])
}
#endif

#if defined(KOKKOS_ENABLE_HIP)
if(params.use_hip)
{
run_mis2<Kokkos::Experimental::HIP>(params);
run = true;
}
#endif

#if defined(KOKKOS_ENABLE_SERIAL)
if(params.use_serial)
{
Expand Down
19 changes: 15 additions & 4 deletions perf_test/graph/KokkosGraph_triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

void print_options(){
std::cerr << "Options\n" << std::endl;
std::cerr << "Choose BackEnd : --openmp [numthreads] | --cuda" << std::endl;
std::cerr << "Choose BackEnd : --openmp [numthreads] | --cuda | --hip" << std::endl;
std::cerr << "Input Matrix : --amtx [path_to_input_matrix]" << std::endl;
std::cerr << "\tInput Matrix format can be multiple formats. If it ends with:" << std::endl;
std::cerr << "\t\t.mtx: it will read matrix market format." << std::endl;
Expand Down Expand Up @@ -96,6 +96,9 @@ int parse_inputs (KokkosKernels::Experiment::Parameters &params, int argc, char
else if ( 0 == strcasecmp( argv[i] , "--cuda" ) ) {
params.use_cuda = 1;
}
else if ( 0 == strcasecmp( argv[i] , "--hip" ) ) {
params.use_hip = 1;
}
else if ( 0 == strcasecmp( argv[i] , "--repeat" ) ) {
params.repeat = atoi( argv[++i] );
}
Expand Down Expand Up @@ -292,7 +295,6 @@ int main (int argc, char ** argv){
const int device_id = 0;
Kokkos::initialize( Kokkos::InitArguments( num_threads, -1, device_id ) );

#if !defined (KOKKOS_ENABLE_CUDA)
#if defined( KOKKOS_ENABLE_OPENMP )

if (params.use_openmp) {
Expand All @@ -311,10 +313,9 @@ int main (int argc, char ** argv){
}

#endif
#endif


#if defined( KOKKOS_ENABLE_CUDA1 )
#if defined( KOKKOS_ENABLE_CUDA )
if (params.use_cuda) {
Kokkos::Cuda::print_configuration(std::cout);
#ifdef KOKKOSKERNELS_MULTI_MEM
Expand All @@ -332,6 +333,16 @@ int main (int argc, char ** argv){

#endif

#if defined( KOKKOS_ENABLE_HIP )
if (params.use_hip) {
Kokkos::Experimental::HIP::print_configuration(std::cout);
KokkosKernels::Experiment::run_multi_mem_triangle
<size_type, idx, Kokkos::Experimental::HIP, Kokkos::Experimental::HIPSpace, Kokkos::Experimental::HIPSpace>(
params
);
}
#endif

Kokkos::finalize();

return 0;
Expand Down
5 changes: 5 additions & 0 deletions perf_test/sparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ KOKKOSKERNELS_ADD_EXECUTABLE(
SOURCES KokkosSparse_spmv.cpp
)

KOKKOSKERNELS_ADD_EXECUTABLE(
sparse_kk_spmv
SOURCES KokkosSparse_kk_spmv.cpp
)

IF(KOKKOSKERNELS_ENABLE_TPL_CUSPARSE)
KOKKOSKERNELS_ADD_EXECUTABLE(
sparse_spmv_merge
Expand Down
Loading