Skip to content

Commit c33e4c2

Browse files
committed
fix errors on running with no SIMD
1 parent 5afe0ea commit c33e4c2

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ before_script:
2525
- tar jxvf cantrbry.tar.bz2
2626
- mkdir build
2727
- cd build
28-
- cmake ..
28+
- cmake .. -DUSE_SIMD=1
2929
script:
3030
- make
3131
- ./TestRangeCoder

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,15 @@ An implementaion of adaptive range coder for C++
5656
|sum|0.491946|88|112|
5757
|xargs.1|0.628815|13|15|
5858

59+
# Building
60+
For Visual Studio 15 2017,
61+
```
62+
git clone https://github.com/taqu/cpprcoder.git
63+
cd cpprcoder/test
64+
mkdir build_simd
65+
pushd build_simd
66+
cmake -G"Visual Studio 15 2017 Win64" -DUSE_SIMD=1 ..
67+
```
68+
5969
# License
6070
This is free and unencumbered software released into the public domain.

cpprcoder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ namespace cpprcoder
117117
#define CPPRCODER_USE_SSE2 (1)
118118
#endif
119119

120-
121120
enum Status
122121
{
123122
Status_Success = 0,
@@ -684,6 +683,7 @@ namespace cpprcoder
684683
frequencies_[i] = 1;
685684
}
686685

686+
prefix_[0] = CHUNK_SIZE;
687687
for(s32 i=1; i<CHUNKS; ++i){
688688
prefix_[i] = prefix_[i-1] + CHUNK_SIZE;
689689
}

test/CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
2222

2323
add_executable(${ProjectName} ${FILES})
2424

25+
set(CXX_FLAGS_SIMD "")
2526
if(MSVC)
26-
set(DEFAULT_CXX_FLAGS "/DWIN32 /D_WINDOWS /D_MBCS /W4 /WX- /nologo /fp:precise /arch:AVX /Zc:wchar_t /TP /Gd")
27+
if(USE_SIMD)
28+
set(CXX_FLAGS_SIMD "/arch:AVX")
29+
endif()
30+
31+
set(DEFAULT_CXX_FLAGS "/DWIN32 /D_WINDOWS /D_MBCS /W4 /WX- /nologo /fp:precise /Zc:wchar_t /TP /Gd ${CXX_FLAGS_SIMD}")
2732
if("1800" VERSION_LESS MSVC_VERSION)
2833
set(DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} /EHsc")
2934
endif()
@@ -35,7 +40,10 @@ if(MSVC)
3540
target_link_libraries(${ProjectName} "liblz4_static.lib")
3641

3742
elseif(UNIX)
38-
set(DEFAULT_CXX_FLAGS "-Wall -O2 -std=c++11 -march=native")
43+
if(USE_SIMD)
44+
set(CXX_FLAGS_SIMD "-march=native")
45+
endif()
46+
set(DEFAULT_CXX_FLAGS "-Wall -O2 -std=c++11 ${CXX_FLAGS_SIMD}")
3947
set(CMAKE_CXX_FLAGS "${DEFAULT_CXX_FLAGS}")
4048
target_link_libraries(${ProjectName} "z")
4149
elseif(APPLE)

0 commit comments

Comments
 (0)