Skip to content
Open
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
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ openpmd_option(MPI "Parallel, Multi-Node I/O for clusters" AUTO)
openpmd_option(HDF5 "HDF5 backend (.h5 files)" AUTO)
openpmd_option(ADIOS2 "ADIOS2 backend (.bp files)" AUTO)
openpmd_option(PYTHON "Enable Python bindings" AUTO)
openpmd_option(SYMBOLHIDING "Enable symbol hiding in libraries" AUTO)

option(openPMD_INSTALL "Add installation targets" ON)
option(openPMD_INSTALL_RPATH "Add RPATHs to installed binaries" ON)
Expand Down Expand Up @@ -219,6 +220,34 @@ function(openpmd_cuda_required target)
endfunction()


# Compiler Features ###########################################################
#
include(CheckCXXSourceCompiles)

check_cxx_source_compiles(
"
#include <cstdlib>
__attribute__((visibility(\"default\"))) static void f(void);
int main(void){ return 0; }
"
HAVE_ATTRIBUTE_VISIBILITY_DEFAULT
)
if(HAVE_ATTRIBUTE_VISIBILITY_DEFAULT OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if(openPMD_USE_SYMBOLHIDING STREQUAL "AUTO" OR
openPMD_USE_SYMBOLHIDING)
set(openPMD_HAVE_SYMBOLHIDING ON)
else()
set(openPMD_HAVE_SYMBOLHIDING OFF)
endif()
else()
set(openPMD_HAVE_SYMBOLHIDING OFF)
if(openPMD_USE_SYMBOLHIDING)
message(FATAL_ERROR "Compiler does not support symbol hiding.")
endif()
endif()


# Dependencies ################################################################
#
message(STATUS "openPMD-api superbuild: ${openPMD_SUPERBUILD}")
Expand Down Expand Up @@ -509,6 +538,18 @@ list(APPEND _msvc_options
)
target_compile_options(openPMD PUBLIC ${_msvc_options})

target_compile_definitions(openPMD PUBLIC
$<BUILD_INTERFACE:OPENPMD_BUILDPHASE=1>)

# symbol hiding
if(openPMD_HAVE_SYMBOLHIDING)
set_target_properties(openPMD PROPERTIES
Copy link
Member

@ax3l ax3l Oct 14, 2025

Choose a reason for hiding this comment

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

This will not work for C++ users, unless you explicitly export all our public C++ APIs.

Already, we should not be exporting C++ stdlib symbols, I think. I think that mixing different C++ stdlibs generally does not work in the same process, just how the dynamic loader works and populates symbols. But this is not needed in most cases, e.g., on HPC one does instead compile with a consistent set of compilers/modules.

CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
Comment on lines +546 to +549
Copy link
Member

Choose a reason for hiding this comment

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

We did this for the old ADIOS1 libraries if you like to take a look:
https://github.com/openPMD/openPMD-api/blob/0.14.5/CMakeLists.txt#L555-L571

target_compile_definitions(openPMD PUBLIC openPMD_HAVE_SYMBOLHIDING=1)
endif()

# own headers
target_include_directories(openPMD PUBLIC
$<BUILD_INTERFACE:${openPMD_SOURCE_DIR}/include>
Expand Down
43 changes: 23 additions & 20 deletions include/openPMD/ChunkInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/
#pragma once

#include "openPMD/auxiliary/Visibility.hpp"
#include "openPMD/backend/Attribute.hpp"
#include "openPMD/config.hpp"

#include "openPMD/Dataset.hpp" // Offset, Extent
Expand All @@ -41,7 +43,7 @@ namespace openPMD
*
* A chunk consists of its offset and its extent
*/
struct ChunkInfo
struct OPENPMD_PUBLIC ChunkInfo
{
Offset offset; //!< origin of the chunk
Extent extent; //!< size of the chunk
Expand All @@ -68,7 +70,7 @@ struct ChunkInfo
* This information will vary between different backends and should be used
* for optimization purposes only.
*/
struct WrittenChunkInfo : ChunkInfo
struct OPENPMD_PUBLIC WrittenChunkInfo : ChunkInfo
{
unsigned int sourceID = 0; //!< ID of the data source containing the chunk

Expand Down Expand Up @@ -113,7 +115,7 @@ namespace chunk_assignment
* @param chunks A list of chunks. Merging will occur in-place.
*/
template <typename Chunk_t>
void mergeChunks(std::vector<Chunk_t> &chunks);
OPENPMD_PUBLIC void mergeChunks(std::vector<Chunk_t> &chunks);

/**
* @brief Pairwise merge all chunks from the same source ID if they can be
Expand All @@ -122,7 +124,7 @@ namespace chunk_assignment
* @param chunks A list of chunks.
* @return Ordered by source ID, lists of merged chunks for each source ID.
*/
auto
OPENPMD_PUBLIC auto
mergeChunksFromSameSourceID(std::vector<WrittenChunkInfo> const &chunks)
-> std::map<unsigned int, std::vector<ChunkInfo>>;

Expand All @@ -133,7 +135,7 @@ namespace chunk_assignment
* chunks only within one compute node and will fail if there is no consumer
* in that same compute node.
*/
struct PartialAssignment
struct OPENPMD_PUBLIC PartialAssignment
{
ChunkTable notAssigned;
Assignment assigned;
Expand All @@ -151,7 +153,7 @@ namespace chunk_assignment
* ChunkTable that guides data sinks on how to load data into reading
* processes.
*/
struct Strategy
struct OPENPMD_PUBLIC Strategy
{
/**
* @brief Assign chunks to be loaded to reading processes.
Expand Down Expand Up @@ -235,7 +237,7 @@ namespace chunk_assignment
* chunks only within one compute node and will fail if there is no consumer
* in that same compute node.
*/
struct PartialStrategy
struct OPENPMD_PUBLIC PartialStrategy
{
/**
* @brief Assign chunks to be loaded to reading processes.
Expand Down Expand Up @@ -321,7 +323,7 @@ namespace chunk_assignment
* were not applicable e.g. due to a suboptimal setup.
*
*/
struct FromPartialStrategy : Strategy
struct OPENPMD_PUBLIC FromPartialStrategy : Strategy
{
FromPartialStrategy(
std::unique_ptr<PartialStrategy> firstPass,
Expand All @@ -346,7 +348,7 @@ namespace chunk_assignment
* in a round-Robin manner.
*
*/
struct RoundRobin : Strategy
struct OPENPMD_PUBLIC RoundRobin : Strategy
{
Assignment assign(
PartialAssignment,
Expand All @@ -364,7 +366,7 @@ namespace chunk_assignment
* Assign all chunks from the first source rank to the first reader rank,
* all from the second source rank to the second reader, and so on.
*/
struct RoundRobinOfSourceRanks : Strategy
struct OPENPMD_PUBLIC RoundRobinOfSourceRanks : Strategy
{
Assignment assign(
PartialAssignment,
Expand All @@ -386,7 +388,7 @@ namespace chunk_assignment
* The first three blocks go to the first process, the last three blocks to
* the second.
*/
struct Blocks : Strategy
struct OPENPMD_PUBLIC Blocks : Strategy
{
Assignment assign(
PartialAssignment,
Expand All @@ -404,7 +406,7 @@ namespace chunk_assignment
* Assign writer processes to reader processes, instead of assigning blocks
* to processes.
*/
struct BlocksOfSourceRanks : Strategy
struct OPENPMD_PUBLIC BlocksOfSourceRanks : Strategy
{
Assignment assign(
PartialAssignment,
Expand All @@ -424,7 +426,7 @@ namespace chunk_assignment
* chosen.
*
*/
struct ByHostname : PartialStrategy
struct OPENPMD_PUBLIC ByHostname : PartialStrategy
{
ByHostname(std::unique_ptr<Strategy> withinNode);

Expand All @@ -451,7 +453,7 @@ namespace chunk_assignment
* current parallel process in case this intersection is non-empty.
*
*/
struct ByCuboidSlice : Strategy
struct OPENPMD_PUBLIC ByCuboidSlice : Strategy
{
ByCuboidSlice(
std::unique_ptr<auxiliary::BlockSlicer> blockSlicer,
Expand Down Expand Up @@ -483,7 +485,7 @@ namespace chunk_assignment
* will be assigned at worst twice the ideal amount of data.
*
*/
struct BinPacking : Strategy
struct OPENPMD_PUBLIC BinPacking : Strategy
{
size_t splitAlongDimension = 0;

Expand Down Expand Up @@ -512,7 +514,7 @@ namespace chunk_assignment
* can be assigned within the same compute node.
*
*/
struct FailingStrategy : Strategy
struct OPENPMD_PUBLIC FailingStrategy : Strategy
{
explicit FailingStrategy();

Expand All @@ -535,7 +537,7 @@ namespace chunk_assignment
* the same node.
*
*/
struct DiscardingStrategy : Strategy
struct OPENPMD_PUBLIC DiscardingStrategy : Strategy
{
explicit DiscardingStrategy();

Expand Down Expand Up @@ -569,7 +571,7 @@ namespace host_info
* @return true If it is available.
* @return false Otherwise.
*/
bool methodAvailable(Method);
OPENPMD_PUBLIC bool methodAvailable(Method);

/**
* @brief Wrapper for the native hostname retrieval functions such as
Expand All @@ -578,7 +580,7 @@ namespace host_info
* @return std::string The hostname / processor name returned by the native
* function.
*/
std::string byMethod(Method);
OPENPMD_PUBLIC std::string byMethod(Method);

#if openPMD_HAVE_MPI
/**
Expand All @@ -591,7 +593,8 @@ namespace host_info
* for all MPI ranks known to the communicator.
* The result is returned on all ranks.
*/
chunk_assignment::RankMeta byMethodCollective(MPI_Comm, Method);
OPENPMD_PUBLIC chunk_assignment::RankMeta
byMethodCollective(MPI_Comm, Method);
#endif
} // namespace host_info
} // namespace openPMD
Expand Down
8 changes: 5 additions & 3 deletions include/openPMD/ChunkInfo_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "openPMD/ChunkInfo.hpp"
#include "openPMD/auxiliary/Visibility.hpp"
#include <string>

namespace openPMD::host_info
Expand All @@ -43,7 +44,8 @@ namespace openPMD::host_info
* via methodAvailable().
* @throws std::out_of_range If an unknown string identifier is passed.
*/
Method methodFromStringDescription(std::string const &descr, bool consider_mpi);
OPENPMD_PUBLIC Method
methodFromStringDescription(std::string const &descr, bool consider_mpi);

/*
* The following block contains one wrapper for each native hostname
Expand All @@ -58,10 +60,10 @@ Method methodFromStringDescription(std::string const &descr, bool consider_mpi);
#endif

#if openPMD_POSIX_AVAILABLE
std::string posix_hostname();
OPENPMD_PUBLIC std::string posix_hostname();
#endif

#if openPMD_HAVE_MPI
std::string mpi_processor_name();
OPENPMD_PUBLIC std::string mpi_processor_name();
#endif
} // namespace openPMD::host_info
3 changes: 2 additions & 1 deletion include/openPMD/Dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "openPMD/Datatype.hpp"
#include "openPMD/auxiliary/Visibility.hpp"

#include <limits>
#include <memory>
Expand All @@ -34,7 +35,7 @@ namespace openPMD
using Extent = std::vector<std::uint64_t>;
using Offset = std::vector<std::uint64_t>;

class Dataset
class OPENPMD_PUBLIC Dataset
{
friend class RecordComponent;

Expand Down
19 changes: 11 additions & 8 deletions include/openPMD/Datatype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// comment to prevent clang-format from moving this #include up
// datatype macros may be included and un-included in other headers
#include "openPMD/DatatypeMacros.hpp"
#include "openPMD/auxiliary/Visibility.hpp"

#include <array>
#include <climits>
Expand All @@ -47,7 +48,7 @@ namespace openPMD

/** Concrete datatype of an object available at runtime.
*/
enum class Datatype : int
enum class OPENPMD_PUBLIC Datatype : int
{
CHAR,
UCHAR,
Expand Down Expand Up @@ -97,7 +98,7 @@ enum class Datatype : int
* listed in order in a vector.
*
*/
std::vector<Datatype> openPMD_Datatypes();
OPENPMD_PUBLIC std::vector<Datatype> openPMD_Datatypes();

/** @brief Fundamental equivalence check for two given types T and U.
*
Expand Down Expand Up @@ -738,17 +739,19 @@ inline bool isSame(openPMD::Datatype const d, openPMD::Datatype const e)
* @param dt The "full" Datatype.
* @return The "inner" Datatype.
*/
Datatype basicDatatype(Datatype dt);
OPENPMD_PUBLIC Datatype basicDatatype(Datatype dt);

Datatype toVectorType(Datatype dt);
OPENPMD_PUBLIC Datatype toVectorType(Datatype dt);

std::string datatypeToString(Datatype dt);
OPENPMD_PUBLIC std::string datatypeToString(Datatype dt);

Datatype stringToDatatype(const std::string &s);
OPENPMD_PUBLIC Datatype stringToDatatype(const std::string &s);

void warnWrongDtype(std::string const &key, Datatype store, Datatype request);
OPENPMD_PUBLIC void
warnWrongDtype(std::string const &key, Datatype store, Datatype request);

std::ostream &operator<<(std::ostream &, openPMD::Datatype const &);
OPENPMD_PUBLIC std::ostream &
operator<<(std::ostream &, openPMD::Datatype const &);

template <typename T>
constexpr auto datatypeIndex() -> size_t
Expand Down
Loading
Loading