Skip to content

Commit

Permalink
Revert to non-posic_memalign version of STREAM
Browse files Browse the repository at this point in the history
Also request medium mcmodel to support large arrays with STREAM.

This reverts commit da10cd8.
  • Loading branch information
bernhardmgruber committed Aug 17, 2023
1 parent bc2ecc3 commit bdc3853
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 309 deletions.
12 changes: 9 additions & 3 deletions examples/stream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cmake_minimum_required (VERSION 3.18.3)

find_package(OpenMP REQUIRED)
set(STREAM_ARRAY_SIZE 400000000 CACHE STRING "STREAM benchmark array size")
set(STREAM_ARRAY_SIZE 80000000 CACHE STRING "STREAM benchmark array size")

project(stream C)

Expand All @@ -14,7 +14,10 @@ target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_CXX)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native)
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -mcmodel=medium) # mcmodel needed for large global vars
if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
target_link_options(${PROJECT_NAME} PRIVATE -shared-intel)
endif()
endif()

project(llama-stream CXX)
Expand All @@ -30,5 +33,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama OpenMP::OpenMP_CXX)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /arch:AVX2)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -march=native)
target_compile_options(${PROJECT_NAME} PRIVATE -march=native -mcmodel=medium) # mcmodel needed for large global vars
if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
target_link_options(${PROJECT_NAME} PRIVATE -shared-intel)
endif()
endif()
9 changes: 5 additions & 4 deletions examples/stream/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
This is a compliant version of the [STREAM benchmark](https://www.cs.virginia.edu/stream/).
There are a few official such versions, which you can download [here](https://www.cs.virginia.edu/stream/FTP/Code/).
The [original version](https://www.cs.virginia.edu/stream/FTP/Code/stream.c) places the input and ouput arrays into the static program segment.
This causes the linker to complain because it breaks limits of ELF/PE (Linux/Windows executable file format) for big array sizes.
We therefore took the [version using `posix_memalign`](https://www.cs.virginia.edu/stream/FTP/Code/Versions/stream_5-10_posix_memalign.c) for allocation.
Some fixes were applied to make it compile with MSVC.
This example is based on the [original version](https://www.cs.virginia.edu/stream/FTP/Code/stream.c) which places the input and ouput arrays into the static program segment.
This requires to set corresponding command line flags, notable `-mcmodel=medium` for gcc, clang and icpx.
Unfortunately, there is no equivalent for MSVC und you are therefore limited in the values of `STREAM_ARRAY_SIZE`.
For MSVC, you can checkout the STREAM [version using `posix_memalign`](https://www.cs.virginia.edu/stream/FTP/Code/Versions/stream_5-10_posix_memalign.c) for allocation.
Some fixes were applied to this version regardless to make it compile with MSVC.

0 comments on commit bdc3853

Please sign in to comment.