Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion tests/cc/halo_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,13 @@ int main(int argc, char** argv) {
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &local_comm);
int local_rank;
MPI_Comm_rank(local_comm, &local_rank);
CHECK_CUDA_EXIT(cudaSetDevice(local_rank));
int num_devices = 0;
CHECK_CUDA_EXIT(cudaGetDeviceCount(&num_devices));
if (num_devices <= 0) {
fprintf(stderr, "No CUDA devices available.\n");
exit(EXIT_FAILURE);
}
CHECK_CUDA_EXIT(cudaSetDevice(local_rank % num_devices));

// Check if test file was provided
std::string testfile;
Expand Down
8 changes: 7 additions & 1 deletion tests/cc/transpose_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,13 @@ int main(int argc, char** argv) {
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &local_comm);
int local_rank;
MPI_Comm_rank(local_comm, &local_rank);
CHECK_CUDA_EXIT(cudaSetDevice(local_rank));
int num_devices = 0;
CHECK_CUDA_EXIT(cudaGetDeviceCount(&num_devices));
if (num_devices <= 0) {
fprintf(stderr, "No CUDA devices available.\n");
exit(EXIT_FAILURE);
}
CHECK_CUDA_EXIT(cudaSetDevice(local_rank % num_devices));

// Check if test file was provided
std::string testfile;
Expand Down
9 changes: 7 additions & 2 deletions tests/fortran/halo_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ program main

integer :: i, idx
real(real64) :: t0
integer :: local_rank, ierr
integer :: local_rank, ierr, num_devices
integer :: local_comm
integer :: res, retcode
logical :: using_testfile
Expand All @@ -546,7 +546,12 @@ program main

call MPI_Comm_split_Type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, local_comm, ierr)
call MPI_Comm_rank(local_comm, local_rank, ierr)
CHECK_CUDA_EXIT(cudaSetDevice(local_rank))
CHECK_CUDA_EXIT(cudaGetDeviceCount(num_devices))
if (num_devices <= 0) then
print*, 'No CUDA devices available.'
call exit(1)
endif
CHECK_CUDA_EXIT(cudaSetDevice(mod(local_rank, num_devices)))

using_testfile = .false.
do i = 1, command_argument_count()
Expand Down
9 changes: 7 additions & 2 deletions tests/fortran/transpose_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ program main

integer :: i, idx
real(real64) :: t0
integer :: local_rank, ierr
integer :: local_rank, ierr, num_devices
integer :: local_comm
integer :: res, retcode
logical :: using_testfile
Expand All @@ -571,7 +571,12 @@ program main

call MPI_Comm_split_Type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, local_comm, ierr)
call MPI_Comm_rank(local_comm, local_rank, ierr)
CHECK_CUDA_EXIT(cudaSetDevice(local_rank))
CHECK_CUDA_EXIT(cudaGetDeviceCount(num_devices))
if (num_devices <= 0) then
print*, 'No CUDA devices available.'
call exit(1)
endif
CHECK_CUDA_EXIT(cudaSetDevice(mod(local_rank, num_devices)))

using_testfile = .false.
do i = 1, command_argument_count()
Expand Down
Loading