Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow torch to link with Intel MKL _ilp64 model (large integers) #1040

Open
wants to merge 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
caf5a61
fix compilation issues under Windows
elikosan May 20, 2016
8fe85b5
Update torch-scm-1.rockspec
elikosan May 20, 2016
c7fbe8f
m.lib not found/necessary under Windows
elikosan May 20, 2016
8efe159
remove m.lib from list of required MKL blas libs for Windows
elikosan May 27, 2016
4d6ea12
FindMKL.cmake typo
elikosan May 27, 2016
62e51be
restore torch in rockspec
elikosan May 31, 2016
76cb36c
define ssize_t on Windows
elikosan Jun 1, 2016
3bce1c8
define ssize_t on Windows
elikosan Jun 1, 2016
be729d6
define ssize_t on Windows
elikosan Jun 1, 2016
7d4a2e8
Merge pull request #1 from torch/master
elikosan Jun 2, 2016
89ab8e4
support for MKL ilp64
elikosan Dec 6, 2016
933ff33
support for MKL ilp64
elikosan Dec 6, 2016
2118356
blas decl compat with ilp64 model
elikosan Dec 7, 2016
c8951bd
make ilp64 patch work on Windows
elikosan Dec 7, 2016
e4a8557
define MKL_ILP64
elikosan Dec 7, 2016
ba78c0f
avoid crashing on Windows with ilp64
elikosan Dec 12, 2016
8ed047a
use MKL_LP64 compiler flag to trigger 32bit ints on 64bits platforms
elikosan Dec 12, 2016
980eb85
Merge pull request #2 from torch/master
elikosan Dec 13, 2016
a87827f
Merge remote-tracking branch 'refs/remotes/torch/master'
elikosan Mar 2, 2017
3777373
uninitialized variable
elikosan Mar 3, 2017
8c7f188
fix broken link, rephrase ugly sentence.
elikosan Mar 9, 2017
211a321
Update THStorage.c
elikosan Mar 17, 2017
281699f
Update THStorage.c
elikosan Mar 17, 2017
d255c20
Update THStorage.c
elikosan Mar 17, 2017
3ea6595
Update THStorage.c
elikosan Mar 17, 2017
e6999a4
Update THStorage.c
elikosan Mar 17, 2017
f896da1
Update THStorage.c
elikosan Mar 17, 2017
b72d4d1
Merge pull request #3 from torch/master
elikosan Mar 17, 2017
a05a3d9
missing dllexport for Windows!
elikosan Mar 17, 2017
1b94d52
missing dllexport for Windows!
elikosan Mar 17, 2017
97c39e5
missing include
elikosan Mar 20, 2017
ca226c4
missing include
elikosan Mar 20, 2017
42ec69f
Update AVX.c
elikosan Mar 20, 2017
db90eaa
remove ifdef __AVX__
elikosan Mar 20, 2017
259b222
remove ifdef __AVX2__
elikosan Mar 20, 2017
48da138
revert
elikosan Apr 3, 2017
0293729
revert
elikosan Apr 3, 2017
3fb5afc
update from master
elikosan Apr 3, 2017
d3999bc
revert
elikosan Apr 3, 2017
2777b04
revert
elikosan Apr 3, 2017
22f1f3f
Merge pull request #4 from torch/master
elikosan Apr 3, 2017
887b734
Merge pull request #5 from torch/master
elikosan May 8, 2017
d92e185
uninitialized variable
elikosan May 8, 2017
f5fa798
fix dead link + rewrite sentence
elikosan May 8, 2017
1226210
Implement lgamma function.
ethanluoyc Apr 20, 2017
97a97c2
Add a keepdim parameter for reduction functions over a single dimension.
gchanan May 3, 2017
aea5e73
Add keepdim to lua cwrap. (#1025)
gchanan May 9, 2017
cba53b2
Ensuring float tensors call float versions of math functions
pavanky May 11, 2017
091b481
Merge pull request #7 from torch/master
elikosan May 12, 2017
0da8686
mkl 64 now installs in intel64
elikosan May 19, 2017
0b95e88
add debug message
elikosan May 19, 2017
7d3ae23
more debugging messages
elikosan May 19, 2017
dda382e
add default value to Intel MKL dirs from environment variables
elikosan May 19, 2017
49cdd28
tell cmake find_library about prefix and suffix
elikosan May 19, 2017
345f39d
add trailing /
elikosan May 19, 2017
b778edb
fix 32/64 bits int issues with Windows
elikosan May 17, 2017
0da3807
allow 32 or 64 bit MKL to be linked
elikosan May 17, 2017
0ee11e3
add MKL_ILP64 flag in cmake
elikosan May 17, 2017
befd78d
allow link to MKL_ILP64 model
elikosan May 24, 2017
2985240
pass MKL_ILP64 environment variable to cmake
elikosan May 24, 2017
4bce3f4
findmkl .cmake typo
elikosan May 24, 2017
f7e397e
findblas.cmake add MKL_ILP64
elikosan May 24, 2017
95d02cc
fix typo
elikosan May 24, 2017
b3b2cf3
add compile to cmake f2c test
elikosan May 24, 2017
6782b83
debug
elikosan May 24, 2017
d5b1f60
debug
elikosan May 24, 2017
4a6a02d
debug
elikosan May 24, 2017
04c6899
debug
elikosan May 24, 2017
942b683
debug
elikosan May 24, 2017
aaec8bb
debug
elikosan May 24, 2017
4f690e7
debug
elikosan May 24, 2017
05558b4
debug
elikosan May 24, 2017
23a2a00
debug
elikosan May 24, 2017
c0672d9
debug
elikosan May 24, 2017
122f16c
debug
elikosan May 24, 2017
1a15395
remove ; in #define
elikosan May 25, 2017
99efc93
merge from torch master (#8)
elikosan Jun 1, 2017
367d695
Merge pull request #9 from torch/master
elikosan Jun 1, 2017
a1f5c11
add b32/b64 modes to torch.save
elikosan Jan 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions File.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,21 @@ function File:readObject()
end
end

-- simple helpers to save/load arbitrary objects/tables
-- simple helpers to save/load arbitrary objects/tables
function torch.save(filename, object, mode, referenced)
assert(mode == nil or mode == 'binary' or mode == 'ascii', '"binary" or "ascii" (or nil) expected for mode')
assert(mode == nil or mode == 'binary' or mode == 'b32' or mode == 'b64' or mode == 'ascii', '"binary" or "ascii" (or nil) expected for mode')
assert(referenced == nil or referenced == true or referenced == false, 'true or false (or nil) expected for referenced')
local longSize
if mode == 'b32' or mode == 'b64' then
longSize = tonumber(mode:match('%d+')) / 8
mode = 'binary'
end
mode = mode or 'binary'
referenced = referenced == nil and true or referenced
local file = torch.DiskFile(filename, 'w')
file[mode](file)
file:referenced(referenced)
if longSize then file:longSize(longSize) end
file:writeObject(object)
file:close()
end
Expand Down
1 change: 1 addition & 0 deletions lib/TH/THGeneral.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#cmakedefine USE_BLAS
#cmakedefine USE_LAPACK
#cmakedefine BLAS_F2C
#cmakedefine MKL_ILP64

#ifdef __cplusplus
# define TH_EXTERNC extern "C"
Expand Down
11 changes: 11 additions & 0 deletions lib/TH/THLapack.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ if (info < 0) { \
THError(fmt, func, info, ##__VA_ARGS__); \
}

#ifdef MKL_ILP64
// set 64 bit MKL integer type
#if (!defined(__INTEL_COMPILER)) & defined(_MSC_VER)
#define LAPACK_INT __int64
#else
#define LAPACK_INT long long int
#endif
#else
#define LAPACK_INT int
#endif

#include "generic/THLapack.h"
#include "THGenerateAllTypes.h"

Expand Down
58 changes: 48 additions & 10 deletions lib/TH/cmake/FindBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -242,32 +242,70 @@ endif()
# Determine if blas was compiled with the f2c conventions
IF (BLAS_LIBRARIES)
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
CHECK_C_SOURCE_RUNS("
IF (MKL_ILP64)
SET(CMAKE_REQUIRED_DEFINITIONS -DMKL_ILP64)
MESSAGE(STATUS "Checking F2C with MKL ILP64 ${CMAKE_REQUIRED_DEFINITIONS}")
ENDIF(MKL_ILP64)

set(f2c_code_d "
#include <stdlib.h>
#include <stdio.h>
float x[4] = { 1, 2, 3, 4 };
float y[4] = { .1, .01, .001, .0001 };
int four = 4;
int one = 1;
#ifdef MKL_ILP64
#if (!defined(__INTEL_COMPILER)) & defined(_MSC_VER)
#define BLAS_INT __int64
#else
#define BLAS_INT long long
#endif
#else
#define BLAS_INT int
#endif
BLAS_INT four = 4;
BLAS_INT one = 1;
extern double sdot_();
int main() {
int i;
double r = sdot_(&four, x, &one, y, &one);
exit((float)r != (float).1234);
}" BLAS_F2C_DOUBLE_WORKS )
CHECK_C_SOURCE_RUNS("
}" )

CHECK_C_SOURCE_COMPILES("${f2c_code_d}" BLAS_F2C_DOUBLE_COMPILES )
IF (NOT BLAS_F2C_DOUBLE_COMPILES)
MESSAGE(STATUS "Warning F2C double check did not compile!!")
MESSAGE(STATUS "${f2c_code_d}")
ENDIF(NOT BLAS_F2C_DOUBLE_COMPILES)

CHECK_C_SOURCE_RUNS("${f2c_code_d}" BLAS_F2C_DOUBLE_WORKS )

set(f2c_code_f "
#include <stdlib.h>
#include <stdio.h>
float x[4] = { 1, 2, 3, 4 };
float y[4] = { .1, .01, .001, .0001 };
int four = 4;
int one = 1;
#ifdef MKL_ILP64
#if (!defined(__INTEL_COMPILER)) & defined(_MSC_VER)
#define BLAS_INT __int64
#else
#define BLAS_INT long long
#endif
#else
#define BLAS_INT int
#endif
BLAS_INT four = 4;
BLAS_INT one = 1;
extern float sdot_();
int main() {
int i;
double r = sdot_(&four, x, &one, y, &one);
exit((float)r != (float).1234);
}" BLAS_F2C_FLOAT_WORKS )
}" )

CHECK_C_SOURCE_COMPILES("${f2c_code_f}" BLAS_F2C_FLOAT_COMPILES )
IF (NOT BLAS_F2C_FLOAT_COMPILES)
MESSAGE(STATUS "Warning F2C float check did not compile!!")
ENDIF(NOT BLAS_F2C_FLOAT_COMPILES)

CHECK_C_SOURCE_RUNS("${f2c_code_f}" BLAS_F2C_FLOAT_WORKS )

IF (BLAS_F2C_DOUBLE_WORKS AND NOT BLAS_F2C_FLOAT_WORKS)
MESSAGE(STATUS "This BLAS uses the F2C return conventions")
SET(BLAS_F2C TRUE)
Expand Down
41 changes: 33 additions & 8 deletions lib/TH/cmake/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,27 @@ INCLUDE(CheckTypeSize)
INCLUDE(CheckFunctionExists)

# Intel Compiler Suite
SET(INTEL_COMPILER_DIR CACHE STRING
SET(INTEL_COMPILER_DIR $ENV{INTEL_COMPILER_DIR} CACHE STRING
"Root directory of the Intel Compiler Suite (contains ipp, mkl, etc.)")
SET(INTEL_MKL_DIR CACHE STRING
SET(INTEL_MKL_DIR $ENV{INTEL_MKL_DIR} CACHE STRING
"Root directory of the Intel MKL (standalone)")
SET(MKL_ILP64 $ENV{MKL_ILP64} CACHE STRING
"Link with 64bit-interger version of MKL (_ilp64 instead of _lp64)")
SET(INTEL_MKL_SEQUENTIAL OFF CACHE BOOL
"Force using the sequential (non threaded) libraries")

MESSAGE(STATUS "INTEL_MKL_DIR: ${INTEL_MKL_DIR}")

# Checks
CHECK_TYPE_SIZE("void*" SIZE_OF_VOIDP)
IF ("${SIZE_OF_VOIDP}" EQUAL 8)
SET(mklvers "em64t")
SET(mklvers "intel64")
SET(iccvers "intel64")
SET(mkl64s "_lp64")
IF (MKL_ILP64)
SET(mkl64s "_ilp64")
ELSE(MKL_ILP64)
SET(mkl64s "_lp64")
ENDIF(MKL_ILP64)
ELSE ("${SIZE_OF_VOIDP}" EQUAL 8)
SET(mklvers "32")
SET(iccvers "ia32")
Expand Down Expand Up @@ -80,15 +88,26 @@ ENDIF (INTEL_COMPILER_DIR)
IF (INTEL_MKL_DIR)
# TODO: diagnostic if dir does not exist
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}
"${INTEL_MKL_DIR}/include")
"${INTEL_MKL_DIR}/include/")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}
"${INTEL_MKL_DIR}/lib/${mklvers}")
"${INTEL_MKL_DIR}/lib/${mklvers}/")
IF (MSVC)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}
"${INTEL_MKL_DIR}/lib/${iccvers}")
"${INTEL_MKL_DIR}/lib/${iccvers}/")
ENDIF (MSVC)
ENDIF (INTEL_MKL_DIR)

# lib prefix
IF (MSVC)
SET(CMAKE_FIND_LIBRARY_PREFIXES "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
ELSE(MSVC)
SET(CMAKE_FIND_LIBRARY_PREFIXES "lib")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
ENDIF (MSVC)

MESSAGE(STATUS "Searching for MKL in ${CMAKE_LIBRARY_PATH} ...")

# Try linking multiple libs
MACRO(CHECK_ALL_LIBRARIES LIBRARIES _name _list _flags)
# This macro checks for the existence of the combination of libraries given by _list.
Expand Down Expand Up @@ -258,9 +277,15 @@ ENDIF (MKL_LIBRARIES)
IF(NOT MKL_FOUND AND MKL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "MKL library not found. Please specify library location")
ENDIF(NOT MKL_FOUND AND MKL_FIND_REQUIRED)


IF(NOT MKL_FIND_QUIETLY)
IF(MKL_FOUND)
MESSAGE(STATUS "MKL library found")
IF (mkl64s)
MESSAGE(STATUS "MKL 64bit library found: ${mkl64s}")
ELSE(mkl64s)
MESSAGE(STATUS "MKL 32bit library found: ${mkl64s}")
ENDIF(mkl64s)
ELSE(MKL_FOUND)
MESSAGE(STATUS "MKL library not found")
ENDIF(MKL_FOUND)
Expand Down
112 changes: 59 additions & 53 deletions lib/TH/generic/THBlas.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,35 @@
# define ffloat float
#endif

TH_EXTERNC void dswap_(int *n, double *x, int *incx, double *y, int *incy);
TH_EXTERNC void sswap_(int *n, float *x, int *incx, float *y, int *incy);
TH_EXTERNC void dscal_(int *n, double *a, double *x, int *incx);
TH_EXTERNC void sscal_(int *n, float *a, float *x, int *incx);
TH_EXTERNC void dcopy_(int *n, double *x, int *incx, double *y, int *incy);
TH_EXTERNC void scopy_(int *n, float *x, int *incx, float *y, int *incy);
TH_EXTERNC void daxpy_(int *n, double *a, double *x, int *incx, double *y, int *incy);
TH_EXTERNC void saxpy_(int *n, float *a, float *x, int *incx, float *y, int *incy);
TH_EXTERNC double ddot_(int *n, double *x, int *incx, double *y, int *incy);
TH_EXTERNC ffloat sdot_(int *n, float *x, int *incx, float *y, int *incy);
TH_EXTERNC void dgemv_(char *trans, int *m, int *n, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy);
TH_EXTERNC void sgemv_(char *trans, int *m, int *n, float *alpha, float *a, int *lda, float *x, int *incx, float *beta, float *y, int *incy);
TH_EXTERNC void dger_(int *m, int *n, double *alpha, double *x, int *incx, double *y, int *incy, double *a, int *lda);
TH_EXTERNC void sger_(int *m, int *n, float *alpha, float *x, int *incx, float *y, int *incy, float *a, int *lda);
TH_EXTERNC void dgemm_(char *transa, char *transb, int *m, int *n, int *k, double *alpha, double *a, int *lda, double *b, int *ldb, double *beta, double *c, int *ldc);
TH_EXTERNC void sgemm_(char *transa, char *transb, int *m, int *n, int *k, float *alpha, float *a, int *lda, float *b, int *ldb, float *beta, float *c, int *ldc);
#ifdef MKL_ILP64
// set 64 bit MKL integer type
#if (!defined(__INTEL_COMPILER)) & defined(_MSC_VER)
#define BLAS_INT __int64
#else
#define BLAS_INT long long int
#endif
#else
#define BLAS_INT int
#endif


TH_EXTERNC void dswap_(BLAS_INT *n, double *x, BLAS_INT *incx, double *y, BLAS_INT *incy);
TH_EXTERNC void sswap_(BLAS_INT *n, float *x, BLAS_INT *incx, float *y, BLAS_INT *incy);
TH_EXTERNC void dscal_(BLAS_INT *n, double *a, double *x, BLAS_INT *incx);
TH_EXTERNC void sscal_(BLAS_INT *n, float *a, float *x, BLAS_INT *incx);
TH_EXTERNC void dcopy_(BLAS_INT *n, double *x, BLAS_INT *incx, double *y, BLAS_INT *incy);
TH_EXTERNC void scopy_(BLAS_INT *n, float *x, BLAS_INT *incx, float *y, BLAS_INT *incy);
TH_EXTERNC void daxpy_(BLAS_INT *n, double *a, double *x, BLAS_INT *incx, double *y, BLAS_INT *incy);
TH_EXTERNC void saxpy_(BLAS_INT *n, float *a, float *x, BLAS_INT *incx, float *y, BLAS_INT *incy);
TH_EXTERNC double ddot_(BLAS_INT *n, double *x, BLAS_INT *incx, double *y, BLAS_INT *incy);
TH_EXTERNC ffloat sdot_(BLAS_INT *n, float *x, BLAS_INT *incx, float *y, BLAS_INT *incy);
TH_EXTERNC void dgemv_(char *trans, BLAS_INT *m, BLAS_INT *n, double *alpha, double *a, BLAS_INT *lda, double *x, BLAS_INT *incx, double *beta, double *y, BLAS_INT *incy);
TH_EXTERNC void sgemv_(char *trans, BLAS_INT *m, BLAS_INT *n, float *alpha, float *a, BLAS_INT *lda, float *x, BLAS_INT *incx, float *beta, float *y, BLAS_INT *incy);
TH_EXTERNC void dger_(BLAS_INT *m, BLAS_INT *n, double *alpha, double *x, BLAS_INT *incx, double *y, BLAS_INT *incy, double *a, BLAS_INT *lda);
TH_EXTERNC void sger_(BLAS_INT *m, BLAS_INT *n, float *alpha, float *x, BLAS_INT *incx, float *y, BLAS_INT *incy, float *a, BLAS_INT *lda);
TH_EXTERNC void dgemm_(char *transa, char *transb, BLAS_INT *m, BLAS_INT *n, BLAS_INT *k, double *alpha, double *a, BLAS_INT *lda, double *b, BLAS_INT *ldb, double *beta, double *c, BLAS_INT *ldc);
TH_EXTERNC void sgemm_(char *transa, char *transb, BLAS_INT *m, BLAS_INT *n, BLAS_INT *k, float *alpha, float *a, BLAS_INT *lda, float *b, BLAS_INT *ldb, float *beta, float *c, BLAS_INT *ldc);


void THBlas_(swap)(long n, real *x, long incx, real *y, long incy)
{
Expand All @@ -39,9 +50,9 @@ void THBlas_(swap)(long n, real *x, long incx, real *y, long incy)
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (n <= INT_MAX) && (incx <= INT_MAX) && (incy <= INT_MAX) )
{
int i_n = (int)n;
int i_incx = (int)incx;
int i_incy = (int)incy;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_incx = (BLAS_INT)incx;
BLAS_INT i_incy = (BLAS_INT)incy;

#if defined(TH_REAL_IS_DOUBLE)
dswap_(&i_n, x, &i_incx, y, &i_incy);
Expand Down Expand Up @@ -70,8 +81,8 @@ void THBlas_(scal)(long n, real a, real *x, long incx)
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (n <= INT_MAX) && (incx <= INT_MAX) )
{
int i_n = (int)n;
int i_incx = (int)incx;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_incx = (BLAS_INT)incx;

#if defined(TH_REAL_IS_DOUBLE)
dscal_(&i_n, &a, x, &i_incx);
Expand All @@ -83,13 +94,8 @@ void THBlas_(scal)(long n, real a, real *x, long incx)
#endif
{
long i;
for(i = 0; i < n; i++) {
if (a == 0) {
x[i*incx] = 0;
} else {
x[i*incx] *= a;
}
}
for(i = 0; i < n; i++)
x[i*incx] *= a;
}
}

Expand All @@ -104,9 +110,9 @@ void THBlas_(copy)(long n, real *x, long incx, real *y, long incy)
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (n <= INT_MAX) && (incx <= INT_MAX) && (incy <= INT_MAX) )
{
int i_n = (int)n;
int i_incx = (int)incx;
int i_incy = (int)incy;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_incx = (BLAS_INT)incx;
BLAS_INT i_incy = (BLAS_INT)incy;

#if defined(TH_REAL_IS_DOUBLE)
dcopy_(&i_n, x, &i_incx, y, &i_incy);
Expand Down Expand Up @@ -134,9 +140,9 @@ void THBlas_(axpy)(long n, real a, real *x, long incx, real *y, long incy)
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (n <= INT_MAX) && (incx <= INT_MAX) && (incy <= INT_MAX) )
{
int i_n = (int)n;
int i_incx = (int)incx;
int i_incy = (int)incy;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_incx = (BLAS_INT)incx;
BLAS_INT i_incy = (BLAS_INT)incy;

#if defined(TH_REAL_IS_DOUBLE)
daxpy_(&i_n, &a, x, &i_incx, y, &i_incy);
Expand Down Expand Up @@ -164,9 +170,9 @@ real THBlas_(dot)(long n, real *x, long incx, real *y, long incy)
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (n <= INT_MAX) && (incx <= INT_MAX) && (incy <= INT_MAX) )
{
int i_n = (int)n;
int i_incx = (int)incx;
int i_incy = (int)incy;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_incx = (BLAS_INT)incx;
BLAS_INT i_incy = (BLAS_INT)incy;

#if defined(TH_REAL_IS_DOUBLE)
return (real) ddot_(&i_n, x, &i_incx, y, &i_incy);
Expand Down Expand Up @@ -195,11 +201,11 @@ void THBlas_(gemv)(char trans, long m, long n, real alpha, real *a, long lda, re
(incx > 0) && (incx <= INT_MAX) &&
(incy > 0) && (incy <= INT_MAX) )
{
int i_m = (int)m;
int i_n = (int)n;
int i_lda = (int)lda;
int i_incx = (int)incx;
int i_incy = (int)incy;
BLAS_INT i_m = (BLAS_INT)m;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_lda = (BLAS_INT)lda;
BLAS_INT i_incx = (BLAS_INT)incx;
BLAS_INT i_incy = (BLAS_INT)incy;

#if defined(TH_REAL_IS_DOUBLE)
dgemv_(&trans, &i_m, &i_n, &alpha, a, &i_lda, x, &i_incx, &beta, y, &i_incy);
Expand Down Expand Up @@ -250,11 +256,11 @@ void THBlas_(ger)(long m, long n, real alpha, real *x, long incx, real *y, long
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (m <= INT_MAX) && (n <= INT_MAX) && (lda <= INT_MAX) && (incx <= INT_MAX) && (incy <= INT_MAX) )
{
int i_m = (int)m;
int i_n = (int)n;
int i_lda = (int)lda;
int i_incx = (int)incx;
int i_incy = (int)incy;
BLAS_INT i_m = (BLAS_INT)m;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_lda = (BLAS_INT)lda;
BLAS_INT i_incx = (BLAS_INT)incx;
BLAS_INT i_incy = (BLAS_INT)incy;

#if defined(TH_REAL_IS_DOUBLE)
dger_(&i_m, &i_n, &alpha, x, &i_incx, y, &i_incy, a, &i_lda);
Expand Down Expand Up @@ -309,12 +315,12 @@ void THBlas_(gemm)(char transa, char transb, long m, long n, long k, real alpha,
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (m <= INT_MAX) && (n <= INT_MAX) && (k <= INT_MAX) && (lda <= INT_MAX) && (ldb <= INT_MAX) && (ldc <= INT_MAX) )
{
int i_m = (int)m;
int i_n = (int)n;
int i_k = (int)k;
int i_lda = (int)lda;
int i_ldb = (int)ldb;
int i_ldc = (int)ldc;
BLAS_INT i_m = (BLAS_INT)m;
BLAS_INT i_n = (BLAS_INT)n;
BLAS_INT i_k = (BLAS_INT)k;
BLAS_INT i_lda = (BLAS_INT)lda;
BLAS_INT i_ldb = (BLAS_INT)ldb;
BLAS_INT i_ldc = (BLAS_INT)ldc;

#if defined(TH_REAL_IS_DOUBLE)
dgemm_(&transa, &transb, &i_m, &i_n, &i_k, &alpha, a, &i_lda, b, &i_ldb, &beta, c, &i_ldc);
Expand Down
Loading