Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templated MD arrays #39

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ target_compile_features(${POCLIB}
cxx_std_17
)

#NOTE this option is done downstream, maybe poc should control it
set(with_cxx "$<COMPILE_LANGUAGE:CXX>")
set(ps_kokkos "$<BOOL:${PORTABILITY_STRATEGY_KOKKOS}>")

target_compile_options(${POCLIB}
INTERFACE
$<${with_cxx}:$<${ps_kokkos}:--expt-relaxed-constexpr>>)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the event of +kokkos~cuda, wouldn't this result in a compile error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it, but POC doesn't have a USE_CUDA or similar like singularity-eos does, so I need to probe which compiler is being used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how I've done it in other projects:

  get_target_property(kokkos_link_libs Kokkos::kokkoscore
                      INTERFACE_LINK_LIBRARIES)
  string(REGEX MATCH "CUDA"
         kokkos_has_cuda_libs "${kokkos_link_libs}")
  ...
  if(kokkos_has_cuda_libs)
    do cuda stuff...
  endif()


# TESTING
# ----------------------------------------
if(PORTS_OF_CALL_BUILD_TESTING)
Expand Down
20 changes: 20 additions & 0 deletions ports-of-call/array.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
// © (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_

#include "portability.hpp"
#include "portable_errors.hpp"
#include "ports-of-call/utility/array_algo.hpp"

#include <cstddef>
#include <iterator>
Expand Down Expand Up @@ -192,6 +206,12 @@ struct array {
}
}

PORTABLE_FUNCTION constexpr bool operator==(const array &rhs) const {
for (size_type i = 0; i < N; ++i)
if (arr[i] != rhs.arr[i]) return false;
return true;
}

//! swap the array contents with another
PORTABLE_FUNCTION constexpr void swap(array &other) {
for (size_type i = 0; i < N; ++i) {
Expand Down
Loading
Loading