Skip to content

Commit dce5c92

Browse files
authored
Merge pull request #180 from ComputationalRadiationPhysics/release-2.4.0crp
Release 2.4.0crp
2 parents 4fc3c52 + 0126a7f commit dce5c92

Some content is hidden

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

50 files changed

+3107
-2768
lines changed

.clang-format

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
AccessModifierOffset: -4
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlines: DontAlign
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: true
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: Yes
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BreakBeforeBraces: Custom
21+
BraceWrapping:
22+
AfterClass: true
23+
AfterControlStatement: true
24+
AfterEnum: true
25+
AfterFunction: true
26+
AfterNamespace: true
27+
AfterStruct: true
28+
AfterUnion: true
29+
AfterExternBlock: true
30+
BeforeCatch: true
31+
BeforeElse: true
32+
IndentBraces: false
33+
SplitEmptyFunction: false
34+
SplitEmptyRecord: false
35+
SplitEmptyNamespace: false
36+
BreakBeforeBinaryOperators: All
37+
BreakBeforeTernaryOperators: true
38+
BreakConstructorInitializers: AfterColon
39+
BreakInheritanceList: AfterColon
40+
BreakStringLiterals: true
41+
ColumnLimit: 80
42+
CompactNamespaces: false
43+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
44+
ConstructorInitializerIndentWidth: 8
45+
ContinuationIndentWidth: 4
46+
Cpp11BracedListStyle: true
47+
DerivePointerAlignment: false
48+
FixNamespaceComments: false
49+
IncludeBlocks: Regroup
50+
IndentCaseLabels: false
51+
IndentPPDirectives: None
52+
IndentWidth: 4
53+
IndentWrappedFunctionNames: false
54+
KeepEmptyLinesAtTheStartOfBlocks: false
55+
Language: Cpp
56+
NamespaceIndentation: All
57+
PointerAlignment: Middle
58+
ReflowComments: true
59+
SortIncludes: true
60+
SortUsingDeclarations: true
61+
SpaceAfterCStyleCast: false
62+
SpaceAfterTemplateKeyword: false
63+
SpaceBeforeAssignmentOperators: true
64+
SpaceBeforeCpp11BracedList: false
65+
SpaceBeforeCtorInitializerColon: true
66+
SpaceBeforeInheritanceColon: true
67+
SpaceBeforeParens: Never
68+
SpaceBeforeRangeBasedForLoopColon: true
69+
SpaceInEmptyParentheses: false
70+
SpacesInAngles: false
71+
SpacesInCStyleCastParentheses: false
72+
SpacesInContainerLiterals: false
73+
SpacesInParentheses: false
74+
SpacesInSquareBrackets: false
75+
Standard: Cpp11
76+
UseTab: Never
77+
...

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
Checks: '*,-llvm-header-guard,-fuchsia-default-arguments-declarations,-cppcoreguidelines-no-malloc,-cppcoreguidelines-owning-memory,-misc-non-private-member-variables-in-classes'
3+
HeaderFilterRegex: '.*'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414

1515
*~
1616
/nbproject
17+
/.vs
18+
/build

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: cpp
22

33
sudo: required
44

5-
dist: trusty
5+
dist: bionic
66

77
compiler:
88
- gcc
@@ -14,6 +14,7 @@ env:
1414

1515
script:
1616
- mkdir build_tmp && cd build_tmp
17+
- CXX=g++-5 && CC=gcc-5
1718
- cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR $TRAVIS_BUILD_DIR
1819
- make
1920
- make install
@@ -28,12 +29,12 @@ before_script:
2829
- sudo apt-get install -f -qq
2930
- sudo dpkg --get-selections | grep hold || { echo "All packages OK."; }
3031
- sudo apt-get install -q -y cmake-data cmake
31-
- sudo apt-get install -qq build-essential
32-
- gcc --version && g++ --version # 4.8
32+
- sudo apt-get install -qq build-essential g++-5
33+
- gcc-5 --version && g++-5 --version # 5.5.0
3334
- apt-cache search nvidia-*
3435
- sudo apt-get install -qq nvidia-common
35-
- sudo apt-get install -qq nvidia-cuda-dev nvidia-cuda-toolkit # 5.5
36-
- sudo apt-get install -qq libboost-dev # 1.54.0
36+
- sudo apt-get install -qq nvidia-cuda-dev nvidia-cuda-toolkit # 9.1.85
37+
- sudo apt-get install -qq libboost-dev # 1.65.1
3738
- sudo find /usr/ -name libcuda*.so
3839

3940
after_script:

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Change Log / Release Log for mallocMC
22
================================================================
33

4+
2.4.0crp
5+
--------
6+
**Date:** 2020-05-28
7+
8+
This release removes the Boost dependency and switched to C++11.
9+
10+
### Changes to mallocMC 2.3.1crp
11+
12+
**Features**
13+
- Cleaning, remove Boost dependency & C++11 Migration #169
14+
15+
**Bug fixes**
16+
- Choose the value for the -arch nvcc flag depending on CUDA version #164 #165
17+
18+
**Misc:**
19+
- Travis CI: GCC 5.5.0 + CUDA 9.1.85 #170
20+
- Adding headers to projects and applied clang-tidy #171
21+
- clang-format #172
22+
23+
Thanks to Sergei Bastrakov, Bernhard Manfred Gruber and Axel Huebl for contributing to this release!
24+
425
2.3.1crp
526
--------
627
**Date:** 2019-02-14

CMakeLists.txt

Lines changed: 28 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
project(mallocMC)
2-
cmake_minimum_required(VERSION 2.8.12.2)
1+
project(mallocMC LANGUAGES CUDA CXX)
2+
cmake_minimum_required(VERSION 3.8)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
36

47
# helper for libs and packages
8+
set(CMAKE_CUDA_STANDARD 11)
9+
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
510
set(CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/"
611
"$ENV{CUDA_ROOT}" "$ENV{BOOST_ROOT}")
712

@@ -14,64 +19,37 @@ set(CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/"
1419
################################################################################
1520

1621
if(POLICY CMP0074)
17-
cmake_policy(SET CMP0074 NEW)
22+
cmake_policy(SET CMP0074 NEW)
1823
endif()
1924

2025

2126
###############################################################################
2227
# CUDA
2328
###############################################################################
24-
find_package(CUDA REQUIRED)
25-
set(CUDA_NVCC_FLAGS "-arch=sm_20;-use_fast_math;")
26-
set(CUDA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
27-
include_directories(${CUDA_INCLUDE_DIRS})
28-
cuda_include_directories(${CUDA_INCLUDE_DIRS})
29+
if(NOT DEFINED COMPUTE_CAPABILITY)
30+
set(COMPUTE_CAPABILITY "30")
31+
endif()
32+
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_${COMPUTE_CAPABILITY} -use_fast_math")
2933

3034
OPTION(CUDA_OUTPUT_INTERMEDIATE_CODE "Output ptx code" OFF)
3135
if(CUDA_OUTPUT_INTERMEDIATE_CODE)
32-
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xptxas;-v;--keep")
33-
endif(CUDA_OUTPUT_INTERMEDIATE_CODE)
36+
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xptxas -v --keep")
37+
endif()
3438

3539
SET(CUDA_OPTIMIZATION_TYPE "unset" CACHE STRING "CUDA Optimization")
3640
set_property(CACHE CUDA_OPTIMIZATION_TYPE PROPERTY STRINGS "unset;-G0;-O0;-O1;-O2;-O3")
37-
if(NOT ${CUDA_OPTIMIZATION_TYPE} STREQUAL "unset")
38-
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};${CUDA_OPTIMIZATION_TYPE}")
41+
if(NOT ${CUDA_OPTIMIZATION_TYPE} STREQUAL "unset")
42+
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDA_OPTIMIZATION_TYPE}")
3943
endif()
4044

4145

42-
###############################################################################
43-
# Boost
44-
###############################################################################
45-
find_package(Boost 1.48.0 REQUIRED)
46-
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
47-
set(LIBS ${LIBS} ${Boost_LIBRARIES})
48-
49-
# nvcc + boost 1.55 work around
50-
if(Boost_VERSION EQUAL 105500)
51-
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} \"-DBOOST_NOINLINE=__attribute__((noinline))\" ")
52-
endif(Boost_VERSION EQUAL 105500)
53-
54-
5546
################################################################################
5647
# Warnings
5748
################################################################################
58-
# GNU
5949
if(CMAKE_COMPILER_IS_GNUCXX)
60-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
61-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
62-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
63-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
64-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
65-
# new warning in gcc 4.8 (flag ignored in previous version)
66-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
67-
# ICC
50+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -Wno-unknown-pragmas -Wextra -Wno-unused-parameter -Wno-unused-local-typedefs")
6851
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
69-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
70-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
71-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_NO_VARIADIC_TEMPLATES")
72-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_NO_CXX11_VARIADIC_TEMPLATES")
73-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_NO_FENV_H")
74-
# PGI
52+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow")
7553
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
7654
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Minform=inform")
7755
endif()
@@ -87,28 +65,19 @@ INSTALL(
8765
DESTINATION include
8866
PATTERN ".git" EXCLUDE
8967
PATTERN "mallocMC_config.hpp" EXCLUDE
90-
)
68+
)
9169

9270

9371
###############################################################################
9472
# Executables
9573
###############################################################################
74+
file(GLOB_RECURSE headers src/include/**)
75+
add_custom_target(mallocMC SOURCES ${headers}) # create a target with the header files for IDE projects
76+
source_group(TREE ${CMAKE_CURRENT_LIST_DIR}/src/include FILES ${headers})
77+
78+
include_directories(${CMAKE_CURRENT_LIST_DIR}/src/include)
79+
add_executable(mallocMC_Example01 EXCLUDE_FROM_ALL examples/mallocMC_example01.cu examples/mallocMC_example01_config.hpp)
80+
add_executable(mallocMC_Example02 EXCLUDE_FROM_ALL examples/mallocMC_example02.cu)
81+
add_executable(mallocMC_Example03 EXCLUDE_FROM_ALL examples/mallocMC_example03.cu)
82+
add_executable(VerifyHeap EXCLUDE_FROM_ALL tests/verify_heap.cu tests/verify_heap_config.hpp)
9683
add_custom_target(examples DEPENDS mallocMC_Example01 mallocMC_Example02 mallocMC_Example03 VerifyHeap)
97-
98-
cuda_add_executable(mallocMC_Example01
99-
EXCLUDE_FROM_ALL
100-
examples/mallocMC_example01.cu )
101-
cuda_add_executable(mallocMC_Example02
102-
EXCLUDE_FROM_ALL
103-
examples/mallocMC_example02.cu )
104-
cuda_add_executable(mallocMC_Example03
105-
EXCLUDE_FROM_ALL
106-
examples/mallocMC_example03.cu )
107-
cuda_add_executable(VerifyHeap
108-
EXCLUDE_FROM_ALL
109-
tests/verify_heap.cu )
110-
111-
target_link_libraries(mallocMC_Example01 ${LIBS})
112-
target_link_libraries(mallocMC_Example02 ${LIBS})
113-
target_link_libraries(mallocMC_Example03 ${LIBS})
114-
target_link_libraries(VerifyHeap ${LIBS})

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Contributing
2+
3+
## Formatting
4+
5+
Please format your code before before opening pull requests using clang-format and the .clang-format file placed in the repository root.
6+
7+
### Visual Studio and CLion
8+
Suport for clang-format is built-in since Visual Studio 2017 15.7 and CLion 2019.1.
9+
The .clang-format file in the repository will be automatically detected and formatting is done as you type, or triggered when pressing the format hotkey.
10+
11+
### Bash
12+
First install clang-format. Instructions therefore can be found on the web. To format you can run this command in bash:
13+
```
14+
find -iname *.cu -o -iname *.hpp | xargs clang-format-10 -i
15+
```

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ mallocMC is header-only, but requires a few other C++ libraries to be
2222
available. Our installation notes can be found in [INSTALL.md](INSTALL.md).
2323

2424

25+
Contributing
26+
------------
27+
28+
Rules for contributions are found in [CONTRIBUTING.md](CONTRIBUTING.md).
29+
2530
On the ScatterAlloc Algorithm
2631
-----------------------------
2732

Usage.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ Currently, there are the following policy classes available:
1919

2020
|Policy | Policy Classes (implementations) | description |
2121
|------- |----------------------------------| ----------- |
22-
|**CreationPolicy** | Scatter`<conf1,conf2>` | A scattered allocation to tradeoff fragmentation for allocation time, as proposed in [ScatterAlloc](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6339604). `conf1` configures the heap layout, `conf2` determines the hashing parameters|
22+
|**CreationPolicy** | Scatter`<conf1,conf2>` | A scattered allocation to tradeoff fragmentation for allocation time, as proposed in [ScatterAlloc](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6339604). `conf1` configures the heap layout, `conf2` determines the hashing parameters|
2323
| | OldMalloc | device-side malloc/new and free/delete syscalls as implemented on NVidia CUDA graphics cards with compute capability sm_20 and higher |
24-
|**DistributionPolicy** | XMallocSIMD`<conf>` | SIMD optimization for warp-wide allocation on NVIDIA CUDA accelerators, as proposed by [XMalloc](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5577907). `conf` is used to determine the pagesize. If used in combination with *Scatter*, the pagesizes must match |
24+
|**DistributionPolicy** | XMallocSIMD`<conf>` | SIMD optimization for warp-wide allocation on NVIDIA CUDA accelerators, as proposed by [XMalloc](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5577907). `conf` is used to determine the pagesize. If used in combination with *Scatter*, the pagesizes must match |
2525
| | Noop | no workload distribution at all |
26-
|**OOMPolicy** | ReturnNull | pointers will be *NULL*, if the request could not be fulfilled |
26+
|**OOMPolicy** | ReturnNull | pointers will be *nullptr*, if the request could not be fulfilled |
2727
| | ~~BadAllocException~~ | will throw a `std::bad_alloc` exception. The accelerator has to support exceptions |
2828
|**ReservePoolPolicy** | SimpleCudaMalloc | allocate a fixed heap with `CudaMalloc` |
2929
| | CudaSetLimits | call to `CudaSetLimits` to increase the available Heap (e.g. when using *OldMalloc*) |
30-
|**AlignmentPolicy** | Shrink`<conf>` | shrinks the pool so that the starting pointer is well aligned, applies padding to requested memory chunks. `conf` is used to determine the alignment|
30+
|**AlignmentPolicy** | Shrink`<conf>` | shrinks the pool so that the starting pointer is well aligned, applies padding to requested memory chunks. `conf` is used to determine the alignment|
3131
| | Noop | no alignment at all |
3232

3333
The user has to choose one of each policy that will form a useful allocator
@@ -45,7 +45,7 @@ to the policy class:
4545
```c++
4646
// configure the AlignmentPolicy "Shrink"
4747
struct ShrinkConfig : mallocMC::AlignmentPolicies::Shrink<>::Properties {
48-
typedef boost::mpl::int_<16> dataAlignment;
48+
static constexpr auto dataAlignment = 16;
4949
};
5050
```
5151
@@ -57,29 +57,29 @@ parameters to create the desired allocator type:
5757
```c++
5858
using namespace mallocMC;
5959
60-
typedef mallocMC::Allocator<
60+
using Allocator1 = mallocMC::Allocator<
6161
CreationPolicy::OldMalloc,
6262
DistributionPolicy::Noop,
6363
OOMPolicy::ReturnNull,
6464
ReservePoolPolicy::CudaSetLimits,
6565
AlignmentPolicy::Noop
66-
> Allocator1;
66+
>;
6767
```
6868

6969
`Allocator1` will resemble the behaviour of classical device-side allocation known
7070
from NVIDIA CUDA since compute capability sm_20. To get a more novel allocator, one
71-
could create the following typedef instead:
71+
could create the following alias instead:
7272

7373
```c++
7474
using namespace mallocMC;
7575

76-
typedef mallocMC::Allocator<
76+
using ScatterAllocator = mallocMC::Allocator<
7777
CreationPolicies::Scatter<>,
7878
DistributionPolicies::XMallocSIMD<>,
7979
OOMPolicies::ReturnNull,
8080
ReservePoolPolicies::SimpleCudaMalloc,
8181
AlignmentPolicies::Shrink<ShrinkConfig>
82-
> ScatterAllocator;
82+
>;
8383
```
8484

8585
Notice, how the policy classes `Scatter` and `XMallocSIMD` are instantiated without
@@ -122,13 +122,13 @@ A simplistic example would look like this:
122122
123123
namespace mallocMC = MC;
124124
125-
typedef MC::Allocator<
125+
using ScatterAllocator = MC::Allocator<
126126
MC::CreationPolicies::Scatter<>,
127127
MC::DistributionPolicies::XMallocSIMD<>,
128128
MC::OOMPolicies::ReturnNull,
129129
MC::ReservePoolPolicies::SimpleCudaMalloc,
130130
MC::AlignmentPolicies::Shrink<ShrinkConfig>
131-
> ScatterAllocator;
131+
>;
132132
133133
__global__ exampleKernel(ScatterAllocator::AllocatorHandle sah)
134134
{

0 commit comments

Comments
 (0)