How to compile MPI CUDA code?

I has a small cluster (four Quad-Core Xeon workstations), and each
workstation install a 8800GT card. I had write the CUDA FDTD code for
one card yet, now I want to extent it to cluster by using MPI(MPICH2).
I can not find any useful infomation how to compile and run it using
nvcc and mpirun ?
does anybody can give some advice?

CUDA and MPI are completely orthogonal. I’d say compile CUDA code into an object file, compile the host code with MPI into an object file, then link the two.

Paulius

hi, I think a wrapper function is needed for kernel code. Is this right?

Yao

It was actually no problem for me. I used the example makefiles. The common.mk ist just slightly modified (to include user libraries).
The modification is like this (just added the $(USRLIB) to the existing common.mk:

LIB := -L$(CUDA_INSTALL_PATH)/lib -L$(LIBDIR) -L$(COMMONDIR)/lib $(USRLIB)

This is my makefile:

ROOTBINDIR = ./
ROOTDIR = /usr/local/NvidiaCudaSdk/

Add source files here

EXECUTABLE := myfirstcuda

Cuda source files (compiled with cudacc)

CUFILES := mzfirstcuda.cu

C/C++ source files (compiled with gcc / c++)

CCFILES :=
potentialfitting.cpp
data.h
data.cpp
crm_atomcluster.h
crm_gjfheader.h
tensorlibdyn.h
montecarlo.h
chi2.h
force_buckingham.h
crm_atomcluster.cpp
crm_gjfheader.cpp
montecarlo.cpp
chi2.cpp
force_buckingham.cpp \

SMVERSIONFLAGS := -arch sm_11

################################################################################

Rules and targets

INCLUDES = -I/opt/mpich/include -I/usr/local/NvidiaCudaSdk/common/inc
USRLIB = -L/opt/mpich/ch-p4mpd/lib64 -lmpich
USRLIB = -lmpich
include /usr/local/NvidiaCudaSdk/common/common.mk

best regards
Christian Müller

Many Thanks for advice.
I still need to study some more about nvcc.

Can you help me how to write a mixed programming using MPI and CUDA??
I just stared this reading about this mixed programming.
Can you give me some direction and where to start for this??