Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Mauney committed Oct 16, 2024
2 parents 761d580 + 707ad53 commit e37efd7
Show file tree
Hide file tree
Showing 8 changed files with 1,180 additions and 1 deletion.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,28 @@ export(
FILE "${CMAKE_CURRENT_BINARY_DIR}/${POCLIB}Targets.cmake")


# Configuration summary ---------------------------------------------------------------------------

include(config_summary)

config_summary_header("Ports-of-Call" "ports-of-call" 30) # 30 characters seems wide enough

config_summary_block("CMake Options")
config_summary_variable("CMAKE_BUILD_TYPE")
config_summary_variable("CMAKE_C_COMPILER") # Does PoC use C or only C++?
config_summary_variable("CMAKE_C_COMPILER_VERSION")
config_summary_variable("CMAKE_C_FLAGS")
config_summary_variable("CMAKE_CXX_COMPILER")
config_summary_variable("CMAKE_CXX_COMPILER_VERSION")
config_summary_variable("CMAKE_CXX_FLAGS")

config_summary_block("Dependencies")
config_summary_dependency("Kokkos" "Kokkos") # Should this always be listed?

config_summary_block("User Options") # Are these the right user options?
config_summary_option("PORTS_OF_CALL_BUILD_TESTING")
config_summary_option("PORTABILITY_STRATEGY_CUDA")
config_summary_option("PORTABILITY_STRATEGY_KOKKOS")
config_summary_option("PORTABILITY_STRATEGY_NONE")

config_summary_print()
152 changes: 152 additions & 0 deletions cmake/config_summary.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# -------------------------------------------------------------------------------------------------
# Set some colors

string(ASCII 27 Esc)
set(color_reset "${Esc}[m")
set(color_boldblue "${Esc}[1;34m")
set(color_boldcyan "${Esc}[1;36m")
set(color_boldgreen "${Esc}[1;32m")
set(color_boldgrey "${Esc}[1;30m")
set(color_boldmagenta "${Esc}[1;35m")
set(color_boldplain "${Esc}[1m")
set(color_boldred "${Esc}[1;31m")
set(color_boldyellow "${Esc}[1;33m")
set(color_cyan "${Esc}[36m")
set(color_yellow "${Esc}[33m")

# -------------------------------------------------------------------------------------------------
# A macro for internal use -- see below for the user macros

# Print out a key-value pair (colored differently than a user option)
macro(config_summary_kvc key value color)
# Figure out spacing
string(LENGTH ${key} _slen)
math(EXPR _tlen "${_width} - ${_slen}")
string(REPEAT " " ${_tlen} _tail)
# Key
string(APPEND _summary
"${color_boldplain}"
" ${key}${_tail} : "
"${color_reset}"
)
# Value
string(APPEND _summary
"${color}"
"${value}"
"${color_reset}"
)
string(APPEND _summary "\n")
endmacro()

# -------------------------------------------------------------------------------------------------
# Macros to write the configuration summary.
# -- config_summary_header should always be called before all other config_summary_*
# -- config_summary_print should always be called after all other config_summary_*

# Print a header and do some setup
# -- Arguments:
# 0) display_name: The name of your project for printouts
# 1) cmake_name: The name for your project as known to CMake (to find variables)
# 2) optional: number of characters for variable names (must be large enough for the longest
# variable name, defaults to 48)
macro(config_summary_header display_name cmake_name)
# save the terminal width (`tput cols` was not portable, so hard-code)
set(_termwidth 80)
# pretty-print a header bar
math(EXPR _bwid "${_termwidth} - 1")
string(REPEAT "-" ${_bwid} _bar)
set(_bar "${color_boldcyan}${_bar}${color_reset}")
string(APPEND _summary "${_bar}\n")
# header message
string(APPEND _summary
"${color_boldcyan}"
"${display_name} configuration summary (version ${${cmake_name}_VERSION})\n"
"${color_reset}"
)
# pretty-print a header bar
string(APPEND _summary "${_bar}\n")
# Set the width for variable names
if (${ARGC} GREATER 2)
set(_width "${ARGV2}")
else()
set(_width 48) #default length if none provided
endif()
endmacro()

# Start a block within the configuration summary
# -- Arguments:
# 0) The title of the block
macro(config_summary_block title)
string(APPEND _summary
"${color_boldcyan}"
"${title}"
"${color_reset}"
"\n"
)
endmacro()

# Print out a key-value pair for information
# -- Arguments:
# 0) the key of the key-value pair
# 1) the value of the key-value pair
macro(config_summary_keyval key value)
config_summary_kvc("${key}" "${value}" "${color_yellow}")
endmacro()

# Shorthand to print out the name and value of an internal variable
# -- Arguments:
# 0) The name of the variable
macro(config_summary_variable varname)
config_summary_keyval("${varname}" "${${varname}}")
endmacro()

# Print out a dependency: not found or version
# -- Arguments:
# 0) The display name of the dependency (for printing)
# 1) The CMake name of the dependency (for finding variables)
# 2) optional: condition for whether or not to print this dependency (e.g., if a dependency is
# only conditionally included, you may only want to conditionally print out whether or not
# the dependency was found)
macro(config_summary_dependency display_name cmake_name)
if (${ARGC} GREATER 2)
set(_condition "${ARGV2}")
else()
set(_condition ON) # always print if no condition provided
endif()
if (${_condition})
if (NOT DEFINED ${cmake_name}_VERSION)
set(_color "${color_boldred}")
set(_version "not found")
else()
set(_color "${color_boldgreen}")
set(_version "${${cmake_name}_VERSION}")
endif()
config_summary_kvc("${display_name}" "${_version}" "${_color}")
endif()
endmacro()

# Print out the setting used for a user-settable variable. This differs from
# config_summary_variable mostly in how the output is colored in order to highlight what the user
# turned on or off at a quick glance.
# -- Arguments:
# 0) The name of the variable
macro(config_summary_option varname)
set(value "${${varname}}")
if (${value})
set(_color "${color_boldgreen}")
else()
set(_color "${color_boldgrey}")
endif()
config_summary_kvc("${varname}" "${value}" "${_color}")
endmacro()

# Finalize the configuration summary and do the actual printing to the terminal
macro(config_summary_print)
# pretty-print a footer bar to match the header
string(APPEND _summary "${_bar}")
# actually print the summary, along with the footer bar
message(NOTICE
"${_summary}"
"${_footerbar}"
)
endmacro()
12 changes: 12 additions & 0 deletions doc/sphinx/src/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ not yet ``constexpr``, so even with the "relaxed ``constexpr``" compilation mode
not feature-complete on GPUs. This will change when those member functions become ``constexpr`` in
C++20.


span.hpp


Expand All @@ -251,3 +252,14 @@ more information, see `C++ reference page <https://en.cppreference.com/w/cpp/con



static_vector.hpp
^^^^^^^^^^^^^^^^^

``PortsOfCall::static_vector`` is a GPU-compatible data structure that provides a
``std::vector``-like interface, but uses ``std::array``-like backing storage. That means that the
size is variable, but the capacity is fixed at runtime. This allows the creation of a data
structure of non-default-constructible objects like with a ``std::vector``. This also allows the
type to be self-contained: no pointers, so a ``PortsOfCall::static_vector`` can be memcopied
between CPU and GPU. It is related to a `proposed data structure
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p0843r8.html`_ that may be included in a
future C++ standard.
Loading

0 comments on commit e37efd7

Please sign in to comment.