CUSP_INCDIRS = /opt/ THRUST_INCDIRS = /opt/ MPI_INCDIRS = $(dir $(shell find "$(shell dirname $(shell which mpirun))/.." -name "mpi.h")) INCDIRS = $(addprefix -I, $(CUSP_INCDIRS) $(THRUST_INCDIRS) $(MPI_INCDIRS)) LIBDIRS = $(addprefix -L, $(shell find "$(shell dirname $(shell which mpirun))/.." -name "lib")) all: lapexp libpetsc_mgpu.so lapexp: lapexp.o mpicxx $< -o $@ -L/opt/cuda/lib64 -lcudart -lcublas $(LIBDIRS) -lpetsc -llapack -lblas -lX11 lapexp.o: lapexp.cu nvcc -arch=sm_13 $(INCDIRS) -c $< -o $@ libpetsc_mgpu.so: petsc_mgpu.c mpicc -fPIC -I/opt/cuda/include -shared $< -o $@ -L/opt/cuda/lib64 -lcublas clean: rm -rf *.o lapexp libpetsc_mgpu.so test: lapexp libpetsc_mgpu.so LD_PRELOAD=./libpetsc_mgpu.so mpirun -np 2 ./lapexp