Skip to content

Commit 4426ddc

Browse files
MichalMrozekArturHarasimiuk
authored andcommitted
Initial commit
Signed-off-by: Michal Mrozek <[email protected]>
0 parents  commit 4426ddc

File tree

705 files changed

+76117
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

705 files changed

+76117
-0
lines changed

.clang-format

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlinesLeft: false
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: All
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: false
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BraceWrapping:
24+
AfterClass: false
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: false
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
BreakBeforeBinaryOperators: false
36+
BreakBeforeBraces: Attach
37+
BreakBeforeTernaryOperators: true
38+
BreakConstructorInitializersBeforeComma: false
39+
# clang-format > v3.8.0: BreakAfterJavaFieldAnnotations: false
40+
# clang-format > v3.8.0: BreakStringLiterals: true
41+
ColumnLimit: 0
42+
CommentPragmas: '^ IWYU pragma:'
43+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
44+
ConstructorInitializerIndentWidth: 4
45+
ContinuationIndentWidth: 4
46+
Cpp11BracedListStyle: true
47+
DerivePointerAlignment: false
48+
DisableFormat: false
49+
ExperimentalAutoDetectBinPacking: false
50+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
51+
IncludeBlocks: Regroup
52+
IncludeCategories:
53+
- Regex: '^"framework/.*"$'
54+
Priority: 1
55+
- Regex: '^".*"$'
56+
Priority: 2
57+
- Regex: '^<.*>$'
58+
Priority: 3
59+
- Regex: '.*'
60+
Priority: 4
61+
IndentCaseLabels: false
62+
IndentWidth: 4
63+
IndentWrappedFunctionNames: false
64+
KeepEmptyLinesAtTheStartOfBlocks: true
65+
MacroBlockBegin: ''
66+
MacroBlockEnd: ''
67+
MaxEmptyLinesToKeep: 1
68+
NamespaceIndentation: None
69+
ObjCBlockIndentWidth: 2
70+
ObjCSpaceAfterProperty: false
71+
ObjCSpaceBeforeProtocolList: true
72+
PenaltyBreakBeforeFirstCallParameter: 19
73+
PenaltyBreakComment: 300
74+
PenaltyBreakFirstLessLess: 120
75+
PenaltyBreakString: 1000
76+
PenaltyExcessCharacter: 1000000
77+
PenaltyReturnTypeOnItsOwnLine: 60
78+
PointerAlignment: Right
79+
ReflowComments: true
80+
SortIncludes: true
81+
SpaceAfterCStyleCast: false
82+
SpaceBeforeAssignmentOperators: true
83+
SpaceBeforeParens: ControlStatements
84+
SpaceInEmptyParentheses: false
85+
SpacesBeforeTrailingComments: 1
86+
SpacesInAngles: false
87+
SpacesInContainerLiterals: true
88+
SpacesInCStyleCastParentheses: false
89+
SpacesInParentheses: false
90+
SpacesInSquareBrackets: false
91+
Standard: Cpp11
92+
TabWidth: 8
93+
UseTab: Never
94+
...
95+

.github/lint.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
lint:
2+
clang-format:
3+
included:
4+
- \.cpp$
5+
- \.h$
6+
- \.inl$
7+
- \.hpp$
8+
excluded:
9+
- third_party/
10+
- scripts/
11+
12+
cmake-format:
13+
disabled: true
14+
15+
copyright:
16+
excluded:
17+
- third_party/
18+
mit_header:
19+
contents: |-
20+
{comment_begin}
21+
{comment_char} Copyright (C) %s Intel Corporation
22+
{comment_char}
23+
{comment_char} SPDX-License-Identifier: MIT
24+
{comment_char}
25+
{comment_end}
26+
year_pattern: (\d+)(-\d+)?
27+
year_constraints:
28+
_default: 2022
29+
file_types:
30+
cpp:
31+
includes:
32+
- \.cpp$
33+
- \.h$
34+
- \.inl$
35+
- \.hpp$
36+
- \.cl$
37+
- \.m$
38+
- \.h.in$
39+
- \.rc.in$
40+
- ^Jenkinsfile$
41+
comment_begin: "/*"
42+
comment_end: >1
43+
*/
44+
comment_char: " *"
45+
bash:
46+
includes:
47+
- CMakeLists.txt$
48+
- \.cmake$
49+
- \.py$
50+
- \.sh$
51+
comment_begin: "#"
52+
comment_char: "#"
53+
bat:
54+
includes:
55+
- \.bat$
56+
- \.cmd$
57+
comment_begin: "REM"
58+
comment_char: "REM"
59+
60+
ults-needed:
61+
disabled: true
62+
63+
binary_files:
64+
disabled: true

.github/pull-request.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaultbranch: master

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
.vs/
3+
CMakeSettings.json

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "third_party/googletest"]
2+
path = third_party/googletest
3+
url = https://github.com/google/googletest.git

.lint-revision

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.21

CMakeLists.txt

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
8+
project(ComputeBenchmarks)
9+
include(CMakeOptions.cmake)
10+
set(PREDEFINED_TARGETS_FOLDER "CustomTargets")
11+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
12+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
13+
14+
15+
16+
# Enable MT Compilation in VisualStudio
17+
if (MSVC)
18+
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
19+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:OpenCL.dll")
20+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:ze_loader.dll")
21+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4199")
22+
endif()
23+
24+
# Load dependencies
25+
if(NOT EXISTS third_party/googletest/CMakeLists.txt)
26+
execute_process(COMMAND git submodule update --init --recursive
27+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
28+
endif()
29+
30+
# Produce version string
31+
string(TIMESTAMP versionDate "%Y%m%d")
32+
execute_process (COMMAND git log -1 --format=%h
33+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
34+
OUTPUT_VARIABLE versionCommit
35+
OUTPUT_STRIP_TRAILING_WHITESPACE
36+
)
37+
set(BENCHMARK_VERSION "${versionDate}_${VERSION_INDEX}_${versionCommit}")
38+
39+
# Publish build additional handling
40+
if(BUILD_FOR_PUBLISHING)
41+
# Only publish release builds
42+
message(STATUS "Overriding build type to Release")
43+
set(CMAKE_CONFIGURATION_TYPES Release)
44+
set(CMAKE_BUILD_TYPE Release)
45+
46+
file(WRITE ${OUTPUT_DIR}/version.txt ${BENCHMARK_VERSION})
47+
message(STATUS "Version ${BENCHMARK_VERSION} written to version.txt")
48+
endif()
49+
50+
# ccache
51+
option(CCACHE_ALLOWED "allow use of ccache" TRUE)
52+
find_program(CCACHE_EXE_FOUND ccache)
53+
if(CCACHE_EXE_FOUND AND CCACHE_ALLOWED)
54+
message(STATUS "Found ccache: ${CCACHE_EXE_FOUND}")
55+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
56+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
57+
endif()
58+
59+
# Gtest
60+
set(gtest_force_shared_crt OFF CACHE BOOL "")
61+
set(BUILD_GMOCK OFF CACHE BOOL "")
62+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
63+
add_subdirectory(third_party/googletest)
64+
if (MSVC)
65+
set_target_properties(gtest_main PROPERTIES FOLDER framework)
66+
set_target_properties(gtest PROPERTIES
67+
FOLDER framework
68+
LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIR}"
69+
RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}"
70+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
71+
)
72+
endif()
73+
74+
# Benchmark
75+
if(MSVC)
76+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_DEBUG} /MT")
77+
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_DEBUG} /MT")
78+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
79+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
80+
endif()
81+
82+
# Compiler proxy for SYCL
83+
if(BUILD_SYCL)
84+
find_package(SYCL)
85+
if(SYCL_FOUND)
86+
string(REPLACE "<CMAKE_CXX_COMPILER>" "${SYCL_PROXY} <CMAKE_CXX_COMPILER>" CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
87+
set(CMAKE_CXX_COMPILER_LAUNCHER "${SYCL_PROXY}")
88+
endif()
89+
endif()
90+
91+
add_subdirectory(source)
92+
set_directory_properties(PROPERTIES VS_STARTUP_PROJECT ulls_benchmark_ocl)

CMakeOptions.cmake

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#
2+
# Copyright (C) 2022 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
macro(benchmark_option NAME DEFAULT_VALUE)
8+
if (NOT DEFINED ${NAME})
9+
set(${NAME} ${DEFAULT_VALUE})
10+
endif()
11+
if (${NAME} STREQUAL "")
12+
set(${NAME} ${DEFAULT_VALUE})
13+
endif()
14+
message(STATUS " ${NAME}=${${NAME}} ${ARGN}")
15+
endmacro()
16+
macro (benchmark_option_group DESCRIPTION)
17+
message(STATUS " ${DESCRIPTION}:")
18+
endmacro()
19+
message(STATUS "Build options:")
20+
21+
# Selecting targets
22+
benchmark_option_group("Flags for selecting targets to be built")
23+
benchmark_option(BUILD_L0 ON)
24+
benchmark_option(BUILD_OCL ON)
25+
benchmark_option(BUILD_SYCL OFF)
26+
if(BUILD_SYCL AND MSVC)
27+
set(BUILD_SYCL OFF)
28+
message(WARNING "Building SYCL benchmarks is disabled on Windows because of incompatibility of the dynamically-linked Visual C++ Runtime, required for DPC++, with GootleTest")
29+
endif()
30+
if (NOT BUILD_L0 OR NOT BUILD_OCL)
31+
set(BUILD_ALL_API_BINARIES OFF)
32+
set(BUILD_ALL_API_BINARIES_COMMENT "(Disabled due to not all APIs being enabled)")
33+
endif()
34+
if (BUILD_SYCL)
35+
set(BUILD_ALL_API_BINARIES OFF)
36+
set(BUILD_ALL_API_BINARIES_COMMENT "(Disabled due to SYCL being enabled)")
37+
endif()
38+
benchmark_option(BUILD_SINGLE_API_BINARIES ON)
39+
benchmark_option(BUILD_ALL_API_BINARIES OFF ${BUILD_ALL_API_BINARIES_COMMENT})
40+
41+
# Publish builds and versioning
42+
benchmark_option_group("Flags for configuring publishable builds and versions")
43+
benchmark_option(BUILD_FOR_PUBLISHING OFF)
44+
if (BUILD_FOR_PUBLISHING)
45+
set(INCLUDE_VERSION_COMMENT "(Enabled by BUILD_FOR_PUBLISHING)")
46+
endif()
47+
benchmark_option(INCLUDE_VERSION OFF ${INCLUDE_VERSION_COMMENT})
48+
benchmark_option(VERSION_INDEX "01")
49+
50+
# Miscellaneous flags
51+
benchmark_option_group("Miscellaneous flags")
52+
benchmark_option(OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin")
53+
benchmark_option(BUILD_HELLO_WORLD OFF)
54+
benchmark_option(GENERATE_DOCS ON)
55+
benchmark_option(BUILD_TOOLS ON)
56+
benchmark_option(LOG_BENCHMARK_TARGETS OFF)
57+
benchmark_option(ALLOW_WARNINGS ON)
58+
59+
# Additional checks
60+
if (NOT BUILD_L0 AND NOT BUILD_OCL AND NOT BUILD_SYCL)
61+
message(FATAL_ERROR "No API was selected for testing. No benchmarks will be produced")
62+
endif()

CONTRIBUTING.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Contributing to ComputeBenchmarks
2+
Please use ClangFormat to properly format the code.
3+
- [Visual Studio extension](https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.ClangFormat).
4+
- [Visual Studio code extension](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format)
5+
- Script formatting all files [Windows](scripts/run_clang-format_on_all_files.cmd) [Linux](scripts/run_clang-format_on_all_files.sh)
6+
7+
Submit your changes via pull request. One of the maintainers will review your changes and merge them.
8+
9+
Remember to add a copyright header at the top of newly created files.
10+
11+
### Adding new benchmarks
12+
A good way to add new benchmarks is to mimic the existing ones and tweak them to your needs. General flow of adding a brand new test is:
13+
1. Select binary, that suits you benchmark, for example `memory_benchmark`
14+
2. Select name for you benchmark, for example `TwoWayTransfer`.
15+
3. Add definition file of your benchmark as source/benchmarks/`memory_benchmark`/definitions/`TwoWayTransfer`.h. This file specifies generic info about your test - its name, description and parameters
16+
4. Add test registration file as source/benchmarks/`memory_benchmark`/gtest/`TwoWayTransfer`.cpp. This file registers your test, so the framework knowns about it and it can be run.
17+
5. Add implementation file as source/benchmarks/`memory_benchmark`/implementations/ocl/`TwoWayTransfer`_ocl.cpp. This file is contains the actual implementation of your test. Substittue *ocl* with *l0* for LevelZero implementation. Each test *can* be implemented in more than one API.
18+
6. Regenerate documentation (see below).
19+
20+
### Generating documentation
21+
Tests documentation is generated from the code and stored in [TESTS.md](TESTS.md) file. Contributors are required to regenerate the documentation by building the *run_docs_generator* target. No further parameters are needed. The [TESTS.md](TESTS.md) file should be automatically updated.

0 commit comments

Comments
 (0)