Skip to content

Commit cc70a33

Browse files
Will Fengezyang
authored andcommitted
Windows fix for #4312
1 parent 48436ac commit cc70a33

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

aten/src/TH/vector/AVX2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef TH_AVX2_H
22
#define TH_AVX2_H
33

4+
#include <stdint.h>
45
#include <stddef.h>
56

67
struct THGenerator;

aten/src/TH/vector/avx_mathfun.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@
3333
#include <immintrin.h>
3434

3535
/* yes I know, the top of this file is quite ugly */
36-
# define ALIGN32_BEG
37-
# define ALIGN32_END __attribute__((aligned(32)))
36+
#if defined(__GNUC__)
37+
# define ALIGN32_BEG __attribute__((aligned(32)))
38+
#elif defined(_WIN32)
39+
# define ALIGN32_BEG __declspec(align(32))
40+
#endif
3841

3942
/* __m128 is ugly to write */
4043
typedef __m256 v8sf; // vector of 8 float (avx)
4144
typedef __m256i v8si; // vector of 8 int (avx)
4245
typedef __m128i v4si; // vector of 8 int (avx)
4346

4447
#define _PI32AVX_CONST(Name, Val) \
45-
static const ALIGN32_BEG int _pi32avx_##Name[4] ALIGN32_END = { Val, Val, Val, Val }
48+
static const ALIGN32_BEG int _pi32avx_##Name[4] = { Val, Val, Val, Val }
4649

4750
_PI32AVX_CONST(1, 1);
4851
_PI32AVX_CONST(inv1, ~1);
@@ -52,11 +55,11 @@ _PI32AVX_CONST(4, 4);
5255

5356
/* declare some AVX constants -- why can't I figure a better way to do that? */
5457
#define _PS256_CONST(Name, Val) \
55-
static const ALIGN32_BEG float _ps256_##Name[8] ALIGN32_END = { Val, Val, Val, Val, Val, Val, Val, Val }
58+
static const ALIGN32_BEG float _ps256_##Name[8] = { Val, Val, Val, Val, Val, Val, Val, Val }
5659
#define _PI32_CONST256(Name, Val) \
57-
static const ALIGN32_BEG int _pi32_256_##Name[8] ALIGN32_END = { Val, Val, Val, Val, Val, Val, Val, Val }
60+
static const ALIGN32_BEG int _pi32_256_##Name[8] = { Val, Val, Val, Val, Val, Val, Val, Val }
5861
#define _PS256_CONST_TYPE(Name, Type, Val) \
59-
static const ALIGN32_BEG Type _ps256_##Name[8] ALIGN32_END = { Val, Val, Val, Val, Val, Val, Val, Val }
62+
static const ALIGN32_BEG Type _ps256_##Name[8] = { Val, Val, Val, Val, Val, Val, Val, Val }
6063

6164
_PS256_CONST(1 , 1.0f);
6265
_PS256_CONST(0p5, 0.5f);

0 commit comments

Comments
 (0)