Skip to content

Commit

Permalink
MATLAB compile scripts integrated in Makefile and configure script
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwittek committed Sep 30, 2015
1 parent 5d13abe commit 8d996de
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bindir = @bindir@
srcdir = @srcdir@
VPATH = @srcdir@

all clean install uninstall lib somoclu python python_doc python_clean python_install r r_clean:
all clean install uninstall lib somoclu python python_doc python_clean python_install r r_clean matlab matlab_clean:
$(MAKE) -C src $@

dist: $(distdir).tar.gz
Expand Down
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ if test x"$with_mpi" != x"no" ; then
mpi_enabled=yes
fi
fi
#Setup MEX compiler
# ------------------------------------------------------------------------------
MATLAB_ROOT="/usr/local/MATLAB/R2013a"
AC_ARG_WITH([matlab],
[ --with-matlab=PATH prefix where MATLAB is installed [default=/usr/local/MATLAB/R2013a]])
if test x"$with_matlab" != x"no" ; then

if test -n "$with_matlab"
then
MATLAB_ROOT=$with_matlab
fi

fi


MEX_BIN=$MATLAB_ROOT/bin/mex
AC_SUBST(MATLAB_ROOT)
AC_SUBST(MEX_BIN)

AC_CONFIG_FILES([Makefile
src/Makefile])
Expand Down
10 changes: 0 additions & 10 deletions src/MATLAB/makeMex-GPU.sh

This file was deleted.

6 changes: 0 additions & 6 deletions src/MATLAB/makeMex.sh

This file was deleted.

37 changes: 27 additions & 10 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@ NVCC = @NVCC@
MPI_INC = @MPI_INC@
MPI_LIBDIR = @MPI_LIBDIR@
MPI_LIBS = @MPI_LIBS@
MATLAB_ROOT = @MATLAB_ROOT@
MEX_BIN = @MEX_BIN@

# VPATH-related substitution variables
srcdir = @srcdir@
VPATH = @srcdir@

LIBOBJS=sparseCpuKernels.o denseCpuKernels.o mapDistanceFunctions.o training.o uMatrix.o
LIBOBJS=sparseCpuKernels.o denseCpuKernels.o io.o mapDistanceFunctions.o training.o uMatrix.o

MEX_FLAGS=-I./
MEX_LIBS=-lgomp
MEX_OBJS=sparseCpuKernels.o denseCpuKernels.o io.o mapDistanceFunctions.o training.o uMatrix.o

ifdef CUDA_LIBS
LIBOBJS+=denseGpuKernels.cu.co
MEX_FLAGS+=-I"$(MATLAB_ROOT)/toolbox/distcomp/gpu/extern/include/" -DCUDA
MEX_LIBS+=$(CUDA_LDFLAGS) $(CUDA_LIBS) -lnvblas -lmwgpu
MEX_OBJS+=denseGpuKernels.cu.o
endif

OBJS=$(LIBOBJS) io.o somoclu.o
Expand All @@ -56,15 +65,13 @@ somoclu: $(OBJS)
%.cu.co: %.cu
$(NVCC) $(DEFS) $(CUDA_CFLAGS) ${MPI_INC} -I$(srcdir) -I.. -o $@ -c $(srcdir)/$<

python_clean:
-rm -fr ./Python/somoclu/src ./Python/somoclu.egg* \
./Python/somoclu/install-sh ./Python/somoclu/Makefile* \
./Python/somoclu/config* ./Python/somoclu/*so \
./Python/somoclu/somoclu_wrap* ./Python/somoclu/*pyc \
./Python/LICENSE ./Python/dist \
./Python/doc/doctrees ./Python/doc/manual.pdf ./Python/doc/html \
./Python/doc/latex ./Python/build $(OBJS) 1>/dev/null
matlab: lib
if [ -e denseGpuKernels.cu.co ]; then cp denseGpuKernels.cu.co denseGpuKernels.cu.o; fi
$(MEX_BIN) $(MEX_FLAGS) MATLAB/MexSomoclu.cpp $(MEX_OBJS) $(MEX_LIBS)

matlab_clean: clean
-rm -f MexSomoclu* denseGpuKernels.cu.o

python:
mkdir -p ./Python/somoclu/src
mkdir -p ./Python/somoclu/src/Windows
Expand All @@ -86,11 +93,20 @@ python_doc: python
python_install: python python_doc
cd Python; python setup.py install

python_clean:
-rm -fr ./Python/somoclu/src ./Python/somoclu.egg* \
./Python/somoclu/install-sh ./Python/somoclu/Makefile* \
./Python/somoclu/config* ./Python/somoclu/*so \
./Python/somoclu/somoclu_wrap* ./Python/somoclu/*pyc \
./Python/LICENSE ./Python/dist \
./Python/doc/doctrees ./Python/doc/manual.pdf ./Python/doc/html \
./Python/doc/latex ./Python/build $(OBJS) 1>/dev/null

r_clean:
-rm -fr ./R/src/configure ./R/src/config.h.in ./R/src/Makefile.root.in \
./R/src/Makefile.in ./R/src/denseGpuKernels.cu ./R/src/*h \
./R/src/mapDistanceFunctions.cpp ./R/src/training.cpp \
./R/src/uMatrix.cpp ./R/src/denseCpuKernels.cpp \
./R/src/io.cpp ./R/src/uMatrix.cpp ./R/src/denseCpuKernels.cpp \
./R/src/sparseCpuKernels.cpp R/data ./Rsomoclu*gz

r:
Expand All @@ -104,6 +120,7 @@ r:
cp ./mapDistanceFunctions.cpp ./R/src/
cp ./training.cpp ./R/src/
cp ./uMatrix.cpp ./R/src/
cp ./io.cpp ./R/src/
cp ./denseCpuKernels.cpp ./R/src/
cp ./denseGpuKernels.cu ./R/src/
cp ./sparseCpuKernels.cpp ./R/src/
Expand Down

5 comments on commit 8d996de

@xgdgsc
Copy link
Collaborator

@xgdgsc xgdgsc commented on 8d996de Sep 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding io.cpp to r is unnecessary and would cause a warning in R CMD check:

* checking compiled code ... WARNING
File ‘Rsomoclu/libs/Rsomoclu.so’:
  Found ‘_ZSt4cerr’, possibly from ‘std::cerr’ (C++)
    Object: ‘io.o’
  Found ‘_ZSt4cout’, possibly from ‘std::cout’ (C++)
    Object: ‘io.o’
  Found ‘exit’, possibly from ‘exit’ (C)
    Object: ‘io.o’

cerr, cout, exit are forbidden.

@peterwittek
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason it is there is the GPU kernel: the my_abort function is in io.cpp. We can restructure it in the next version.

@xgdgsc
Copy link
Collaborator

@xgdgsc xgdgsc commented on 8d996de Sep 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I' ve added my_abort to Rsomoclu.cpp in 9b0de3b for CUDA.

@peterwittek
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is something I overlooked. I noticed MEX complaining when io.cpp was missing, this is why a couple of changes were made across the interfaces. You might want to exclude io.cpp when you update CRAN. The eventual solution will be a restructuring that does not kill the process if there are CUDA failures. I make open an issue on this.

@xgdgsc
Copy link
Collaborator

@xgdgsc xgdgsc commented on 8d996de Sep 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I can exclude io.cpp when I update CRAN.

Please sign in to comment.