Skip to content

Commit

Permalink
comment cleanup and copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Mauney committed Aug 30, 2024
1 parent 0f66ba1 commit ece0a3c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 43 deletions.
13 changes: 13 additions & 0 deletions ports-of-call/array.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// © (or copyright) 2019-2024. Triad National Security, LLC. All rights
// reserved. This program was produced under U.S. Government contract
// 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is
// operated by Triad National Security, LLC for the U.S. Department of
// Energy/National Nuclear Security Administration. All rights in the
// program are reserved by Triad National Security, LLC, and the
// U.S. Department of Energy/National Nuclear Security
// Administration. The Government is granted for itself and others acting
// on its behalf a nonexclusive, paid-up, irrevocable worldwide license
// in this material to reproduce, prepare derivative works, distribute
// copies to the public, perform publicly and display publicly, and to
// permit others to do so.

#ifndef _PORTS_OF_CALL_ARRAY_HPP_
#define _PORTS_OF_CALL_ARRAY_HPP_

Expand Down
13 changes: 13 additions & 0 deletions ports-of-call/utility/array_algo.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// © (or copyright) 2019-2024. Triad National Security, LLC. All rights
// reserved. This program was produced under U.S. Government contract
// 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is
// operated by Triad National Security, LLC for the U.S. Department of
// Energy/National Nuclear Security Administration. All rights in the
// program are reserved by Triad National Security, LLC, and the
// U.S. Department of Energy/National Nuclear Security
// Administration. The Government is granted for itself and others acting
// on its behalf a nonexclusive, paid-up, irrevocable worldwide license
// in this material to reproduce, prepare derivative works, distribute
// copies to the public, perform publicly and display publicly, and to
// permit others to do so.

#ifndef _PORTSOFCALL_UTILITY_ARRAY_ALGO_HPP_
#define _PORTSOFCALL_UTILITY_ARRAY_ALGO_HPP_

Expand Down
54 changes: 13 additions & 41 deletions ports-of-call/utility/index_algo.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// © (or copyright) 2019-2024. Triad National Security, LLC. All rights
// reserved. This program was produced under U.S. Government contract
// 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is
// operated by Triad National Security, LLC for the U.S. Department of
// Energy/National Nuclear Security Administration. All rights in the
// program are reserved by Triad National Security, LLC, and the
// U.S. Department of Energy/National Nuclear Security
// Administration. The Government is granted for itself and others acting
// on its behalf a nonexclusive, paid-up, irrevocable worldwide license
// in this material to reproduce, prepare derivative works, distribute
// copies to the public, perform publicly and display publicly, and to
// permit others to do so.

#ifndef _PORTSOFCALL_UTILITY_INDEX_ALGO_HPP_
#define _PORTSOFCALL_UTILITY_INDEX_ALGO_HPP_

Expand All @@ -9,47 +22,6 @@

namespace util {

/*
template <auto I, class T, std::size_t N>
PORTABLE_FORCEINLINE_FUNCTION static constexpr auto
get_stride(std::array<T, N> const &dim) {
static_assert(I < dim.size(), "Dim index is out of bounds");
// column major
return std::accumulate(std::begin(dim), std::begin(dim) + I, std::size_t{1},
std::multiplies<std::size_t>{});
}
namespace detail {
template <class T, std::size_t N, std::size_t... Is>
PORTABLE_FORCEINLINE_FUNCTION static constexpr auto
get_strides_impl(std::array<T, N> const &dim, std::index_sequence<Is...>) {
return std::array{get_stride<Is>(dim)...};
}
} // namespace detail
template <class T, std::size_t N>
PORTABLE_FORCEINLINE_FUNCTION static constexpr auto
get_strides(std::array<T, N> const &dim) {
return detail::get_strides_impl(dim, std::make_index_sequence<dim.size()>{});
}
template <class T, std::size_t N>
PORTABLE_FORCEINLINE_FUNCTION static constexpr auto
fast_findex(std::array<T, N> const &ijk, std::array<T, N> const &dim,
std::array<T, N> const &stride) {
// TODO: assert ijk in bounds
return std::inner_product(std::begin(ijk), std::end(ijk), std::begin(stride),
std::size_t{0});
}
template <class T, std::size_t N>
PORTABLE_FORCEINLINE_FUNCTION static constexpr auto
findex(std::array<T, N> const &ijk, std::array<T, N> const &dim) {
return fast_findex(ijk, dim, get_strides(dim));
}
*/
template <auto I, class A>
PORTABLE_FORCEINLINE_FUNCTION static constexpr auto get_stride(A const &dim) {

Expand Down
13 changes: 13 additions & 0 deletions test/test_array.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// © (or copyright) 2019-2024. Triad National Security, LLC. All rights
// reserved. This program was produced under U.S. Government contract
// 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is
// operated by Triad National Security, LLC for the U.S. Department of
// Energy/National Nuclear Security Administration. All rights in the
// program are reserved by Triad National Security, LLC, and the
// U.S. Department of Energy/National Nuclear Security
// Administration. The Government is granted for itself and others acting
// on its behalf a nonexclusive, paid-up, irrevocable worldwide license
// in this material to reproduce, prepare derivative works, distribute
// copies to the public, perform publicly and display publicly, and to
// permit others to do so.

#include "ports-of-call/array.hpp"
#include "ports-of-call/portability.hpp"

Expand Down
17 changes: 15 additions & 2 deletions test/test_utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#ifndef _TEST_PORTOFCALL_HPP_
#define _TEST_PORTOFCALL_HPP_
// © (or copyright) 2019-2024. Triad National Security, LLC. All rights
// reserved. This program was produced under U.S. Government contract
// 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is
// operated by Triad National Security, LLC for the U.S. Department of
// Energy/National Nuclear Security Administration. All rights in the
// program are reserved by Triad National Security, LLC, and the
// U.S. Department of Energy/National Nuclear Security
// Administration. The Government is granted for itself and others acting
// on its behalf a nonexclusive, paid-up, irrevocable worldwide license
// in this material to reproduce, prepare derivative works, distribute
// copies to the public, perform publicly and display publicly, and to
// permit others to do so.

#ifndef _TEST_TEST_UTILITIES_HPP_
#define _TEST_TEST_UTILITIES_HPP_

#include <functional>
#include <ports-of-call/array.hpp>
Expand Down

0 comments on commit ece0a3c

Please sign in to comment.