-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with memory pools and add mutexes
- Loading branch information
1 parent
f0c7a26
commit 6920ce1
Showing
5 changed files
with
136 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
/* | ||
* (C) Copyright 2024- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation | ||
* nor does it submit to any jurisdiction. | ||
*/ | ||
|
||
#include <iostream> | ||
#include <cstddef> | ||
|
||
#include "pluto/pluto.h" | ||
|
||
[[maybe_unused]] constexpr std::size_t kb = 1024; | ||
[[maybe_unused]] constexpr std::size_t mb = 1024*kb; | ||
[[maybe_unused]] constexpr std::size_t gb = 1024*mb; | ||
|
||
class vector { | ||
public: | ||
vector(std::size_t n, const pluto::allocator<std::byte>& alloc) : | ||
size_{n}, | ||
alloc_{alloc} { | ||
if (size_) { | ||
data_ = alloc_.allocate(size_); | ||
} | ||
} | ||
~vector() { | ||
if(size_) { | ||
alloc_.deallocate(data_,size_); | ||
} | ||
} | ||
std::byte* data_ = nullptr; | ||
std::size_t size_ = 0; | ||
pluto::allocator<std::byte> alloc_; | ||
}; | ||
|
||
|
||
int main(int argc, char* argv[]) { | ||
std::cout << "BEGIN" << std::endl; | ||
|
||
pluto::TraceOptions::instance().enabled = true; | ||
|
||
pluto::allocator<std::byte> allocator(pluto::pool_resource()); | ||
// using vector = pluto::host::vector<std::byte>; | ||
|
||
vector array1(200*mb,allocator); | ||
vector array2(200*mb,allocator); | ||
vector array3(1.2*gb,allocator); | ||
|
||
|
||
std::cout << "END" << std::endl; | ||
} |