Skip to content
Snippets Groups Projects
Commit d211596a authored by Sergei Zharko's avatar Sergei Zharko
Browse files

Algo: moving the PartitionedVector, PartitionedSpan and PODVector into a...

Algo: moving the PartitionedVector, PartitionedSpan and PODVector into a separate header-only library
parent 3ef736c3
No related branches found
No related tags found
1 merge request!2085CbmContainers/OnlineContainers library
......@@ -52,13 +52,12 @@ if (CBM_ONLINE_STANDALONE)
add_subdirectory(../external external)
endif()
add_subdirectory(kfp)
add_subdirectory(base)
add_subdirectory(log)
add_subdirectory(ca)
add_subdirectory(data)
add_subdirectory(kf)
add_subdirectory(ca)
add_subdirectory(base)
#add_subdirectory(kfp) # For KFParticleOnline
add_subdirectory(kfp)
# exclude unittests from being build inside the container
if (NOT CBM_ONLINE_STANDALONE)
......@@ -227,6 +226,7 @@ target_include_directories(Algo
target_link_libraries(Algo
PUBLIC OnlineData
PVector
KfCore
CaCore
ROOT::GenVector
......@@ -305,6 +305,7 @@ if (NOT CBM_ONLINE_STANDALONE)
target_link_libraries(AlgoOffline
PUBLIC CbmData
PVector
KfCoreOffline
CaCoreOffline
ROOT::GenVector
......
add_subdirectory(yaml)
add_subdirectory(pvector)
set(INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
)
add_library(PVector INTERFACE)
target_include_directories(PVector
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(PVector
INTERFACE GSL
)
install(
FILES
PartitionedVector.h
PartitionedSpan.h
DESTINATION
include/
)
File moved
......@@ -4,7 +4,7 @@
#ifndef CBM_ALGO_BASE_POD_VECTOR_H
#define CBM_ALGO_BASE_POD_VECTOR_H
#include "util/PODAllocator.h"
#include "PODAllocator.h"
#include <vector>
......
......@@ -4,12 +4,11 @@
#ifndef CBM_ALGO_BASE_PARTITIONED_SPAN_H
#define CBM_ALGO_BASE_PARTITIONED_SPAN_H
#include "Definitions.h"
#include <array>
#include <gsl/span>
#include <stdexcept>
#include <vector>
#include <cstdint>
namespace cbm::algo
{
......@@ -36,7 +35,7 @@ namespace cbm::algo
// #if defined(__INTELLISENSE__) || defined(__clang__)
template<typename Allocator>
PartitionedSpan(std::vector<T, Allocator>& container, gsl::span<const size_t> offsets,
gsl::span<const u32> addresses)
gsl::span<const uint32_t> addresses)
: fData(container)
, fOffsets(offsets)
, fAdresses(addresses)
......@@ -47,7 +46,7 @@ namespace cbm::algo
// FIXME disable if T is non-const via SFINAE, otherwise get misleading compiler errors
template<typename Allocator>
PartitionedSpan(const std::vector<T, Allocator>& container, gsl::span<const size_t> offsets,
gsl::span<const u32> addresses)
gsl::span<const uint32_t> addresses)
: fData(container)
, fOffsets(offsets)
, fAdresses(addresses)
......@@ -56,7 +55,7 @@ namespace cbm::algo
}
template<size_t N>
PartitionedSpan(std::array<T, N>& container, gsl::span<const size_t> offsets, gsl::span<const u32> addresses)
PartitionedSpan(std::array<T, N>& container, gsl::span<const size_t> offsets, gsl::span<const uint32_t> addresses)
: fData(container)
, fOffsets(offsets)
, fAdresses(addresses)
......@@ -66,7 +65,7 @@ namespace cbm::algo
// FIXME disable if T is non-const via SFINAE
template<size_t N>
PartitionedSpan(const std::array<T, N>& container, gsl::span<const size_t> offsets, gsl::span<const u32> addresses)
PartitionedSpan(const std::array<T, N>& container, gsl::span<const size_t> offsets, gsl::span<const uint32_t> addresses)
: fData(container)
, fOffsets(offsets)
, fAdresses(addresses)
......@@ -75,7 +74,7 @@ namespace cbm::algo
}
// #endif
PartitionedSpan(gsl::span<T> data, gsl::span<const size_t> offsets, gsl::span<const u32> addresses)
PartitionedSpan(gsl::span<T> data, gsl::span<const size_t> offsets, gsl::span<const uint32_t> addresses)
: fData(data)
, fOffsets(offsets)
, fAdresses(addresses)
......@@ -115,16 +114,16 @@ namespace cbm::algo
return UnsafePartitionSpan(i);
}
u32 Address(size_t i) const
uint32_t Address(size_t i) const
{
EnsureBounds(i);
return fAdresses[i];
}
std::pair<gsl::span<T>, u32> Partition(size_t i) const
std::pair<gsl::span<T>, uint32_t> Partition(size_t i) const
{
EnsureBounds(i);
return std::pair<gsl::span<T>, u32>(UnsafePartitionSpan(i), fAdresses[i]);
return std::pair<gsl::span<T>, uint32_t>(UnsafePartitionSpan(i), fAdresses[i]);
}
size_t NPartitions() const { return fAdresses.size(); }
......@@ -139,7 +138,7 @@ namespace cbm::algo
gsl::span<T> Data() const { return fData; }
gsl::span<const u32> Addresses() const { return fAdresses; }
gsl::span<const uint32_t> Addresses() const { return fAdresses; }
gsl::span<const size_t> Offsets() const { return fOffsets; }
......@@ -149,7 +148,7 @@ namespace cbm::algo
gsl::span<T> fData;
gsl::span<const size_t> fOffsets;
gsl::span<const u32> fAdresses;
gsl::span<const uint32_t> fAdresses;
// FIXME code duplication with PartitionedVector
......@@ -176,10 +175,10 @@ namespace cbm::algo
// template auto deduction
template<typename T, template<typename> class Container>
PartitionedSpan(Container<T>&, gsl::span<const size_t>, gsl::span<const u32>) -> PartitionedSpan<T>;
PartitionedSpan(Container<T>&, gsl::span<const size_t>, gsl::span<const uint32_t>) -> PartitionedSpan<T>;
template<typename T, template<typename> class Container>
PartitionedSpan(const Container<T>&, gsl::span<const size_t>, gsl::span<const u32>) -> PartitionedSpan<const T>;
PartitionedSpan(const Container<T>&, gsl::span<const size_t>, gsl::span<const uint32_t>) -> PartitionedSpan<const T>;
template<typename T, typename Allocator>
PartitionedSpan(PartitionedVector<T, Allocator>&) -> PartitionedSpan<T>;
......
......@@ -4,8 +4,7 @@
#ifndef CBM_ALGO_BASE_PARTITIONED_VECTOR_H
#define CBM_ALGO_BASE_PARTITIONED_VECTOR_H
#include "Definitions.h"
#include "util/PODAllocator.h"
#include "PODAllocator.h"
#include <boost/serialization/access.hpp>
#include <boost/serialization/vector.hpp>
......@@ -46,7 +45,7 @@ namespace cbm::algo
*
* @note Requires sizes.size() == addresses.size()
*/
PartitionedVector(Container_t&& data, gsl::span<const size_t> sizes, gsl::span<const u32> addresses)
PartitionedVector(Container_t&& data, gsl::span<const size_t> sizes, gsl::span<const uint32_t> addresses)
: fData(std::move(data))
, fOffsets()
, fAddresses(addresses.begin(), addresses.end())
......@@ -149,7 +148,7 @@ namespace cbm::algo
/**
* @brief Get the hardware address of partition i.
*/
u32 Address(size_t i) const
uint32_t Address(size_t i) const
{
EnsureBounds(i);
return fAddresses[i];
......@@ -169,19 +168,19 @@ namespace cbm::algo
/**
* @brief Get a pair of the data and the hardware address of partition i.
*/
std::pair<gsl::span<T>, u32> Partition(size_t i)
std::pair<gsl::span<T>, uint32_t> Partition(size_t i)
{
EnsureBounds(i);
return std::pair<gsl::span<T>, u32>(UnsafePartitionSpan(i), fAddresses[i]);
return std::pair<gsl::span<T>, uint32_t>(UnsafePartitionSpan(i), fAddresses[i]);
}
/**
* @brief Get a pair of the data and the hardware address of partition i.
*/
std::pair<gsl::span<const T>, u32> Partition(size_t i) const
std::pair<gsl::span<const T>, uint32_t> Partition(size_t i) const
{
EnsureBounds(i);
return std::pair<gsl::span<const T>, u32>(UnsafePartitionSpan(i), fAddresses[i]);
return std::pair<gsl::span<const T>, uint32_t>(UnsafePartitionSpan(i), fAddresses[i]);
}
/**
......@@ -221,7 +220,7 @@ namespace cbm::algo
/**
* @brief Get the addresses.
*/
const std::vector<u32>& Addresses() const { return fAddresses; }
const std::vector<uint32_t>& Addresses() const { return fAddresses; }
/**
* @brief Get the underlying offsets.
......@@ -230,9 +229,9 @@ namespace cbm::algo
private:
Container_t fData; //< Data
std::vector<size_t> fOffsets; // < Offsets of the partitions in fData
std::vector<u32> fAddresses; //< Hardware addresses of the partitions
Container_t fData; ///< Data
std::vector<size_t> fOffsets; ///< Offsets of the partitions in fData
std::vector<uint32_t> fAddresses; ///< Addresses of the partitions
void EnsureDimensions() const
{
......
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#include "Definitions.h"
#include "PartitionedSpan.h"
#include "PartitionedVector.h"
......
......@@ -2,6 +2,8 @@
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#include "Definitions.h"
#include "PODVector.h"
#include "PartitionedVector.h"
#include "gtest/gtest.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment