From 672f228e63bf99e5c6b37b52f731b07217ecfd6f Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Tue, 13 Dec 2016 11:57:50 -0500 Subject: [PATCH 01/13] remove -j option (does not work on Windows) --- rocks/cutorch-scm-1.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocks/cutorch-scm-1.rockspec b/rocks/cutorch-scm-1.rockspec index 83143859..21196ba5 100644 --- a/rocks/cutorch-scm-1.rockspec +++ b/rocks/cutorch-scm-1.rockspec @@ -24,7 +24,7 @@ build = { jopts=$(getconf _NPROCESSORS_CONF) echo "Building on $jopts cores" -cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) -j$jopts install +cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) install ]], platforms = { windows = { From 7331cc3e6ccec17ddfc80a152b6ca17dc681ea2d Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Wed, 14 Dec 2016 16:36:13 -0500 Subject: [PATCH 02/13] fix wrong export directive for THCCachingHostAllocator --- lib/THC/THCCachingHostAllocator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/THC/THCCachingHostAllocator.h b/lib/THC/THCCachingHostAllocator.h index 2f2adc17..f2f54c7a 100644 --- a/lib/THC/THCCachingHostAllocator.h +++ b/lib/THC/THCCachingHostAllocator.h @@ -18,7 +18,7 @@ // Note that this allocator does not split larger allocations into smaller // blocks, unlike the caching device allocator. // -extern THAllocator THCCachingHostAllocator; +THC_API THAllocator THCCachingHostAllocator; // Records an event in the specified stream. The allocation 'ptr' will not be // re-used until the event has occured. From 79bff93d1255de0686e80dec16668b96516c7bcd Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Wed, 14 Dec 2016 16:51:31 -0500 Subject: [PATCH 03/13] restore -j option --- rocks/cutorch-scm-1.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocks/cutorch-scm-1.rockspec b/rocks/cutorch-scm-1.rockspec index 21196ba5..83143859 100644 --- a/rocks/cutorch-scm-1.rockspec +++ b/rocks/cutorch-scm-1.rockspec @@ -24,7 +24,7 @@ build = { jopts=$(getconf _NPROCESSORS_CONF) echo "Building on $jopts cores" -cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) install +cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) -j$jopts install ]], platforms = { windows = { From c859c922c28b86910a09996d44a2860074872d81 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 15 Dec 2016 11:19:02 -0500 Subject: [PATCH 04/13] fix missing cmake definitions Torch installation directories need to be propagated otherwise cutorch installs in the wrong directories (they default to lib, include,bin,etc and thus works on default installs) --- lib/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ebd35b92..ab78a589 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1 +1,6 @@ +SET(TH_INSTALL_BIN_SUBDIR "${Torch_INSTALL_BIN_SUBDIR}") +SET(TH_INSTALL_LIB_SUBDIR "${Torch_INSTALL_LIB_SUBDIR}") +SET(TH_INSTALL_INCLUDE_SUBDIR "${Torch_INSTALL_INCLUDE_SUBDIR}") +SET(TH_INSTALL_CMAKE_SUBDIR "${Torch_INSTALL_CMAKE_SUBDIR}") + ADD_SUBDIRECTORY(THC) From 0c3dd0ccc02f5f22e307b5c0e8fb0d8fa1e92275 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 15 Dec 2016 11:28:07 -0500 Subject: [PATCH 05/13] fix install directory logic now that install dirs are set properly in upstream CMakefile, they don't need to be reset here, plus the INCLUDE_DIRECTORIES and LINK_DIRECTORIES (lines 111,112) statement should be executed. --- lib/THC/CMakeLists.txt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/THC/CMakeLists.txt b/lib/THC/CMakeLists.txt index 34a45501..36865ddf 100644 --- a/lib/THC/CMakeLists.txt +++ b/lib/THC/CMakeLists.txt @@ -102,20 +102,15 @@ IF(NOT THC_INSTALL_BIN_SUBDIR OR NOT THC_INSTALL_INCLUDE_SUBDIR OR NOT THC_INSTALL_CMAKE_SUBDIR) - INCLUDE_DIRECTORIES(${TH_INCLUDE_PATH} ${TH_INCLUDE_PATH}/TH) - LINK_DIRECTORIES(${TH_LIB_PATH}) - SET(THC_INSTALL_BIN_SUBDIR "bin" CACHE PATH "THC install binary subdirectory") SET(THC_INSTALL_LIB_SUBDIR "lib" CACHE PATH "THC install library subdirectory") SET(THC_INSTALL_INCLUDE_SUBDIR "include" CACHE PATH "THC install include subdirectory") SET(THC_INSTALL_CMAKE_SUBDIR "share/cmake/THC" CACHE PATH "THC install cmake subdirectory") -ELSE() - SET(THC_INSTALL_BIN_SUBDIR ${Torch_INSTALL_BIN_SUBDIR}) - SET(THC_INSTALL_LIB_SUBDIR ${Torch_INSTALL_LIB_SUBDIR}) - SET(THC_INSTALL_INCLUDE_SUBDIR ${Torch_INSTALL_INCLUDE_SUBDIR}) - SET(THC_INSTALL_CMAKE_SUBDIR ${Torch_INSTALL_CMAKE_SUBDIR}) ENDIF() +INCLUDE_DIRECTORIES(${TH_INCLUDE_PATH} ${TH_INCLUDE_PATH}/TH) +LINK_DIRECTORIES(${TH_LIB_PATH}) + INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}") CONFIGURE_FILE(THCGeneral.h.in "${CMAKE_CURRENT_BINARY_DIR}/THCGeneral.h") From d3f478315745e7d591c977244ac424c92340fe90 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 15 Dec 2016 12:02:06 -0500 Subject: [PATCH 06/13] Update CMakeLists.txt --- lib/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ab78a589..257feeed 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,6 +1,6 @@ -SET(TH_INSTALL_BIN_SUBDIR "${Torch_INSTALL_BIN_SUBDIR}") -SET(TH_INSTALL_LIB_SUBDIR "${Torch_INSTALL_LIB_SUBDIR}") -SET(TH_INSTALL_INCLUDE_SUBDIR "${Torch_INSTALL_INCLUDE_SUBDIR}") -SET(TH_INSTALL_CMAKE_SUBDIR "${Torch_INSTALL_CMAKE_SUBDIR}") +SET(THC_INSTALL_BIN_SUBDIR "${Torch_INSTALL_BIN_SUBDIR}") +SET(THC_INSTALL_LIB_SUBDIR "${Torch_INSTALL_LIB_SUBDIR}") +SET(THC_INSTALL_INCLUDE_SUBDIR "${Torch_INSTALL_INCLUDE_SUBDIR}") +SET(THC_INSTALL_CMAKE_SUBDIR "${Torch_INSTALL_CMAKE_SUBDIR}") ADD_SUBDIRECTORY(THC) From bf1655a25d531fb21fbbf1cdf98ff07974b5b128 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 15 Dec 2016 12:09:27 -0500 Subject: [PATCH 07/13] Update CMakeLists.txt --- lib/THC/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/THC/CMakeLists.txt b/lib/THC/CMakeLists.txt index 36865ddf..6bbc0db1 100644 --- a/lib/THC/CMakeLists.txt +++ b/lib/THC/CMakeLists.txt @@ -190,6 +190,13 @@ IF(USE_MAGMA) TARGET_LINK_LIBRARIES(THC ${MAGMA_LIBRARIES} ${CUDA_cusparse_LIBRARY}) ENDIF(USE_MAGMA) +MESSAGE(STATUS "Installation subdirectories:") +MESSAGE(STATUS " bin=${THC_INSTALL_BIN_SUBDIR}") +MESSAGE(STATUS " lib=${THC_INSTALL_LIB_SUBDIR}") +MESSAGE(STATUS " include=${THC_INSTALL_INCLUDE_SUBDIR}") +MESSAGE(STATUS " cmake=${THC_INSTALL_CMAKE_SUBDIR}") + + INSTALL(TARGETS THC RUNTIME DESTINATION "${THC_INSTALL_BIN_SUBDIR}" LIBRARY DESTINATION "${THC_INSTALL_LIB_SUBDIR}" From 3878a229100765eafee3f01e445e7aa25b84b272 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 15 Dec 2016 12:16:52 -0500 Subject: [PATCH 08/13] Update CMakeLists.txt --- lib/THC/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/THC/CMakeLists.txt b/lib/THC/CMakeLists.txt index 6bbc0db1..237a7a5b 100644 --- a/lib/THC/CMakeLists.txt +++ b/lib/THC/CMakeLists.txt @@ -191,10 +191,10 @@ IF(USE_MAGMA) ENDIF(USE_MAGMA) MESSAGE(STATUS "Installation subdirectories:") -MESSAGE(STATUS " bin=${THC_INSTALL_BIN_SUBDIR}") -MESSAGE(STATUS " lib=${THC_INSTALL_LIB_SUBDIR}") -MESSAGE(STATUS " include=${THC_INSTALL_INCLUDE_SUBDIR}") -MESSAGE(STATUS " cmake=${THC_INSTALL_CMAKE_SUBDIR}") +MESSAGE(STATUS " bin=${CMAKE_INSTALL_PREFIX}/${THC_INSTALL_BIN_SUBDIR}") +MESSAGE(STATUS " lib=${CMAKE_INSTALL_PREFIX}/${THC_INSTALL_LIB_SUBDIR}") +MESSAGE(STATUS " include=${CMAKE_INSTALL_PREFIX}/${THC_INSTALL_INCLUDE_SUBDIR}") +MESSAGE(STATUS " cmake=${CMAKE_INSTALL_PREFIX}/${THC_INSTALL_CMAKE_SUBDIR}") INSTALL(TARGETS THC From 48ca4cfb7a23bbfa2cd6df6f08b4d69ef75909e0 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Wed, 21 Dec 2016 21:43:01 -0500 Subject: [PATCH 09/13] Add THC_EXPORTS flag to windows build to export THC symbols --- lib/THC/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/THC/CMakeLists.txt b/lib/THC/CMakeLists.txt index 237a7a5b..cf90b8bb 100644 --- a/lib/THC/CMakeLists.txt +++ b/lib/THC/CMakeLists.txt @@ -89,6 +89,13 @@ IF(APPLE) # CUDA 7 supports clang and libc++ so no need to change anything ENDIF(APPLE) +# Flags +# When using MSVC +IF(MSVC) + # we want to respect the standard, and we are bored of those **** . + ADD_DEFINITIONS(-DTHC_EXPORTS=1) +ENDIF(MSVC) + # Detect CUDA architecture and get best NVCC flags IF(NOT COMMAND CUDA_SELECT_NVCC_ARCH_FLAGS OR MSVC) INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/select_compute_arch.cmake) From ff00c04140d432a60135999e1ea7c8152c8350f8 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Wed, 21 Dec 2016 21:44:10 -0500 Subject: [PATCH 10/13] Update CMakeLists.txt --- lib/THC/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/THC/CMakeLists.txt b/lib/THC/CMakeLists.txt index cf90b8bb..66530b55 100644 --- a/lib/THC/CMakeLists.txt +++ b/lib/THC/CMakeLists.txt @@ -89,10 +89,9 @@ IF(APPLE) # CUDA 7 supports clang and libc++ so no need to change anything ENDIF(APPLE) -# Flags # When using MSVC IF(MSVC) - # we want to respect the standard, and we are bored of those **** . + # dll export flag ADD_DEFINITIONS(-DTHC_EXPORTS=1) ENDIF(MSVC) From 63c91984245268daf3b5576483cff467a1db2a00 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 1 Jun 2017 18:12:50 -0400 Subject: [PATCH 11/13] fix rockspec --- rocks/cutorch-scm-1.rockspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rocks/cutorch-scm-1.rockspec b/rocks/cutorch-scm-1.rockspec index 5dbdfbe8..16782eee 100644 --- a/rocks/cutorch-scm-1.rockspec +++ b/rocks/cutorch-scm-1.rockspec @@ -23,13 +23,13 @@ build = { jopts=$(getconf _NPROCESSORS_CONF) -echo "Building on $jopts cores" -cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DLUA_INCDIR=$(LUA_INCDIR) -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) -j$jopts install +echo "Building on $(jopts) cores" +cmake -E make_directory build && cd build && cmake .. -DLUALIB="$(LUALIB)" -DLUA_INCDIR="$(LUA_INCDIR)" -DCMAKE_CXX_FLAGS="$(CMAKE_CXX_FLAGS)" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) -j$jopts install ]], platforms = { windows = { build_command = [[ -cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DLUA_INCDIR=$(LUA_INCDIR) -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) install +cmake -E make_directory build && cd build && cmake .. -DLUALIB="" -DLUA_INCDIR="$(LUA_INCDIR)" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE) install ]] } }, From 33935a11b8a61be8502ba5ffedb2fda120fbb14f Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 1 Jun 2017 20:28:07 -0400 Subject: [PATCH 12/13] cutorch cmake needs lua_libdir --- CMakeLists.txt | 3 ++- rocks/cutorch-scm-1.rockspec | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d3ece71..c406ea83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,8 @@ INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/torch") SET(src Storage.c init.c Tensor.c TensorMath.c TensorOperator.c torch/utils.c) SET(luasrc init.lua Tensor.lua FFI.lua test/test.lua) -set(CMAKE_REQUIRED_INCLUDES ${LUA_INCDIR}) +set(CMAKE_REQUIRED_INCLUDES ${LUA_INCDIR}) +set(CMAKE_REQUIRED_LIBRARIES ${LUA_LIBDIR}) include(CheckCSourceCompiles) check_c_source_compiles(" #include diff --git a/rocks/cutorch-scm-1.rockspec b/rocks/cutorch-scm-1.rockspec index 16782eee..66492c1b 100644 --- a/rocks/cutorch-scm-1.rockspec +++ b/rocks/cutorch-scm-1.rockspec @@ -2,14 +2,14 @@ package = "cutorch" version = "scm-1" source = { - url = "git://github.com/torch/cutorch.git", + url = "git://github.com/elikosan/cutorch.git", } description = { summary = "Torch CUDA Implementation", detailed = [[ ]], - homepage = "https://github.com/torch/cutorch", + homepage = "https://github.com/elikosan/cutorch", license = "BSD" } From b14e26552e2cfafabc67c433971268b4e6d750ca Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Thu, 1 Jun 2017 20:36:46 -0400 Subject: [PATCH 13/13] cutorch cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c406ea83..e14caf7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ SET(src Storage.c init.c Tensor.c TensorMath.c TensorOperator.c torch/utils.c) SET(luasrc init.lua Tensor.lua FFI.lua test/test.lua) set(CMAKE_REQUIRED_INCLUDES ${LUA_INCDIR}) -set(CMAKE_REQUIRED_LIBRARIES ${LUA_LIBDIR}) +set(CMAKE_REQUIRED_LIBRARIES ${LUA_LIBDIR}/${LUALIB}) include(CheckCSourceCompiles) check_c_source_compiles(" #include