MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
test_Region.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Contributors to the Media eXchange Layer project.
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#include <catch2/catch_test_macros.hpp>
6#include "Region.hpp"
7
8using namespace mxl::lib::fabrics::ofi;
9
10TEST_CASE("ofi: Region constructors", "[ofi][Constructors]")
11{
12 auto hostLoc = Region::Location::host();
13 REQUIRE(hostLoc.isHost());
14 REQUIRE(hostLoc.id() == 0);
15 REQUIRE(hostLoc.iface() == FI_HMEM_SYSTEM);
16 REQUIRE(hostLoc.toString() == "host");
17
18 auto cudaLoc = Region::Location::cuda(3);
19 REQUIRE_FALSE(cudaLoc.isHost());
20 REQUIRE(cudaLoc.id() == 3);
21 REQUIRE(cudaLoc.iface() == FI_HMEM_CUDA);
22 REQUIRE(cudaLoc.toString() == "cuda, id=3");
23}
24
25TEST_CASE("ofi: RegionGroup view and iovec conversion", "[ofi][RegionGroup]")
26{
27 std::uint64_t dummyGrainIndex = 0;
28 std::uint16_t dummyValidSlices = 0;
29
30 auto r1 = Region{0x1000, 64, &dummyGrainIndex, &dummyValidSlices, Region::Location::host()};
31 auto r2 = Region{0x2000, 128, &dummyGrainIndex, &dummyValidSlices, Region::Location::host()};
32 auto group = RegionGroup({r1, r2});
33 REQUIRE(group.size() == 2);
34
35 auto const* iovecs = group.asIovec();
36 REQUIRE(iovecs[0].iov_base == reinterpret_cast<void*>(0x1000));
37 REQUIRE(iovecs[0].iov_len == 64);
38
39 REQUIRE(iovecs[1].iov_base == reinterpret_cast<void*>(0x2000));
40 REQUIRE(iovecs[1].iov_len == 128);
41}
Represent a group of memory regions.
Definition Region.hpp:136
static Location host() noexcept
specify a host memory location.
Definition Region.cpp:23
static Location cuda(int deviceId) noexcept
specify a CUDA device memory location.
Definition Region.cpp:28
Represent a memory region (unregistered).
Definition Region.hpp:24
TEST_CASE("ofi: Region constructors", "[ofi][Constructors]")
REQUIRE(timeDelta< 33 '366 '667LL)