Skip to content

Commit

Permalink
improvement based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
BTNC committed Nov 4, 2016
1 parent bac29c2 commit db39706
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 83 deletions.
33 changes: 1 addition & 32 deletions clean.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,14 @@ set TORCH_DISTRO=%~dp0.
for /d %%G in ("%TORCH_DISTRO%\win-files\3rd\wineditline-*") do rmdir /s /q "%%~G"\build
cd %TORCH_DISTRO%\win-files\3rd\dlfcn-win32 && git clean -fdx

cd %TORCH_DISTRO%\exe\luajit-rocks && git clean -fdx
cd %TORCH_DISTRO%\exe\lua-5.1.5 && del /q *.obj *.o *.lib *.dll *.exp *.exe
cd %TORCH_DISTRO%\exe\lua-5.2.4 && del /q *.obj *.o *.lib *.dll *.exp *.exe
cd %TORCH_DISTRO%\exe\lua-5.3.3 && del /q *.obj *.o *.lib *.dll *.exp *.exe
cd %TORCH_DISTRO%\exe\luajit-2.0 && git clean -fdx
cd %TORCH_DISTRO%\exe\luajit-2.1 && git clean -fdx
cd %TORCH_DISTRO%\exe\luarocks && git clean -fdx

cd %TORCH_DISTRO%\extra\luafilesystem && git clean -fdx
cd %TORCH_DISTRO%\extra\penlight && git clean -fdx
cd %TORCH_DISTRO%\extra\lua-cjson && git clean -fdx

cd %TORCH_DISTRO%\extra\luaffifb && git clean -fdx
cd %TORCH_DISTRO%\pkg\sundown && git clean -fdx
cd %TORCH_DISTRO%\pkg\cwrap && git clean -fdx
cd %TORCH_DISTRO%\pkg\paths && git clean -fdx
cd %TORCH_DISTRO%\pkg\torch && git clean -fdx
cd %TORCH_DISTRO%\pkg\dok && git clean -fdx
cd %TORCH_DISTRO%\pkg\sys && git clean -fdx
cd %TORCH_DISTRO%\exe\trepl && git clean -fdx
cd %TORCH_DISTRO%\pkg\xlua && git clean -fdx
cd %TORCH_DISTRO%\extra\nn && git clean -fdx
cd %TORCH_DISTRO%\extra\graph && git clean -fdx
cd %TORCH_DISTRO%\extra\nngraph && git clean -fdx
cd %TORCH_DISTRO%\pkg\image && git clean -fdx
cd %TORCH_DISTRO%\pkg\optim && git clean -fdx

cd %TORCH_DISTRO%\extra\cutorch && git clean -fdx
cd %TORCH_DISTRO%\extra\cunn && git clean -fdx

cd %TORCH_DISTRO%\pkg\gnuplot && git clean -fdx
cd %TORCH_DISTRO%\exe\env && git clean -fdx
cd %TORCH_DISTRO%\extra\nnx && git clean -fdx
cd %TORCH_DISTRO%\exe\qtlua && git clean -fdx
cd %TORCH_DISTRO%\pkg\qttorch && git clean -fdx
cd %TORCH_DISTRO%\extra\threads && git clean -fdx
cd %TORCH_DISTRO%\extra\argcheck && git clean -fdx

cd %TORCH_DISTRO%\extra\cudnn && git clean -fdx
cd %TORCH_DISTRO% && git submodule foreach --recursive git clean -fdx

echo Cleaning is finished
@endlocal
47 changes: 32 additions & 15 deletions install-deps.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
REM set TORCH_LUA_VERSION=LUAJIT21

:: where to install Torch7, default to install\ under distro\
REM set TORCH_INSTALL_DIR=install
REM set TORCH_INSTALL_DIR=D:\Torch\

:: conda environment name for Torch7, default to torch
REM set TORCH_CONDA_ENV=torch
:: conda environment name for Torch7, default to torch-vcversion
REM set TORCH_CONDA_ENV=mytorch7

:: which blas/lapack libraries will be used, default to openblas installed by conda
:: [1] mkl: download from https://software.intel.com/intel-mkl, install and set following two variables
Expand All @@ -25,7 +25,7 @@ REM set INTEL_COMPILER_DIR=D:\\Intel\\SWTools\\compilers_and_libraries\\windows
:: [2] other: set path to the blas library and path to the laback library
:: both BLAS and LAPACK should be set even if they refer to the same library
:: take openblas for example: download latest release from https://github.com/xianyi/OpenBLAS/releases/latest
:: use mingw cross compiler tools in cygwin, since mingw windows native gfortrain is available in cygwin but not msys2
:: use mingw cross compiler tools in cygwin, since mingw windows native gfortrain is available in cygwin but not in msys2
:: compilation command in cygwin: make CC=x86_64-w64-mingw32-gcc FC=x86_64-w64-mingw32-gfortran CROSS_SUFFIX=x86_64-w64-mingw32-
:: please refer to openblas's README for detailed installation instructions
REM set BLAS_LIBRARIES=D:\\Libraries\\lib\libopenblas.dll.a
Expand Down Expand Up @@ -74,13 +74,12 @@ if "%PreferredToolArchitecture%" == "x64" (
if "%CommandPromptType%" == "Native" (
if "%Platform%" == "X64" set TORCH_VS_PLATFORM=x64
)
if "%Platform%" == "" set TORCH_VS_PLATFORM=x86
if "%Platform%" == "" set TORCH_VS_PLATFORM=x86
)

if not "%TORCH_VS_PLATFORM%"=="x64" if not "%TORCH_VS_PLATFORM%"=="x86" (
echo %ECHO_PREFIX% It is suggested to compile x64 or x86 Torch7 directly instead of cross compilation %TORCH_VS_PLATFORM%
pause
)
if "%TORCH_VS_PLATFORM%" == "x86" set TORCH_VS_TOOL=x86
if not "%TORCH_VS_PLATFORM%" == "%TORCH_VS_PLATFORM:x86_=%" set TORCH_VS_TOOL=x86
if "%TORCH_VS_TOOL%" == "" set TORCH_VS_TOOL=x64

:::: validate lua version ::::

Expand Down Expand Up @@ -165,6 +164,17 @@ if "%CONDA_CMD%" == "" (
goto :NO_CONDA
)

set TORCH_CONDA_INFO=%TORCH_DISTRO%\win-files\check_conda_info_for_torch.txt
conda info > %TORCH_CONDA_INFO%
if "%TORCH_VS_TOOL%" == "x64" set TORCH_CONDA_PLATFORM=win-64
if "%TORCH_VS_TOOL%" == "x86" set TORCH_CONDA_PLATFORM=win-86

findstr "%TORCH_CONDA_PLATFORM%" "%TORCH_CONDA_INFO%" >nul
if errorlevel 1 (
echo %ECHO_PREFIX% %TORCH_VS_TOOL% Torch7 requires %TORCH_CONDA_PLATFORM% conda, installation will continue without conda
goto :NO_CONDA
)

if %TORCH_VS_VERSION% GEQ 14 ( set CONDA_VS_VERSION=14&& goto :CONDA_SETUP )
if %TORCH_VS_VERSION% GEQ 10 ( set CONDA_VS_VERSION=10&& goto :CONDA_SETUP )
set CONDA_VS_VERSION=9
Expand Down Expand Up @@ -207,11 +217,18 @@ goto :AFTER_OPENBLAS

:CONDA_INSTALL_OPENBLAS
echo %ECHO_PREFIX% Installing openblas by conda, since there is no blas library specified
conda install -n %TORCH_CONDA_ENV% -c omnia openblas --yes || goto :Fail
if "%TORCH_VS_TOOL%" == "x64" conda install -n %TORCH_CONDA_ENV% -c ukoethe openblas --yes || goto :Fail
if "%TORCH_VS_TOOL%" == "x86" conda install -n %TORCH_CONDA_ENV% -c omnia openblas --yes || goto :Fail

:AFTER_OPENBLAS
if "%BLAS_LIBRARIES%" == "" set BLAS_LIBRARIES=%TORCH_CONDA_LIBRARY%\\lib\\libopenblaspy.dll.a
if "%LAPACK_LIBRARIES%" == "" set LAPACK_LIBRARIES=%TORCH_CONDA_LIBRARY%\\lib\\libopenblaspy.dll.a
if "%TORCH_VS_TOOL%" == "x64" (
if "%BLAS_LIBRARIES%" == "" set BLAS_LIBRARIES=%TORCH_CONDA_LIBRARY%\\lib\\libopenblas.lib
if "%LAPACK_LIBRARIES%" == "" set LAPACK_LIBRARIES=%TORCH_CONDA_LIBRARY%\\lib\\libopenblas.lib
)
if "%TORCH_VS_TOOL%" == "x86" (
if "%BLAS_LIBRARIES%" == "" set BLAS_LIBRARIES=%TORCH_CONDA_LIBRARY%\\lib\\libopenblaspy.dll.a
if "%LAPACK_LIBRARIES%" == "" set LAPACK_LIBRARIES=%TORCH_CONDA_LIBRARY%\\lib\\libopenblaspy.dll.a
)

:: other dependencies
findstr "jpeg" "%TORCH_CONDA_PKGS%" >nul
Expand All @@ -225,14 +242,14 @@ if errorlevel 1 set TORCH_DEPENDENCIES=%TORCH_DEPENDENCIES% libxml2
findstr "qt" "%TORCH_CONDA_PKGS%" >nul
if errorlevel 1 set TORCH_DEPENDENCIES=%TORCH_DEPENDENCIES% qt=4.8.7

del /q %TORCH_CONDA_PKGS%

if not "%TORCH_DEPENDENCIES%" == "" (
echo %ECHO_PREFIX% Installing %TORCH_DEPENDENCIES% by conda for Torch7
conda install -n %TORCH_CONDA_ENV% -c conda-forge %TORCH_DEPENDENCIES% --yes
)

:NO_CONDA
del /q %TORCH_CONDA_INFO%
del /q %TORCH_CONDA_PKGS%

:::: git clone luarocks ::::

Expand Down Expand Up @@ -297,7 +314,7 @@ cd %TORCH_DISTRO%\win-files\3rd\
wget -nc https://sourceforge.net/projects/mingweditline/files/latest --no-check-certificate -O wineditline.zip
7z x wineditline.zip -y >NUL
cd wineditline*
cmake -E make_directory build && cd build && cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\ && nmake install
cmake -E make_directory build && cd build && cmake .. -G "NMake Makefiles" -DLIB_SUFFIX="64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\ && nmake install

:::: install dlfcn-win32 ::::
echo %ECHO_PREFIX% Installing dlfcn-win32 for thread package
Expand Down
12 changes: 4 additions & 8 deletions install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo %ECHO_PREFIX% Updating submodules
git submodule update --init --recursive

:: [TODO] this part should be removed after distro/master is updated to point to the patched version
for %%i in (pkg\sundown pkg\paths exe\trepl pkg\sys extra\graph extra\nngraph) do (
for %%i in (pkg\sundown pkg\paths exe\trepl pkg\sys extra\graph extra\nngraph extra\threads pkg\torch) do (
cd %TORCH_DISTRO%\%%i
git checkout origin/master
git pull origin master
Expand All @@ -37,11 +37,7 @@ if "%TORCH_SETUP_HAS_MKL%" == "1" (
cd %TORCH_DISTRO%\pkg\torch && git apply %PATCH_DIR%\torch.patch --whitespace=fix & ( call %LUAROCKS_CMD% make rocks\torch-scm-1.rockspec BLAS_LIBRARIES="%BLAS_LIBRARIES%" LAPACK_LIBRARIES="%LAPACK_LIBRARIES%" LAPACK_FOUND=TRUE || goto :FAIL ) & git apply %PATCH_DIR%\torch.patch --reverse --whitespace=fix
)
cd %TORCH_DISTRO%\pkg\dok && call %LUAROCKS_CMD% make rocks\dok-scm-1.rockspec || goto :FAIL
if "%TORCH_VS_PLATFORM%" == "x86" (
cd %TORCH_DISTRO%\exe\trepl && git apply %PATCH_DIR%\trepl.x86.patch --whitespace=fix & ( call %LUAROCKS_CMD% make trepl-scm-1.rockspec || goto :FAIL ) & git apply %PATCH_DIR%\trepl.x86.patch --reverse --whitespace=fix
) else (
cd %TORCH_DISTRO%\exe\trepl && call %LUAROCKS_CMD% make trepl-scm-1.rockspec || goto :FAIL
)
cd %TORCH_DISTRO%\exe\trepl && call %LUAROCKS_CMD% make trepl-scm-1.rockspec || goto :FAIL
cd %TORCH_DISTRO%\pkg\sys && call %LUAROCKS_CMD% make sys-1.1-0.rockspec || goto :FAIL
cd %TORCH_DISTRO%\pkg\xlua && call %LUAROCKS_CMD% make xlua-1.0-0.rockspec || goto :FAIL
cd %TORCH_DISTRO%\extra\nn && call %LUAROCKS_CMD% make rocks\nn-scm-1.rockspec || goto :FAIL
Expand All @@ -50,7 +46,7 @@ cd %TORCH_DISTRO%\extra\nngraph && call %LUAROCKS_CMD% make nngraph-scm-1.rocksp
cd %TORCH_DISTRO%\pkg\image && call %LUAROCKS_CMD% make image-1.1.alpha-0.rockspec || goto :FAIL
cd %TORCH_DISTRO%\pkg\optim && call %LUAROCKS_CMD% make optim-1.0.5-0.rockspec || goto :FAIL

if not "%TORCH_SETUP_HAS_CUDA%" == "" if not "%TORCH_VS_PLATFORM%" == "x86" (
if not "%TORCH_SETUP_HAS_CUDA%" == "" if not "%TORCH_VS_TOOL%" == "x86" (
echo %ECHO_PREFIX% Found CUDA on your machine. Installing CUDA packages
cd %TORCH_DISTRO%\extra\cutorch && call %LUAROCKS_CMD% make rocks\cutorch-scm-1.rockspec || goto :FAIL
cd %TORCH_DISTRO%\extra\cunn && git apply %TORCH_DISTRO%\win-files\patch\cunn.patch --whitespace=fix & ( call %LUAROCKS_CMD% make rocks\cunn-scm-1.rockspec || goto :FAIL ) & git apply %TORCH_DISTRO%\win-files\patch\cunn.patch --reverse --whitespace=fix
Expand All @@ -65,7 +61,7 @@ cd %TORCH_DISTRO%\pkg\qttorch && call %LUAROCKS_CMD% make rocks\qttorch-scm-1.ro
cd %TORCH_DISTRO%\extra\threads && call %LUAROCKS_CMD% make rocks\threads-scm-1.rockspec WIN_DLFCN_INCDIR=%WIN_DLFCN_INCDIR% WIN_DLFCN_LIBDIR=%WIN_DLFCN_LIBDIR%
cd %TORCH_DISTRO%\extra\argcheck && call %LUAROCKS_CMD% make rocks\argcheck-scm-1.rockspec

if not "%TORCH_SETUP_HAS_CUDA%" == "" if not "%TORCH_VS_PLATFORM%" == "x86" (
if not "%TORCH_SETUP_HAS_CUDA%" == "" if not "%TORCH_VS_TOOL%" == "x86" (
echo %ECHO_PREFIX% Found CUDA on your machine. Installing optional CUDA packages
cd %TORCH_DISTRO%\extra\cudnn && git apply %TORCH_DISTRO%\win-files\patch\cudnn.patch --whitespace=fix & call %LUAROCKS_CMD% make cudnn-scm-1.rockspec & git apply %TORCH_DISTRO%\win-files\patch\cudnn.patch --reverse --whitespace=fix
)
Expand Down
33 changes: 31 additions & 2 deletions win-files/patch/lua-cjson.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
diff --git a/fpconv.h b/fpconv.h
index 7b0d0ee..f674e41 100644
--- a/fpconv.h
+++ b/fpconv.h
@@ -4,6 +4,10 @@
*
* Longest double printed with %.14g is 21 characters long:
* -1.7976931348623e+308 */
+#ifdef _MSC_VER
+#define inline __inline
+#define snprintf _snprintf
+#endif
# define FPCONV_G_FMT_BUFSIZE 32

#ifdef USE_INTERNAL_FPCONV
diff --git a/lua-cjson-2.1devel-1.rockspec b/lua-cjson-2.1devel-1.rockspec
index 154e333..ae25872 100644
index 154e333..0f7652e 100644
--- a/lua-cjson-2.1devel-1.rockspec
+++ b/lua-cjson-2.1devel-1.rockspec
@@ -47,6 +47,7 @@ build = {
-- Override default build options (per platform)
platforms = {
win32 = { modules = { cjson = { defines = {
+ "strncasecmp=strnicmp",
+ "strncasecmp=_strnicmp",
"DISABLE_INVALID_NUMBERS"
} } } }
},
Expand Down Expand Up @@ -36,3 +51,17 @@ index ac779e4..c3272f0 100644
}

s->size = newsize;
diff --git a/strbuf.h b/strbuf.h
index d861108..b135560 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -24,6 +24,9 @@

#include <stdlib.h>
#include <stdarg.h>
+#ifdef _MSC_VER
+#define inline __inline
+#endif

/* Size: Total bytes allocated to *buf
* Length: String length, excluding optional NULL terminator.
13 changes: 0 additions & 13 deletions win-files/patch/torch.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
diff --git a/lib/TH/THDiskFile.c b/lib/TH/THDiskFile.c
index 2ded7bd..ad81b2e 100644
--- a/lib/TH/THDiskFile.c
+++ b/lib/TH/THDiskFile.c
@@ -2,7 +2,7 @@
#include "THDiskFile.h"
#include "THFilePrivate.h"

-#ifdef _WIN64
+#ifdef _MSC_VER
#include <stdint.h>
#endif

diff --git a/lib/luaT/luaT.c b/lib/luaT/luaT.c
index 95166ed..2dc307a 100644
--- a/lib/luaT/luaT.c
Expand Down
13 changes: 0 additions & 13 deletions win-files/patch/trepl.x86.patch

This file was deleted.

0 comments on commit db39706

Please sign in to comment.