|
| 1 | +/* |
| 2 | + mallocMC: Memory Allocator for Many Core Architectures. |
| 3 | +
|
| 4 | + Copyright 2025 Helmholtz-Zentrum Dresden - Rossendorf |
| 5 | +
|
| 6 | + Author(s): Julian Johannes Lenz, Rene Widera |
| 7 | +
|
| 8 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + of this software and associated documentation files (the "Software"), to deal |
| 10 | + in the Software without restriction, including without limitation the rights |
| 11 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + copies of the Software, and to permit persons to whom the Software is |
| 13 | + furnished to do so, subject to the following conditions: |
| 14 | +
|
| 15 | + The above copyright notice and this permission notice shall be included in |
| 16 | + all copies or substantial portions of the Software. |
| 17 | +
|
| 18 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + THE SOFTWARE. |
| 25 | +*/ |
| 26 | + |
| 27 | +#include "mallocMC/allocator.hpp" |
| 28 | + |
| 29 | +#include "mallocMC/alignmentPolicies/Shrink.hpp" |
| 30 | +#include "mallocMC/creationPolicies/FlatterScatter.hpp" |
| 31 | +#include "mallocMC/distributionPolicies/Noop.hpp" |
| 32 | +#include "mallocMC/oOMPolicies/ReturnNull.hpp" |
| 33 | +#include "mallocMC/reservePoolPolicies/AlpakaBuf.hpp" |
| 34 | + |
| 35 | +#include <alpaka/example/ExampleDefaultAcc.hpp> |
| 36 | + |
| 37 | +#include <catch2/catch_test_macros.hpp> |
| 38 | +#include <mallocMC/mallocMC.hpp> |
| 39 | +using Dim = alpaka::DimInt<1>; |
| 40 | +using Idx = std::size_t; |
| 41 | + |
| 42 | +// Define the device accelerator |
| 43 | +using Acc = alpaka::ExampleDefaultAcc<Dim, Idx>; |
| 44 | + |
| 45 | +TEST_CASE("Allocator") |
| 46 | +{ |
| 47 | + SECTION("can be initialised with 0 memory.") |
| 48 | + { |
| 49 | + auto const platform = alpaka::Platform<Acc>{}; |
| 50 | + auto const dev = alpaka::getDevByIdx(platform, 0); |
| 51 | + auto queue = alpaka::Queue<Acc, alpaka::Blocking>{dev}; |
| 52 | + |
| 53 | + mallocMC::Allocator< |
| 54 | + Acc, |
| 55 | + mallocMC::CreationPolicies::FlatterScatter<>, |
| 56 | + mallocMC::DistributionPolicies::Noop, |
| 57 | + mallocMC::OOMPolicies::ReturnNull, |
| 58 | + mallocMC::ReservePoolPolicies::AlpakaBuf<Acc>, |
| 59 | + mallocMC::AlignmentPolicies::Shrink<>> |
| 60 | + allocator{dev, queue, 0}; |
| 61 | + } |
| 62 | +} |
0 commit comments