Skip to content

Commit 80bf2b0

Browse files
committed
Merge pull request #102 from ComputationalRadiationPhysics/dev
Release 2.2.0crp
2 parents 799d7d7 + ef29c73 commit 80bf2b0

File tree

11 files changed

+159
-64
lines changed

11 files changed

+159
-64
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ env:
99

1010
script:
1111
- mkdir build_tmp && cd build_tmp
12-
- cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR $TRAVIS_BUILD_DIR
12+
- CXXFLAGS="-Werror" cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR $TRAVIS_BUILD_DIR
1313
- make
1414
- make install
1515
- make examples
1616

1717
before_script:
18+
- sudo add-apt-repository --yes ppa:smspillaz/cmake-2.8.12
1819
- sudo apt-get update -qq
20+
- sudo apt-get install -q -y cmake-data cmake
1921
- sudo apt-get install -qq build-essential
2022
- sudo apt-get install -qq gcc-4.4 g++-4.4
2123
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4

CHANGELOG.md

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

4+
2.2.0crp
5+
-------------
6+
**Date:** 2015-09-25
7+
8+
This release fixes some minor bugs that occured after the release of 2.1.0crp, adds some documentation and improves the interoperability with other projects and build systems.
9+
We closed all issues documented in
10+
[Milestone *2.2.0crp: Stabilizing the release*](https://github.com/ComputationalRadiationPhysics/mallocMC/issues?milestone=5&state=closed)
11+
12+
### Changes to mallocMC 2.1.0crp
13+
14+
**Features**
15+
- the interface now provides the host function `HeapInfoVector getHeapLocations()` to obtain information about the location and size of existing mallocMC-heaps #86
16+
17+
**Bug fixes**
18+
- the function `getAvailableSlots` was always required in the policy classes, although the implementations might not provide it #89
19+
20+
**Misc:**
21+
- the code relied on `__TROW` being defined, which is not available in all compilers #91
22+
- the CMake dependency increased to CMake >= 2.8.12.2 #92
23+
- a new FindmallocMC.cmake module file is provided at https://github.com/ComputationalRadiationPhysics/cmake-modules #85
24+
- See the full changes at https://github.com/ComputationalRadiationPhysics/mallocMC/compare/2.1.0crp...2.2.0crp
25+
26+
427
2.1.0crp
528
-------------
629
**Date:** 2015-02-11

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project(mallocMC)
2-
cmake_minimum_required(VERSION 2.8.5)
2+
cmake_minimum_required(VERSION 2.8.12.2)
33

44
# helper for libs and packages
55
set(CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/"
@@ -46,18 +46,20 @@ endif(Boost_VERSION EQUAL 105500)
4646
# GNU
4747
if(CMAKE_COMPILER_IS_GNUCXX)
4848
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
49+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
4950
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
5051
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
5152
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
5253
# new warning in gcc 4.8 (flag ignored in previous version)
5354
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
54-
# ICC
55+
# ICC
5556
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
5657
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
58+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
5759
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_NO_VARIADIC_TEMPLATES")
5860
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_NO_CXX11_VARIADIC_TEMPLATES")
5961
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_NO_FENV_H")
60-
# PGI
62+
# PGI
6163
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
6264
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Minform=inform")
6365
endif()

INSTALL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Install
1515
- *Debian/Ubuntu:* `sudo apt-get install libboost-dev libboost-program-options-dev`
1616
- *Arch Linux:* `sudo pacman -S boost`
1717
- or download from [http://www.boost.org/](http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download)
18-
- `CMake` >= 2.8.5
18+
- `CMake` >= 2.8.12.2
1919
- *Debian/Ubuntu:* `sudo apt-get install cmake file cmake-curses-gui`
2020
- *Arch Linux:* `sudo pacman -S cmake`
2121
- `git` >= 1.7.9.5
@@ -58,17 +58,17 @@ Because we are linking to Boost and CUDA, the following **external dependencies*
5858

5959
If you are using CMake you can download our `FindmallocMC.cmake` module with
6060
```bash
61-
wget https://raw.githubusercontent.com/ComputationalRadiationPhysics/picongpu/dev/src/cmake/FindmallocMC.cmake
61+
wget https://raw.githubusercontent.com/ComputationalRadiationPhysics/cmake-modules/dev/FindmallocMC.cmake
6262
# read the documentation
6363
cmake -DCMAKE_MODULE_PATH=. --help-module FindmallocMC | less
6464
```
6565

6666
and use the following lines in your `CMakeLists.txt`:
6767
```cmake
68-
# this example will require at least CMake 2.8.5
69-
cmake_minimum_required(VERSION 2.8.5)
68+
# this example will require at least CMake 2.8.12.2
69+
cmake_minimum_required(VERSION 2.8.12.2)
7070
71-
# add path to FindmallocMC.cmake, e.g. in the directory in cmake/
71+
# add path to FindmallocMC.cmake, e.g., in the directory in cmake/
7272
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
7373
7474
# find the packages that are required by mallocMC. This has to be done BEFORE

src/include/mallocMC/alignmentPolicies/Shrink_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ namespace Shrink2NS{
7474
#endif
7575
static const uint32 dataAlignment = MALLOCMC_AP_SHRINK_DATAALIGNMENT;
7676

77+
// \TODO: The static_cast can be removed once the minimal dependencies of
78+
// this project is are at least CUDA 7.0 and gcc 4.8.2
7779
BOOST_STATIC_ASSERT(static_cast<uint32>(dataAlignment) > 0);
7880
//dataAlignment must also be a power of 2!
7981
BOOST_STATIC_ASSERT(dataAlignment && !(dataAlignment & (dataAlignment-1)) );

src/include/mallocMC/distributionPolicies/XMallocSIMD_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ namespace DistributionPolicies{
7777

7878
//all the properties must be unsigned integers > 0
7979
BOOST_STATIC_ASSERT(!std::numeric_limits<typename Properties::pagesize::type>::is_signed);
80+
81+
// \TODO: The static_cast can be removed once the minimal dependencies of
82+
// this project is are at least CUDA 7.0 and gcc 4.8.2
8083
BOOST_STATIC_ASSERT(static_cast<uint32>(pagesize) > 0);
8184

8285
public:

src/include/mallocMC/mallocMC_hostclass.hpp

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <cassert>
4040

4141
#include <boost/mpl/assert.hpp>
42+
#include <vector>
4243

4344
namespace mallocMC{
4445

@@ -57,6 +58,47 @@ namespace mallocMC{
5758
static const bool providesAvailableSlots = T::CreationPolicy::providesAvailableSlots::value;
5859
};
5960

61+
class HeapInfo{
62+
public:
63+
void* p;
64+
size_t size;
65+
};
66+
67+
namespace detail{
68+
69+
/**
70+
* @brief Template class to call getAvailableSlots[Host|Accelerator] if the CreationPolicy provides it.
71+
*
72+
* Returns 0 else.
73+
*
74+
* @tparam T_CreationPolicy The desired type of a CreationPolicy
75+
* @tparam T_ProvidesAvailableSlotsHost If the CreationPolicy provides getAvailableSlotsHost
76+
*/
77+
template<typename T_ProvidesAvailableSlotsHost>
78+
struct GetAvailableSlotsIfAvail
79+
{
80+
template<typename T_Allocator>
81+
MAMC_HOST MAMC_ACCELERATOR
82+
static unsigned getAvailableSlots(size_t slotSize, T_Allocator &){
83+
return 0;
84+
}
85+
};
86+
template<>
87+
struct GetAvailableSlotsIfAvail<
88+
boost::mpl::bool_<true> >
89+
{
90+
template<typename T_Allocator>
91+
MAMC_HOST MAMC_ACCELERATOR
92+
static unsigned getAvailableSlots(size_t slotSize, T_Allocator & alloc){
93+
#ifdef __CUDA_ARCH__
94+
return alloc.getAvailableSlotsAccelerator(slotSize);
95+
#else
96+
return alloc.getAvailableSlotsHost(slotSize, alloc);
97+
#endif
98+
}
99+
};
100+
101+
}
60102

61103
/**
62104
* @brief "HostClass" that combines all policies to a useful allocator
@@ -93,9 +135,12 @@ namespace mallocMC{
93135
typedef T_ReservePoolPolicy ReservePoolPolicy;
94136
typedef T_AlignmentPolicy AlignmentPolicy;
95137

138+
typedef std::vector<HeapInfo> HeapInfoVector;
139+
96140
private:
97141
typedef boost::uint32_t uint32;
98142
void* pool;
143+
HeapInfo heapInfos;
99144

100145
public:
101146

@@ -129,19 +174,21 @@ namespace mallocMC{
129174
pool = ReservePoolPolicy::setMemPool(size);
130175
boost::tie(pool,size) = AlignmentPolicy::alignPool(pool,size);
131176
void* h = CreationPolicy::initHeap(*this,pool,size);
177+
heapInfos.p=pool;
178+
heapInfos.size=size;
132179

133180
/*
134181
* This is a workaround for a bug with getAvailSlotsPoly:
135182
* Due to some problems with conditional compilation (possibly a CUDA bug),
136-
* this host function must explicitly be used from inside a host
183+
* getAvailableSlotsHost must explicitly be used from inside a host
137184
* function at least once. Doing it here guarantees that it is executed
138185
* and that this execution happens on the host. Usually, simply defining
139186
* this inside a host function (without actually executing it) would be
140187
* sufficient. However, due to the template nature of policy based
141188
* design, functions are only compiled if they are actually used.
142189
*/
143-
if(CreationPolicy::providesAvailableSlots::value)
144-
CreationPolicy::getAvailableSlotsHost(1024,*this); //actual slot size does not matter
190+
detail::GetAvailableSlotsIfAvail<boost::mpl::bool_<CreationPolicy::providesAvailableSlots::value> >
191+
::getAvailableSlots(1024, *this); //actual slot size does not matter
145192

146193
return h;
147194
}
@@ -167,23 +214,17 @@ namespace mallocMC{
167214
// polymorphism over the availability of getAvailableSlots
168215
MAMC_HOST MAMC_ACCELERATOR
169216
unsigned getAvailableSlots(size_t slotSize){
170-
return getAvailSlotsPoly(slotSize, boost::mpl::bool_<CreationPolicy::providesAvailableSlots::value>());
171-
}
217+
slotSize = AlignmentPolicy::applyPadding(slotSize);
172218

173-
private:
174-
MAMC_HOST MAMC_ACCELERATOR
175-
unsigned getAvailSlotsPoly(size_t slotSize, boost::mpl::bool_<false>){
176-
return 0;
219+
return detail::GetAvailableSlotsIfAvail<boost::mpl::bool_<CreationPolicy::providesAvailableSlots::value> >
220+
::getAvailableSlots(slotSize, *this);
177221
}
178222

179-
MAMC_HOST MAMC_ACCELERATOR
180-
unsigned getAvailSlotsPoly(size_t slotSize, boost::mpl::bool_<true>){
181-
slotSize = AlignmentPolicy::applyPadding(slotSize);
182-
#ifdef __CUDA_ARCH__
183-
return CreationPolicy::getAvailableSlotsAccelerator(slotSize);
184-
#else
185-
return CreationPolicy::getAvailableSlotsHost(slotSize,*this);
186-
#endif
223+
MAMC_HOST
224+
HeapInfoVector getHeapLocations(){
225+
HeapInfoVector v;
226+
v.push_back(heapInfos);
227+
return v;
187228
}
188229

189230
};

src/include/mallocMC/mallocMC_overwrites.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#pragma once
3434

3535
#include "mallocMC_prefixes.hpp"
36+
#include <vector>
3637

3738
/** Creates a global object of a many core memory allocator
3839
*
@@ -82,6 +83,12 @@ bool providesAvailableSlots(){ \
8283
} /* end namespace mallocMC */
8384

8485

86+
/** __THROW is defined in Glibc so it is not available on all platforms.
87+
*/
88+
#ifndef __THROW
89+
#define __THROW
90+
#endif
91+
8592
/** Create the functions malloc() and free() inside a namespace
8693
*
8794
* This allows for a peaceful coexistence between different functions called
@@ -103,6 +110,20 @@ void free(void* p) __THROW \
103110
} /* end namespace mallocMC */
104111

105112

113+
/** Create the function getHeapLocations inside a namespace
114+
*
115+
* This returns a vector of type mallocMC::HeapInfo. The HeapInfo should at least
116+
* contain the pointer to the heap (on device) and its size.
117+
*/
118+
#define MALLOCMC_HEAPLOC() \
119+
namespace mallocMC{ \
120+
MAMC_HOST \
121+
std::vector<mallocMC::HeapInfo> getHeapLocations() \
122+
{ \
123+
return mallocMC::mallocMCGlobalObject.getHeapLocations(); \
124+
} \
125+
} /* end namespace mallocMC */
126+
106127

107128
/* if the defines do not exist (wrong CUDA version etc),
108129
* create at least empty defines
@@ -121,4 +142,5 @@ void free(void* p) __THROW \
121142
#define MALLOCMC_SET_ALLOCATOR_TYPE(MALLOCMC_USER_DEFINED_TYPE) \
122143
MALLOCMC_GLOBAL_FUNCTIONS(MALLOCMC_USER_DEFINED_TYPE) \
123144
MALLOCMC_MALLOC() \
145+
MALLOCMC_HEAPLOC() \
124146
MALLOCMC_AVAILABLESLOTS()

0 commit comments

Comments
 (0)