Skip to content

Commit fb2f9a2

Browse files
committed
Made some changes to make it run with CUDA 4.2
1 parent aeb0434 commit fb2f9a2

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

posts/cuda-aware-mpi-example/src/CUDA_Aware_MPI.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
void SetDeviceBeforeInit()
2424
{
2525
char * localRankStr = NULL;
26-
int rank = 0, devCount = 0;
26+
int rank = 0, devCount = 0;
2727

2828
// We extract the local rank initialization using an environment variable
2929
if ((localRankStr = getenv(ENV_LOCAL_RANK)) != NULL)

posts/cuda-aware-mpi-example/src/Host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void InitializeDataChunk(int topSizeY, int topIdxY, const int2 * domSize, const
261261
SafeCudaCall(cudaMalloc((void **)devResidue, sizeof(real)));
262262
SafeCudaCall(cudaMemcpy(devBlocks[0], hostBlock, blockBytes, cudaMemcpyHostToDevice));
263263
SafeCudaCall(cudaMemcpy(devBlocks[1], devBlocks[0], blockBytes, cudaMemcpyDeviceToDevice));
264-
SafeCudaCall(cudaStreamCreateWithFlags(copyStream, cudaStreamNonBlocking));
264+
SafeCudaCall(cudaStreamCreate(copyStream));
265265

266266
SafeHostFree(hostBlock);
267267
}

posts/cuda-aware-mpi-example/src/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ GENCODE_SM13 := -gencode arch=compute_13,code=sm_13
2121
GENCODE_SM20 := -gencode arch=compute_20,code=sm_20
2222
GENCODE_SM30 := -gencode arch=compute_30,code=sm_30
2323
GENCODE_SM35 := -gencode arch=compute_35,code=sm_35
24-
GENCODE_FLAGS := $(GENCODE_SM13) $(GENCODE_SM20) $(GENCODE_SM30) $(GENCODE_SM35)
24+
GENCODE_FLAGS := $(GENCODE_SM13) $(GENCODE_SM20)
2525

2626
NVCCFLAGS=-O3 $(GENCODE_FLAGS) -Xcompiler -march=native
2727

@@ -55,9 +55,11 @@ cuda_aware_mpi.o: Jacobi.h CUDA_Aware_MPI.c Makefile
5555
$(MPICC) $(MPICFLAGS) $(CFLAGS) $(CUDACFLAGS) -c CUDA_Aware_MPI.c -o cuda_aware_mpi.o
5656

5757
$(JACOBI_CUDA_NORMAL_MPI): jacobi.o input.o host.o device.o cuda_normal_mpi.o Makefile
58+
mkdir -p $(BINDIR)
5859
$(MPICC) $(CUDALDFLAGS) -o $(JACOBI_CUDA_NORMAL_MPI) jacobi.o input.o host.o device.o cuda_normal_mpi.o
5960

6061
$(JACOBI_CUDA_AWARE_MPI): jacobi.o input.o host.o device.o cuda_aware_mpi.o Makefile
62+
mkdir -p $(BINDIR)
6163
$(MPICC) $(CUDALDFLAGS) -o $(JACOBI_CUDA_AWARE_MPI) jacobi.o input.o host.o device.o cuda_aware_mpi.o
6264

6365
doc: CUDA_Normal_MPI.c CUDA_Aware_MPI.c Device.cu Host.c Input.c Makefile Jacobi.c Jacobi.h Jacobi.doxygen

posts/cuda-aware-mpi-example/src/README

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Description document for the GPU-based Jacobi solver
1515
Contents:
1616
---------
1717
1) Application overview
18-
2) Build instructions
19-
3) Documentation
18+
2) Build instructions
19+
3) Run instructions
20+
4) Documentation
2021

2122

2223
=======================
@@ -56,8 +57,6 @@ c) -fs - optional argument indicating that the replacement of the old block wi
5657
a fast pointer swap rather than a full block copy (which is the default behavior)
5758
d) -h | --help - optional argument for printing help information; this overrides all other arguments
5859

59-
60-
6160
=====================
6261
2) Build instructions
6362
=====================
@@ -72,11 +71,22 @@ You can build the CUDA-aware MPI an the normal MPI version by calling make in sr
7271
cd src
7372
make
7473

75-
To find mpi.h and the CUDA runtime library the provied Makefile relies on CUDA_INSTALL_PATH and MPI_HOME beeing set correctly.
74+
To find mpi.h and the CUDA runtime library the provied Makefile relies on CUDA_INSTALL_PATH and MPI_HOME beeing set correctly. If you are using CUDA 5 or newer and running on a device with compute capability 3.0 or 3.5 you should also add GENCODE_SM30 and GENCODE_SM35 to the GENCODE_FLAGS in the Makefile. Also the macro ENV_LOCAL_RANK might need to
75+
be changed in Jacobi.h to handle the GPU affinit properly. It defaults to MV2_COMM_WORLD_LOCAL_RANK which works with MVAPICH2.
7676
The generated binaries can then be found found the bin directory.
77+
78+
===================
79+
3) Run instructions
80+
===================
81+
82+
To run the normal MPI version use:
83+
mpiexec -np 2 ./jacobi_cuda_normal_mpi -t 2 1
84+
85+
To run the CUDA-aware MPI version depending on the MPI implementation you are using you need to activate the CUDA-aware feature, e.g. for MVAPICH2 use
86+
MV2_USE_CUDA=1 mpiexec -np 2 --exports=MV2_USE_CUDA ./jacobi_cuda_aware_mpi -t 2 1
7787

7888
================
79-
3) Documentation
89+
4) Documentation
8090
================
8191

8292
Documentation for this project may be generated automatically using Doxygen by calling make doc. A configuration file for this may be found in the "doc" folder. If

0 commit comments

Comments
 (0)