File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ using namespace std;
1616static inline int numberOfTrailingZeros (uint64_t x) {
1717 if (x == 0 )
1818 return 64 ;
19- return __builtin_ctzl (x);
19+ return __builtin_ctzll (x);
2020}
2121
2222class BoolArray {
@@ -90,7 +90,7 @@ class BoolArray {
9090 for (uint32_t k = 0 ; k < buffer.size (); ++k) {
9191 uint64_t myword = buffer[k];
9292 while (myword != 0 ) {
93- int ntz = __builtin_ctzl (myword);
93+ int ntz = __builtin_ctzll (myword);
9494 ans[pos++] = k * 64 + ntz;
9595 myword ^= (1ll << ntz);
9696 }
Original file line number Diff line number Diff line change 2222#ifdef _MSC_VER
2323#include <intrin.h>
2424
25- uint32_t __inline __builtin_clz (uint32_t value ) {
25+ int __inline __builtin_clz (uint32_t value ) {
2626 unsigned long leading_zero = 0 ;
2727 return _BitScanReverse (& leading_zero , value ) == 0 ? 0 : (31 - leading_zero );
2828}
2929
30- uint32_t __inline __builtin_ctz (uint32_t value ) {
30+ int __inline __builtin_ctz (uint32_t value ) {
3131 unsigned long trailing_zero = 0 ;
3232 return _BitScanForward (& trailing_zero , value ) == 0 ? 32 : trailing_zero ;
3333}
3434
35- uint32_t __inline __builtin_ctzl (uint64_t value ) {
35+ // NOTE: avoid ctzl / clzl since long is 32 bits for MSVC
36+
37+ int __inline __builtin_ctzll (uint64_t value ) {
3638#ifdef _M_X64
3739 unsigned long trailing_zero = 0 ;
3840 return _BitScanForward64 (& trailing_zero , value ) == 0 ? 64 : trailing_zero ;
Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ class ZipfianGenerator {
218218
219219 double zeta (int nn, double ttheta) {
220220 double sum = 0 ;
221- for (long i = 0 ; i < nn; i++) {
221+ for (int i = 0 ; i < nn; i++) {
222222 sum += 1 / (pow (i + 1 , ttheta));
223223 }
224224 return sum;
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ LINK=link.exe
1818INC = /Iinclude
1919
2020!IF "$(DEBUG)"=="yes"
21- CFLAGS = /nologo /MDd /LDd /Od /Zi /D_DEBUG /D__SSSE3__ /RTC1 /W3 /wd"4141" /GS /Gm /arch:AVX
21+ CFLAGS = /nologo /MDd /LDd /Od /Zi /D_DEBUG /D__SSSE3__ /RTC1 /W3 /wd"4141" /GS /Gm /arch:AVX /EHsc
2222ARFLAGS = /nologo
2323LDFLAGS = /nologo /debug /nodefaultlib:msvcrt
2424!ELSE
25- CFLAGS = /nologo /MD /O2 /Zi /DNDEBUG /D__SSSE3__ /W3 /wd"4141" /Gm- /GS /Gy /Oi /GL /MP /arch:AVX
25+ CFLAGS = /nologo /MD /O2 /Zi /DNDEBUG /D__SSSE3__ /W3 /wd"4141" /Gm- /GS /Gy /Oi /GL /MP /arch:AVX /EHsc
2626ARFLAGS = /nologo /LTCG
2727LDFLAGS = /nologo /LTCG /DYNAMICBASE /incremental:no /debug /opt:ref,icf
2828!ENDIF
@@ -42,6 +42,10 @@ unit: lib
4242 $(CC) $(INC) $(CFLAGS) /c src/unit.cpp
4343 $(LINK) $(LDFLAGS) /OUT:unit.exe unit.obj simdcomp_a.lib
4444
45+ example: lib
46+ $(CC) $(INC) $(CFLAGS) /c example.cpp
47+ $(LINK) $(LDFLAGS) /OUT:example.exe example.obj simdcomp_a.lib
48+
4549clean:
4650 del /Q *.obj
4751 del /Q *.lib
You can’t perform that action at this time.
0 commit comments