Skip to content

Commit

Permalink
Work under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
samehkhamis committed Jul 24, 2015
1 parent 4dc3aea commit d2bb9d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion THGeneral.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# define TH_EXTERNC extern
#endif

#ifdef WIN32
#ifdef _WIN32
# ifdef TH_EXPORTS
# define TH_API TH_EXTERNC __declspec(dllexport)
# else
Expand Down
1 change: 1 addition & 0 deletions generic/THTensorConv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define TH_GENERIC_FILE "generic/THTensorConv.c"
#else


/*
2D Input, 2D kernel : convolve given image with the given kernel.
*/
Expand Down
22 changes: 22 additions & 0 deletions generic/simd/convolve.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#if defined(USE_AVX)

#ifdef _MSC_VER
#include <intrin.h>

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" \
Expand All @@ -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,
Expand Down

0 comments on commit d2bb9d0

Please sign in to comment.