diff --git a/lib/TH/THGeneral.h.in b/lib/TH/THGeneral.h.in index 91b0c7da..651f82a8 100644 --- a/lib/TH/THGeneral.h.in +++ b/lib/TH/THGeneral.h.in @@ -21,7 +21,7 @@ # define TH_EXTERNC extern #endif -#ifdef WIN32 +#ifdef _WIN32 # ifdef TH_EXPORTS # define TH_API TH_EXTERNC __declspec(dllexport) # else diff --git a/lib/TH/generic/THTensorConv.c b/lib/TH/generic/THTensorConv.c index 9ebd188e..da37989a 100644 --- a/lib/TH/generic/THTensorConv.c +++ b/lib/TH/generic/THTensorConv.c @@ -2,6 +2,7 @@ #define TH_GENERIC_FILE "generic/THTensorConv.c" #else + /* 2D Input, 2D kernel : convolve given image with the given kernel. */ diff --git a/lib/TH/generic/simd/convolve.c b/lib/TH/generic/simd/convolve.c index aa669bad..842af175 100644 --- a/lib/TH/generic/simd/convolve.c +++ b/lib/TH/generic/simd/convolve.c @@ -1,5 +1,25 @@ #if defined(USE_AVX) +#ifdef _MSC_VER +#include + +static __inline int __get_cpuid (unsigned int __level, unsigned int *__eax, + unsigned int *__ebx, unsigned int *__ecx, + unsigned int *__edx) { + unsigned int cpui[4]; + __cpuid(cpui, __level); + *__eax = cpui[0]; *__ebx = cpui[1]; *__ecx = cpui[2]; *__edx = cpui[3]; + return 1; +} + +static void xgetbv(unsigned int op, unsigned int* eax, unsigned int* edx) { + *eax = 0; *edx = 0; + if (op == 0) + *eax = _xgetbv(_XCR_XFEATURE_ENABLED_MASK); +} + +#else + #if __i386__ #define __cpuid(__level, __eax, __ebx, __ecx, __edx) \ __asm(" pushl %%ebx\n" \ @@ -26,6 +46,8 @@ static void xgetbv(unsigned int op, unsigned int* eax, unsigned int* edx) { (".byte 0x0f, 0x01, 0xd0": "=a" (*eax), "=d" (*edx) : "c" (op) : "cc"); } +#endif + enum ECPUFeature { kCPUFeature_SSE = 0x01, diff --git a/utils.h b/utils.h index d66f40e2..f9654d4b 100644 --- a/utils.h +++ b/utils.h @@ -18,7 +18,7 @@ # define TORCH_EXTERNC extern #endif -#ifdef WIN32 +#ifdef _WIN32 # ifdef torch_EXPORTS # define TORCH_API TORCH_EXTERNC __declspec(dllexport) # else