Skip to content

Commit 02cfbee

Browse files
committed
Fix MSVC build on missing symbol of _cvtss_sh/_cvtsh_ss and suppress exceptions in JIT.
Signed-off-by: Yong Wu <yong.wu@intel.com>
1 parent ec268b3 commit 02cfbee

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/RefImplementations.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
#include <numeric>
1919
#include <thread>
2020
#include <iostream>
21-
#include <immintrin.h>
21+
#include <immintrin.h> // for _cvtss_sh/_cvtsh_ss
22+
23+
#ifdef _MSC_VER
24+
// MSVC does not provide _cvtsh_ss/_cvtss_sh
25+
#define _cvtsh_ss(a) \
26+
_mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128(a)))
27+
28+
// FIXME -
29+
// MSVC assumes rounding is 0...7 so the _MM_FROUND_NO_EXC (which is 0x8
30+
// if set) will lose.
31+
#define _cvtss_sh(a, rounding) static_cast<unsigned short> \
32+
(_mm_cvtsi128_si32(_mm_cvtps_ph(_mm_set_ss(a), ((rounding) & 0x7U))))
33+
34+
#endif
2235

2336
using namespace std;
2437

src/RowWiseSparseAdagradFused.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ typename ReturnFunctionSignature<indxType, offsetType, dataType>::
617617
a->vpaddd(out_vreg, r0_vreg, out_vreg);
618618
}
619619
// Truncate rounding to 'counterwork' the random added part
620-
a->vcvtps2ph(x86::word_ptr(x86::rsp), out_vreg, 0b11);
620+
a->vcvtps2ph(x86::word_ptr(x86::rsp), out_vreg, 11);
621621
// Copy results back
622622
for (size_t r = 0; r < remainder; ++r) {
623623
a->mov(h.r16(), x86::ptr(x86::rsp, sizeof(dataType) * r));
@@ -637,7 +637,7 @@ typename ReturnFunctionSignature<indxType, offsetType, dataType>::
637637
a->vpaddd(out_vreg, r0_vreg, out_vreg);
638638
}
639639
// Truncate rounding
640-
a->k(x86::k(1)).vcvtps2ph(w_ptr, out_vreg, 0b11);
640+
a->k(x86::k(1)).vcvtps2ph(w_ptr, out_vreg, 11);
641641
}
642642
} else {
643643
a->vcvtph2ps(out_vreg, w_ptr);
@@ -646,7 +646,7 @@ typename ReturnFunctionSignature<indxType, offsetType, dataType>::
646646
a->vpaddd(out_vreg, r0_vreg, out_vreg);
647647
}
648648
// Truncate rounding
649-
a->vcvtps2ph(w_ptr, out_vreg, 0b11);
649+
a->vcvtps2ph(w_ptr, out_vreg, 11);
650650
}
651651
}
652652

0 commit comments

Comments
 (0)