Skip to content

Commit

Permalink
new os x build (+1 squashed commit)
Browse files Browse the repository at this point in the history
Squashed commits:
[11fbf8a] Add support for Mac OS X build
This needs gcc-5 compiler
  • Loading branch information
eliasdc committed Aug 4, 2015
1 parent a6ef761 commit 9e50bcf
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 21 deletions.
4 changes: 3 additions & 1 deletion be.iminds.iot.dianne.tensor/cuda.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Import-Package: com.esotericsoftware.kryo.*;resolution:=optional
Bundle-Name: Dianne Cuda Tensor Library
Bundle-Description: Dianne Tensor implementation based on Torch's THC Cuda lib

Bundle-NativeCode: x86_64/libTHTensor.so;osname=Linux;processor=x86_64,armv7l/libTHTensor.so;osname=Linux;processor=arm
Bundle-NativeCode: \
Linux/x86_64/libTHTensor.so;osname=Linux;processor=x86_64,\
Linux/armv7l/libTHTensor.so;osname=Linux;processor=arm

-includeresource: \
cuda
36 changes: 20 additions & 16 deletions be.iminds.iot.dianne.tensor/jni/THTensor/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# This file builds the native TH Tensor library and the JNI interface

CC=gcc
CXX=g++
NVCC=nvcc
OS := $(shell uname -s)
ARCH := $(shell uname -m)

JAVA_HOME := /usr/lib/jvm/default-java
CUDA_HOME := /usr/local/cuda
ifeq ($(OS),Linux)
include Makefile.Linux
endif
ifeq ($(OS),Darwin)
include Makefile.Darwin
endif

CUDA_HOME ?= /usr/local/cuda
JAVA_INCLUDE := $(JAVA_HOME)/include
JAVA_PLATFORMINCLUDE := $(JAVA_INCLUDE)/$(JDKPLATFORMINCLUDESUBDIR)

ARCH := $(shell uname -m)
JAVAH := be.iminds.iot.dianne.tensor.impl.th.THTensor be.iminds.iot.dianne.tensor.impl.th.THTensorMath be.iminds.iot.dianne.tensor.impl.th.THTensorFactory
SRC := THTensorFactoryJNI.c THTensorJNI.c THTensorMathJNI.c
INCLUDES := -I$(JAVA_HOME)/include/ -I/usr/lib/jvm -ITH
INCLUDES := -I$(JAVA_INCLUDE) -I$(JAVA_PLATFORMINCLUDE) -ITH
OBJECT := THTensorFactoryJNI.o THTensorJNI.o THTensorMathJNI.o
FLAGS := -O3 -w
LINKS := libTH.a libopenblas.a -lm -lgomp
LIB := libTHTensor.so
DEPLOY_DIR := ../../native/$(ARCH)
DEPLOY_DIR := ../../native/$(OS)/$(ARCH)

# cuda specific build parameters
CUDA_INCLUDES := -ITHC -I$(CUDA_HOME)/include/
Expand All @@ -32,29 +36,29 @@ cuda: INCLUDES += $(CUDA_INCLUDES)
cuda: LINKS = $(CUDA_LINKS)
cuda: FLAGS += $(CUDA_FLAGS)
cuda: OBJECT += $(CUDA_OBJECT)
cuda: DEPLOY_DIR := ../../cuda/$(ARCH)
cuda: DEPLOY_DIR := ../../cuda/$(OS)/$(ARCH)
cuda: cudaops libTHC.a install

javah:
for file in $(JAVAH) ; do \
javah -jni -classpath ../../bin $$file ; \
for file in $(JAVAH); do \
javah -jni -classpath ../../bin $$file; \
done

compile: javah
$(CC) $(FLAGS) -fPIC -DLINUX $(INCLUDES) -c $(SRC)
$(CC) $(FLAGS) $(CCFLAGS) -fPIC $(INCLUDES) -c $(SRC)

cudaops:
$(NVCC) $(NVCC_FLAGS) $(INCLUDES) -c $(CUDA_SRC)

link: compile
$(CC) $(FLAGS) -shared $(OBJECT) $(LINKS) -o $(LIB)
$(CC) $(FLAGS) $(CCFLAGS) $(SHARED) $(OBJECT) $(LINKS) -o $(LIB)

install: libopenblas.a libTH.a link
mkdir -p $(DEPLOY_DIR)
cp $(LIB) $(DEPLOY_DIR)/$(LIB)

test:
$(CXX) $(FLAGS) -DLINUX $(INCLUDES) -c Test.c
$(CXX) $(FLAGS) $(INCLUDES) -c Test.c
$(CXX) $(FLAGS) Test.o $(LINKS) -o test

libTH.a:
Expand Down
16 changes: 16 additions & 0 deletions be.iminds.iot.dianne.tensor/jni/THTensor/Makefile.Darwin
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#---------------------------------------------------------------------------
# Darwin settings
# Compiler
CC=gcc-5
CXX=g++-5
NVCC=nvcc
CCFLAGS += -DOSX -framework accelerate
LIB := libTHTensor.dylib
SHARED := -dynamiclib

JAVA_HOME ?= $(shell /usr/libexec/java_home)
# this is the subdirectory name in JAVA_HOME/include/ that contains platform-specific files
# it seems that some versions of Java 1.1 on linux need this to be "genunix"
JDKPLATFORMINCLUDESUBDIR := darwin

#---------------------------------------------------------------------------
16 changes: 16 additions & 0 deletions be.iminds.iot.dianne.tensor/jni/THTensor/Makefile.Linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#---------------------------------------------------------------------------
# Linux settings
# Compiler
CC=gcc
CXX=g++
NVCC=nvcc
CCFLAGS += -DLINUX
LIB := libTHTensor.so
SHARED := -shared

JAVA_HOME ?= /usr/lib/jvm/default-java
# this is the subdirectory name in JAVA_HOME/include/ that contains platform-specific files
# it seems that some versions of Java 1.1 on linux need this to be "genunix"
JDKPLATFORMINCLUDESUBDIR := linux

#---------------------------------------------------------------------------
Binary file not shown.
7 changes: 4 additions & 3 deletions be.iminds.iot.dianne.tensor/test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

NATIVE=native/x86_64/
ARCH=`uname -m`
OS=`uname -s`
NATIVE=native/$OS/$ARCH/

if [ $# -ne 0 ]; then
if [ $1 == "cuda" ]; then
NATIVE=cuda/x86_64/
NATIVE=cuda/$OS/$ARCH/
fi
fi

Expand Down
5 changes: 4 additions & 1 deletion be.iminds.iot.dianne.tensor/th.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ Import-Package: com.esotericsoftware.kryo.*;resolution:=optional
Bundle-Name: Dianne TH Tensor Library
Bundle-Description: Dianne Tensor implementation based on Torch's TH C lib

Bundle-NativeCode: x86_64/libTHTensor.so;osname=Linux;processor=x86_64,armv7l/libTHTensor.so;osname=Linux;processor=arm
Bundle-NativeCode: \
Linux/x86_64/libTHTensor.so;osname=Linux;processor=x86_64,\
Linux/armv7l/libTHTensor.so;osname=Linux;processor=arm,\
Darwin/x86_64/libTHTensor.dylib;osname=macosx;processor=x86_64

-includeresource: \
native

0 comments on commit 9e50bcf

Please sign in to comment.