-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from stephenswat/refactor/remove_stl
Replace uses of STL types in device code
- Loading branch information
Showing
27 changed files
with
324 additions
and
188 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
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,125 @@ | ||
/* | ||
* This file is part of covfie, a part of the ACTS project | ||
* | ||
* Copyright (c) 2022 CERN | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cassert> | ||
#include <cstddef> | ||
#include <utility> | ||
|
||
#include <covfie/core/qualifiers.hpp> | ||
|
||
namespace covfie::array { | ||
template <typename _scalar_t, std::size_t _size> | ||
requires(_size > 0) struct array { | ||
using scalar_t = _scalar_t; | ||
using value_type = _scalar_t; | ||
static constexpr std::size_t dimensions = _size; | ||
|
||
COVFIE_DEVICE array() = default; | ||
|
||
COVFIE_DEVICE array(const scalar_t (&arr)[dimensions]) | ||
requires(dimensions > 1) | ||
: array(arr, std::make_index_sequence<dimensions>()) | ||
{ | ||
} | ||
|
||
COVFIE_DEVICE array(const scalar_t & val) | ||
: array(val, std::make_index_sequence<dimensions>()) | ||
{ | ||
} | ||
|
||
template <typename... Ts> | ||
requires(sizeof...(Ts) == dimensions) COVFIE_DEVICE array(Ts... args) | ||
: m_data{std::forward<Ts>(args)...} | ||
{ | ||
} | ||
|
||
COVFIE_DEVICE constexpr scalar_t & at(const std::size_t & n) | ||
{ | ||
assert(n < dimensions); | ||
|
||
return m_data[n]; | ||
} | ||
|
||
COVFIE_DEVICE constexpr const scalar_t & at(const std::size_t & n) const | ||
{ | ||
assert(n < dimensions); | ||
|
||
return m_data[n]; | ||
} | ||
|
||
COVFIE_DEVICE constexpr scalar_t & operator[](const std::size_t & n) | ||
{ | ||
assert(n < dimensions); | ||
|
||
return m_data[n]; | ||
} | ||
|
||
COVFIE_DEVICE constexpr const scalar_t & operator[](const std::size_t & n | ||
) const | ||
{ | ||
assert(n < dimensions); | ||
|
||
return m_data[n]; | ||
} | ||
|
||
COVFIE_DEVICE constexpr std::size_t size() const | ||
{ | ||
return dimensions; | ||
} | ||
|
||
COVFIE_DEVICE constexpr scalar_t * begin() | ||
{ | ||
return m_data + 0; | ||
} | ||
|
||
COVFIE_DEVICE constexpr const scalar_t * begin() const | ||
{ | ||
return m_data + 0; | ||
} | ||
|
||
COVFIE_DEVICE constexpr const scalar_t * cbegin() const | ||
{ | ||
return m_data + 0; | ||
} | ||
|
||
COVFIE_DEVICE constexpr scalar_t * end() | ||
{ | ||
return m_data + dimensions; | ||
} | ||
|
||
COVFIE_DEVICE constexpr const scalar_t * end() const | ||
{ | ||
return m_data + dimensions; | ||
} | ||
|
||
COVFIE_DEVICE constexpr const scalar_t * cend() const | ||
{ | ||
return m_data + dimensions; | ||
} | ||
|
||
private: | ||
template <std::size_t... Is> | ||
COVFIE_DEVICE | ||
array(const scalar_t (&arr)[dimensions], std::index_sequence<Is...>) | ||
: m_data{arr[Is]...} | ||
{ | ||
} | ||
|
||
template <std::size_t... Is> | ||
COVFIE_DEVICE array(const scalar_t & val, std::index_sequence<Is...>) | ||
: m_data{((void)Is, val)...} | ||
{ | ||
} | ||
|
||
scalar_t m_data[dimensions]; | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
|
||
#pragma once | ||
|
||
#include <array> | ||
#include <iostream> | ||
|
||
#include <covfie/core/concepts.hpp> | ||
|
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
Oops, something went wrong.