From 2f7d008770e2bd05b0b0775c2a21b06e3807e59b Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Thu, 28 Nov 2024 11:16:20 +0100 Subject: [PATCH 1/9] Add deactivation header, to include to disable PDI effects --- pdi/CMakeLists.txt | 1 + pdi/docs/CMakeLists.txt | 1 + pdi/include/pdi_deactivation.h | 308 +++++++++++++++++++++++++++++++++ 3 files changed, 310 insertions(+) create mode 100644 pdi/include/pdi_deactivation.h diff --git a/pdi/CMakeLists.txt b/pdi/CMakeLists.txt index 17917f224..ea62ddde1 100644 --- a/pdi/CMakeLists.txt +++ b/pdi/CMakeLists.txt @@ -199,6 +199,7 @@ install(TARGETS PDI_C EXPORT PDI_C_EXPORT ) install(FILES "${PDI_SOURCE_DIR}/include/pdi.h" + "${PDI_SOURCE_DIR}/include/pdi_deactivation.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT Development ) diff --git a/pdi/docs/CMakeLists.txt b/pdi/docs/CMakeLists.txt index b1ea2da9d..57d8e762c 100644 --- a/pdi/docs/CMakeLists.txt +++ b/pdi/docs/CMakeLists.txt @@ -90,6 +90,7 @@ doxygen_add_docs(doxygen_doc "${PDI_BINARY_DIR}/pdi/version.h" "${PDI_BINARY_DIR}/fmoddir/pdif.h" "${PDI_SOURCE_DIR}/include/pdi.h" + "${PDI_SOURCE_DIR}/include/pdi_deactivation.h" "${PDI_SOURCE_DIR}/include/pdi/" "${PDI_SOURCE_DIR}/../example/README.md" "${PDI_SOURCE_DIR}/../tutorial/README.md" diff --git a/pdi/include/pdi_deactivation.h b/pdi/include/pdi_deactivation.h new file mode 100644 index 000000000..085b7e1c4 --- /dev/null +++ b/pdi/include/pdi_deactivation.h @@ -0,0 +1,308 @@ +/******************************************************************************* +* Copyright (C) 2015-2021 Commissariat a l'energie atomique et aux energies alternatives (CEA) +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of CEA nor the names of its contributors may be used to +* endorse or promote products derived from this software without specific +* prior written permission. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +******************************************************************************/ + +/** \file pdi_deactivation.h + * + * C user API + * + * The user facing API is the interface offered by PDI to C application + * developers. + * + * \defgroup init_final Initialization and finalization + * + * The initialization and finalization part of the API is used to setup PDI, + * release its resources and check version information. + * + * \defgroup annotation Code annotation + * + * The code annotation API is the main interface to use in the code. + * + * It offers functions that can be called from code with no side effect by + * default and that can therefore be considered as annotations. + * + * \defgroup error Error handling + * + * The error handling API supports checking the error status of PDI. + * + * By default, errors in PDI C API are signaled by a return code of type + * PDI_status_t and an error message can be retrieved with the PDI_errmsg + * function. This default behavior can be changed by replacing the error handler + * with the PDI_errhandler function. + * + */ + +#ifdef PDI_H_ +#define PDI_H_ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// /** \addtogroup error +// * \{ +// */ + +// /** Error codes of PDI +// */ +// typedef enum PDI_status_e { +// /// everything went well +// PDI_OK = 0, +// /// on an input call, no such data is available +// PDI_UNAVAILABLE, +// /// The configuration file is invalid +// PDI_ERR_CONFIG, +// /// A value expression is invalid +// PDI_ERR_VALUE, +// /// Tried to load a non-existing plugin +// PDI_ERR_PLUGIN, +// /// Implementation limitation (typically an unimplemented feature) +// PDI_ERR_IMPL, +// /// A system error occured (OS, etc.) +// PDI_ERR_SYSTEM, +// /** A call to a function has been made at a wrong time (e.g. closing an +// * unopened transaction) +// */ +// PDI_ERR_STATE, +// /// A conflict of onwership over a content has been raised +// PDI_ERR_RIGHT, +// /// Invalid type error +// PDI_ERR_TYPE + +// } PDI_status_t; + +// /** Type of a callback function used when an error occurs +// * \param status the error code +// * \param message the human-readable error message +// * \param context a user-provided context +// */ +// typedef void (*PDI_errfunc_f)(PDI_status_t status, const char* message, void* context); + +// /** Definition of an error handler +// */ +// typedef struct PDI_errhandler_s { +// /// The function to handle the error (none if NULL) +// PDI_errfunc_f func; + +// /// the context that will be provided to the function +// void* context; + +// } PDI_errhandler_t; + +// /** Prints the error message and aborts if the status is invalid +// */ +// extern const PDI_errhandler_t PDI_EXPORT PDI_ASSERT_HANDLER; + +// /** Prints the error message and continue if the status is invalid +// */ +// extern const PDI_errhandler_t PDI_EXPORT PDI_WARN_HANDLER; + +// /** Does nothing +// */ +// extern const PDI_errhandler_t PDI_EXPORT PDI_NULL_HANDLER; + + +/** Return a human-readabe message describing the last error that occured in PDI + */ +const char PDI_EXPORT * PDI_errmsg(void){}; + +/** Sets the error handler to use + * + * PDI_asserthandler is the default handler before this function is called + * + * \param handler the new handler to set + * \return the previous handler + */ +PDI_errhandler_t PDI_EXPORT PDI_errhandler(PDI_errhandler_t handler){}; + +/// \} + +/** \addtogroup init_final Initialization and finalization + * + * The initialization and finalization part of the API is used to setup PDI, + * release its resources and check version information. + * \{ + */ + +/** Initializes PDI + * \param[in] conf the configuration + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_init(PC_tree_t conf){}; + +/** Finalizes PDI + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_finalize(void){}; + +/** Checks PDI API version + * + * \param[out] provided version if non-null it is filled with the provided API version + * \param[in] expected if non-zero the expected API version + * \return an error status if the expected version is incompatible with the + * provided one + */ +PDI_status_t PDI_EXPORT PDI_version(unsigned long* provided, unsigned long expected){}; + +/// \} + +/** \addtogroup annotation + * \{ + */ + +/** + * Access directions + */ +// typedef enum PDI_inout_e { +// /// No data transfert +// PDI_NONE = 0, +// /// data tranfer from PDI to the main code +// PDI_IN = 1, +// /// data transfer from the main code to PDI +// PDI_OUT = 2, +// /// data transfer in both direction +// PDI_INOUT = 3 + +// } PDI_inout_t; + +/** Shares some data with PDI. The user code should not modify it before + * a call to either PDI_release or PDI_reclaim. + * \param[in] name the data name + * \param[in,out] data the accessed data + * \param[in] access whether the data can be accessed for read or write + * by PDI + * \return an error status + * \pre the user code owns the data buffer + * \post ownership of the data buffer is shared between PDI and the user code + * + * the access parameter is a binary OR of PDI_IN & PDI_OUT. + * * PDI_IN means PDI can set the buffer content + * * PDI_OUT means the buffer contains data that can be accessed by PDI + */ +PDI_status_t PDI_EXPORT PDI_share(const char* name, void* data, PDI_inout_t access){}; + +/** Requests for PDI to access a data buffer. + * \param[in] name the data name + * \param[in,out] buffer a pointer to the accessed data buffer + * \param[in] inout the access properties (PDI_IN, PDI_OUT, PDI_INOUT) + * \return an error status + * \pre PDI owns the data buffer + * \post ownership of the data buffer is shared between PDI and the user code + */ +PDI_status_t PDI_EXPORT PDI_access(const char* name, void** buffer, PDI_inout_t inout){}; + +/** Releases ownership of a data shared with PDI. PDI is then responsible to + * free the associated memory whenever necessary. + * \param[in] name name of the data to release + * \return an error status + * \pre ownership of the data buffer is shared between PDI and the user code + * \pre PDI owns the data buffer + */ +PDI_status_t PDI_EXPORT PDI_release(const char* name){}; + +/** Reclaims ownership of a data buffer shared with PDI. PDI does not manage + * the buffer memory anymore. + * \param[in] name name of the data to reclaim + * \return an error status + * \pre ownership of the data buffer is shared between PDI and the user code + * \post the user code owns the data buffer + */ +PDI_status_t PDI_EXPORT PDI_reclaim(const char* name){}; + +/** Triggers a PDI "event" + * \param[in] event the event name + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_event(const char* event){}; + +/** Shortly exposes some data to PDI. Equivalent to PDI_share + PDI_reclaim. + * \param[in] name the data name + * \param[in] data the exposed data + * \param[in] access whether the data can be accessed for read or write + * by PDI + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_expose(const char* name, void* data, PDI_inout_t access){}; + +/** Performs multiple exposes at once. All the data is shared in order they were specified + * and reclaimed in reversed order after an event is triggered. + * + * NULL argument indicates an end of the list. + * + * \param[in] event_name the name of the event that will be triggered when + * all data become available + * \param[in] name the data name + * \param[in] data the exposed data + * \param[in] access whether the data can be accessed for read or write by PDI + * \param[in] ... (additional arguments) additional list of data to expose, + * each should contain name, data and access, NULL argument + * inidactes an end of the list. + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_multi_expose(const char* event_name, const char* name, void* data, PDI_inout_t access, ...){}; + +#ifdef PDI_WITH_DEPRECATED + +/** Begin a transaction in which all PDI_expose calls are grouped. + * + * This requires a call to PDI_transaction_end to close the transaction. + * + * \deprecated the transaction part of the API is deprecated, the + * PDI_multi_expose function should be used instead. + * + * \see PDI_expose the function used to expose data inside the transaction + * \see PDI_transaction_end the function used to end the transaction + * + * \param[in] name the name of the transaction (an event thus named will be + * triggered when all data become available) + * \return an error status + */ +PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_begin(const char* name){}; + +/** Ends the previously opened transaction. + * + * \deprecated the transaction part of the API is deprecated, the + * PDI_multi_expose function should be used instead. + * + * \see PDI_transaction_begin the function used to start the transaction + * \see PDI_expose the function used to expose data inside the transaction + * + * \return an error status + */ +PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_end(void){}; + +#endif // PDI_WITH_DEPRECATED + +/// \} + +#ifdef __cplusplus +} // extern C +#endif + + +#endif // PDI_H_ From 1385e764b58102bfbf8b8c581a717801dfa0724c Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Thu, 28 Nov 2024 12:00:11 +0100 Subject: [PATCH 2/9] Refactor to remove redundancies between pdi.h and pdi_deactivation.h, and prepare for PR, Fix #438 --- AUTHORS | 3 ++ pdi/CHANGELOG.md | 1 + pdi/include/pdi_deactivation.h | 76 +--------------------------------- 3 files changed, 5 insertions(+), 75 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9af99cd4b..f145a44e3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,3 +36,6 @@ project co-financed by Polish Ministry of Science and Higher Education. Yushan Wang - CEA (yushan.wang@cea.fr) * Maintainer (Sept. 2023 - ...) + +Julian Auriac - CEA (julian.auriac@cea.fr) +* Maintainer (Nov. 2024 - ...) diff --git a/pdi/CHANGELOG.md b/pdi/CHANGELOG.md index 1596f5359..c4077f99d 100644 --- a/pdi/CHANGELOG.md +++ b/pdi/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to * Add the `Context::find()` method. [#445](https://gitlab.maisondelasimulation.fr/pdidev/pdi/-/issues/445) * Add the `pybind11::dtype to_python(const std::shared_ptr& scalar_type)` helper function. +* Add the header pdi_deactivation.h which allows to disable PDI effects while keeping code syntax unchanged. #### Changed * Update the version of dependencies according to our policy: oldest supported diff --git a/pdi/include/pdi_deactivation.h b/pdi/include/pdi_deactivation.h index 085b7e1c4..a4b92f30e 100644 --- a/pdi/include/pdi_deactivation.h +++ b/pdi/include/pdi_deactivation.h @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (C) 2015-2021 Commissariat a l'energie atomique et aux energies alternatives (CEA) +* Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,65 +68,6 @@ extern "C" { // * \{ // */ -// /** Error codes of PDI -// */ -// typedef enum PDI_status_e { -// /// everything went well -// PDI_OK = 0, -// /// on an input call, no such data is available -// PDI_UNAVAILABLE, -// /// The configuration file is invalid -// PDI_ERR_CONFIG, -// /// A value expression is invalid -// PDI_ERR_VALUE, -// /// Tried to load a non-existing plugin -// PDI_ERR_PLUGIN, -// /// Implementation limitation (typically an unimplemented feature) -// PDI_ERR_IMPL, -// /// A system error occured (OS, etc.) -// PDI_ERR_SYSTEM, -// /** A call to a function has been made at a wrong time (e.g. closing an -// * unopened transaction) -// */ -// PDI_ERR_STATE, -// /// A conflict of onwership over a content has been raised -// PDI_ERR_RIGHT, -// /// Invalid type error -// PDI_ERR_TYPE - -// } PDI_status_t; - -// /** Type of a callback function used when an error occurs -// * \param status the error code -// * \param message the human-readable error message -// * \param context a user-provided context -// */ -// typedef void (*PDI_errfunc_f)(PDI_status_t status, const char* message, void* context); - -// /** Definition of an error handler -// */ -// typedef struct PDI_errhandler_s { -// /// The function to handle the error (none if NULL) -// PDI_errfunc_f func; - -// /// the context that will be provided to the function -// void* context; - -// } PDI_errhandler_t; - -// /** Prints the error message and aborts if the status is invalid -// */ -// extern const PDI_errhandler_t PDI_EXPORT PDI_ASSERT_HANDLER; - -// /** Prints the error message and continue if the status is invalid -// */ -// extern const PDI_errhandler_t PDI_EXPORT PDI_WARN_HANDLER; - -// /** Does nothing -// */ -// extern const PDI_errhandler_t PDI_EXPORT PDI_NULL_HANDLER; - - /** Return a human-readabe message describing the last error that occured in PDI */ const char PDI_EXPORT * PDI_errmsg(void){}; @@ -175,21 +116,6 @@ PDI_status_t PDI_EXPORT PDI_version(unsigned long* provided, unsigned long expec * \{ */ -/** - * Access directions - */ -// typedef enum PDI_inout_e { -// /// No data transfert -// PDI_NONE = 0, -// /// data tranfer from PDI to the main code -// PDI_IN = 1, -// /// data transfer from the main code to PDI -// PDI_OUT = 2, -// /// data transfer in both direction -// PDI_INOUT = 3 - -// } PDI_inout_t; - /** Shares some data with PDI. The user code should not modify it before * a call to either PDI_release or PDI_reclaim. * \param[in] name the data name From 4e7c3b71d1057a6f0e1e88ba1df879d5080e80c6 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 2 Dec 2024 15:29:10 +0100 Subject: [PATCH 3/9] Ready for PR, Fix #438, include unit test for PDI C deactivation, to do : Fortran equivalent --- AUTHORS | 5 +- pdi/docs/Using_PDI.md | 3 +- pdi/include/pdi_deactivation.h | 84 +++++++++++++++++++++++++++++++--- tests/AUTHORS | 4 +- tests/CMakeLists.txt | 4 ++ tests/test_06.c | 52 +++++++++++++++++++++ tests/test_06.yml | 6 +++ 7 files changed, 146 insertions(+), 12 deletions(-) create mode 100644 tests/test_06.c create mode 100644 tests/test_06.yml diff --git a/AUTHORS b/AUTHORS index f145a44e3..a597553dd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,6 +6,8 @@ Please note this is the list for the distribution mechanism of PDI. The list for each sub-project (including PDI itself) is located in the dedicated sub-project AUTHORS file. +Julian Auriac - CEA (julian.auriac@cea.fr) +* Maintainer (Nov. 2024 - ...) Julien Bigot - CEA (julien.bigot@cea.fr) * Maintainer (Dec. 2014 - ...) @@ -36,6 +38,3 @@ project co-financed by Polish Ministry of Science and Higher Education. Yushan Wang - CEA (yushan.wang@cea.fr) * Maintainer (Sept. 2023 - ...) - -Julian Auriac - CEA (julian.auriac@cea.fr) -* Maintainer (Nov. 2024 - ...) diff --git a/pdi/docs/Using_PDI.md b/pdi/docs/Using_PDI.md index 000fc3865..f3124eb5d 100644 --- a/pdi/docs/Using_PDI.md +++ b/pdi/docs/Using_PDI.md @@ -36,6 +36,7 @@ variables set up. If source files (of application that uses %PDI) and specification tree file are ready, the compilation step can be made. For C make sure that source files that use %PDI API are including `pdi.h` header file. +%PDI can be disabled by using `pdi_deactivation.h` instead of `pdi.h`, and re-enabled by doing the opposite. For Fortran make sure that source files that use %PDI API are using `%PDI` module file (`USE %PDI`). ### Compiling by hand {#compiling_by_hand} @@ -92,4 +93,4 @@ plugins in 4 steps (it will use the first plugin found): 1. `PDI_PLUGIN_PATH` environment variable that is colon separated list with paths, 2. `plugin_path` subtree in specification tree: \ref plugin_path_map_node, 3. Relative path of used %PDI shared object `libpdi.so`, -4. `LD_LIBRARY_PATH` environment variable that is colon separated list. +4. `LD_LIBRARY_PATH` environment variable that is colon separated list. \ No newline at end of file diff --git a/pdi/include/pdi_deactivation.h b/pdi/include/pdi_deactivation.h index a4b92f30e..2378614ea 100644 --- a/pdi/include/pdi_deactivation.h +++ b/pdi/include/pdi_deactivation.h @@ -52,7 +52,6 @@ * */ -#ifdef PDI_H_ #define PDI_H_ #include @@ -64,9 +63,68 @@ extern "C" { #endif -// /** \addtogroup error -// * \{ -// */ +/** \addtogroup error + * \{ + */ + +/** Error codes of PDI + */ +typedef enum PDI_status_e { + /// everything went well + PDI_OK = 0, + /// on an input call, no such data is available + PDI_UNAVAILABLE, + /// The configuration file is invalid + PDI_ERR_CONFIG, + /// A value expression is invalid + PDI_ERR_VALUE, + /// Tried to load a non-existing plugin + PDI_ERR_PLUGIN, + /// Implementation limitation (typically an unimplemented feature) + PDI_ERR_IMPL, + /// A system error occured (OS, etc.) + PDI_ERR_SYSTEM, + /** A call to a function has been made at a wrong time (e.g. closing an + * unopened transaction) + */ + PDI_ERR_STATE, + /// A conflict of onwership over a content has been raised + PDI_ERR_RIGHT, + /// Invalid type error + PDI_ERR_TYPE + +} PDI_status_t; + +/** Type of a callback function used when an error occurs + * \param status the error code + * \param message the human-readable error message + * \param context a user-provided context + */ +typedef void (*PDI_errfunc_f)(PDI_status_t status, const char* message, void* context); + +/** Definition of an error handler + */ +typedef struct PDI_errhandler_s { + /// The function to handle the error (none if NULL) + PDI_errfunc_f func; + + /// the context that will be provided to the function + void* context; + +} PDI_errhandler_t; + +/** Prints the error message and aborts if the status is invalid + */ +extern const PDI_errhandler_t PDI_EXPORT PDI_ASSERT_HANDLER; + +/** Prints the error message and continue if the status is invalid + */ +extern const PDI_errhandler_t PDI_EXPORT PDI_WARN_HANDLER; + +/** Does nothing + */ +extern const PDI_errhandler_t PDI_EXPORT PDI_NULL_HANDLER; + /** Return a human-readabe message describing the last error that occured in PDI */ @@ -116,6 +174,21 @@ PDI_status_t PDI_EXPORT PDI_version(unsigned long* provided, unsigned long expec * \{ */ +/** + * Access directions + */ +typedef enum PDI_inout_e { + /// No data transfert + PDI_NONE = 0, + /// data tranfer from PDI to the main code + PDI_IN = 1, + /// data transfer from the main code to PDI + PDI_OUT = 2, + /// data transfer in both direction + PDI_INOUT = 3 + +} PDI_inout_t; + /** Shares some data with PDI. The user code should not modify it before * a call to either PDI_release or PDI_reclaim. * \param[in] name the data name @@ -229,6 +302,3 @@ PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_end(void){}; #ifdef __cplusplus } // extern C #endif - - -#endif // PDI_H_ diff --git a/tests/AUTHORS b/tests/AUTHORS index 9c4b3f55a..ec69e7b21 100644 --- a/tests/AUTHORS +++ b/tests/AUTHORS @@ -2,6 +2,8 @@ Multiple people have contributed to the PDI tests. To show our appreciation for their public spirit, we list here in alphabetical order a condensed list of their contributions. +Julian Auriac - CEA (julian.auriac@cea.fr) +* Maintainer (Nov. 2024 - ...) Julien Bigot - CEA (julien.bigot@cea.fr) * Initial buildsystem @@ -15,4 +17,4 @@ project co-financed by Polish Ministry of Science and Higher Education. * Tests inspired by Parflow that combine Serialize & Decl'HDF5 Yushan Wang - CEA (yushan.wang@cea.fr) -* Maintainer (Sept. 2023 - ...) +* Maintainer (Sept. 2023 - ...) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1706d200b..8386477f4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -56,6 +56,10 @@ add_executable(test_04_C test_04.c) target_link_libraries(test_04_C PDI::PDI_C) add_test(NAME test_04_C COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/test_04.yml") +add_executable(test_06_C test_06.c) +target_link_libraries(test_06_C PDI::PDI_C) +add_test(NAME test_06_C COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/test_06.yml") + endif("${BUILD_DECL_HDF5_PLUGIN}" AND "${BUILD_SERIALIZE_PLUGIN}") if("${BUILD_DECL_NETCDF_PLUGIN}" AND "${BUILD_SERIALIZE_PLUGIN}") diff --git a/tests/test_06.c b/tests/test_06.c new file mode 100644 index 000000000..5d0ceb5fe --- /dev/null +++ b/tests/test_06.c @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (C) 2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of CEA nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include +// #include +#include +#include + + +int main(int argc, char* argv[]) +{ + PC_tree_t conf = PC_parse_path(argv[1]); + + PDI_init(PC_get(conf, ".pdi")); + printf("%s",argv[1]); + + long longval; + + int global_size[2]; + PC_int(PC_get(conf, ".global_size.height"), &longval); global_size[0] = longval; + PC_int(PC_get(conf, ".global_size.width"), &longval); global_size[1] = longval; + + // # As the value is shared with pdi.h, it can be reclaimed in a second time. + // # In the case of pdi_deactivation.h, the value is never shared, hence the reclaim operation fails. + // PDI_share("global_size", global_size, PDI_OUT) == NULL; + PDI_reclaim("global_size"); + + PDI_finalize(); + return 0; +} diff --git a/tests/test_06.yml b/tests/test_06.yml new file mode 100644 index 000000000..3003893fe --- /dev/null +++ b/tests/test_06.yml @@ -0,0 +1,6 @@ +global_size: { height: 60, width: 12 } + +pdi: + plugins: + trace: + logging: { pattern: '[PDI][%n-plugin] *** %l: %v' } \ No newline at end of file From cc1a02b7ffd3d5e40c11d7aa318b3e82544c4776 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 2 Dec 2024 15:41:35 +0100 Subject: [PATCH 4/9] Ready for PR, Fix #438, Fix indent issue on test file 06 --- tests/test_06.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_06.c b/tests/test_06.c index 5d0ceb5fe..6646d8cda 100644 --- a/tests/test_06.c +++ b/tests/test_06.c @@ -31,22 +31,22 @@ int main(int argc, char* argv[]) { - PC_tree_t conf = PC_parse_path(argv[1]); - - PDI_init(PC_get(conf, ".pdi")); - printf("%s",argv[1]); - - long longval; - - int global_size[2]; - PC_int(PC_get(conf, ".global_size.height"), &longval); global_size[0] = longval; - PC_int(PC_get(conf, ".global_size.width"), &longval); global_size[1] = longval; - - // # As the value is shared with pdi.h, it can be reclaimed in a second time. - // # In the case of pdi_deactivation.h, the value is never shared, hence the reclaim operation fails. + PC_tree_t conf = PC_parse_path(argv[1]); + + PDI_init(PC_get(conf, ".pdi")); + printf("%s",argv[1]); + + long longval; + + int global_size[2]; + PC_int(PC_get(conf, ".global_size.height"), &longval); global_size[0] = longval; + PC_int(PC_get(conf, ".global_size.width"), &longval); global_size[1] = longval; + + // # As the value is shared with pdi.h, it can be reclaimed in a second time. + // # In the case of pdi_deactivation.h, the value is never shared, hence the reclaim operation fails. // PDI_share("global_size", global_size, PDI_OUT) == NULL; PDI_reclaim("global_size"); - + PDI_finalize(); return 0; } From eec80b6942a6ee581bb9fe89b3850d91caa9e80d Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 2 Dec 2024 15:52:07 +0100 Subject: [PATCH 5/9] =?UTF-8?q?Ready=20for=20PR,=20Fix=20#438,=20Fix=20ind?= =?UTF-8?q?ent=20issue=20on=20test=20file=2006=20n=C2=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_06.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_06.c b/tests/test_06.c index 6646d8cda..d9790b6f9 100644 --- a/tests/test_06.c +++ b/tests/test_06.c @@ -28,19 +28,20 @@ #include #include - int main(int argc, char* argv[]) { PC_tree_t conf = PC_parse_path(argv[1]); PDI_init(PC_get(conf, ".pdi")); - printf("%s",argv[1]); + printf("%s", argv[1]); long longval; int global_size[2]; - PC_int(PC_get(conf, ".global_size.height"), &longval); global_size[0] = longval; - PC_int(PC_get(conf, ".global_size.width"), &longval); global_size[1] = longval; + PC_int(PC_get(conf, ".global_size.height"), &longval); + global_size[0] = longval; + PC_int(PC_get(conf, ".global_size.width"), &longval); + global_size[1] = longval; // # As the value is shared with pdi.h, it can be reclaimed in a second time. // # In the case of pdi_deactivation.h, the value is never shared, hence the reclaim operation fails. From 9c7ef92c51ce94ca55bf3c184c08b3ac35d08b58 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 2 Dec 2024 15:54:41 +0100 Subject: [PATCH 6/9] =?UTF-8?q?Ready=20for=20PR,=20Fix=20#438,=20Fix=20ind?= =?UTF-8?q?ent=20issue=20on=20test=20file=2006=20n=C2=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_06.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_06.c b/tests/test_06.c index d9790b6f9..b8e6d5667 100644 --- a/tests/test_06.c +++ b/tests/test_06.c @@ -31,23 +31,23 @@ int main(int argc, char* argv[]) { PC_tree_t conf = PC_parse_path(argv[1]); - + PDI_init(PC_get(conf, ".pdi")); printf("%s", argv[1]); - + long longval; - + int global_size[2]; PC_int(PC_get(conf, ".global_size.height"), &longval); - global_size[0] = longval; + global_size[0] = longval; PC_int(PC_get(conf, ".global_size.width"), &longval); - global_size[1] = longval; - + global_size[1] = longval; + // # As the value is shared with pdi.h, it can be reclaimed in a second time. // # In the case of pdi_deactivation.h, the value is never shared, hence the reclaim operation fails. // PDI_share("global_size", global_size, PDI_OUT) == NULL; PDI_reclaim("global_size"); - + PDI_finalize(); return 0; } From 6091396da058c9abd670101058b2b6dbece750a7 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 2 Dec 2024 16:13:51 +0100 Subject: [PATCH 7/9] =?UTF-8?q?Ready=20for=20PR,=20Fix=20#438,=20Fix=20ind?= =?UTF-8?q?ent=20issue=20on=20test=20file=2006=20n=C2=B04=20and=20add=20de?= =?UTF-8?q?activation=20mention=20to=20pull=5Frequest=5Ftemplate.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/pull_request_template.md | 3 ++- tests/test_06.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index eb10fa34d..2d3ed566e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,7 +6,8 @@ Before merging your code, please check the following: * [ ] you have added a line describing your changes to the Changelog; * [ ] you have added unit tests for any new or improved feature; -* [ ] In case you updated dependencies, you have checked pdi/docs/CheckList.md +* [ ] in case you updated dependencies, you have checked pdi/docs/CheckList.md; +* [ ] in case you added a new member to pdi.h, add the equivalent empty member to pdi_deactivation.h * you have checked your code format: - [ ] you have checked that you respect all conventions specified in CONTRIBUTING.md; - [ ] you have checked that the indentation and formatting conforms to the `.clang-format`; diff --git a/tests/test_06.c b/tests/test_06.c index b8e6d5667..f84359a67 100644 --- a/tests/test_06.c +++ b/tests/test_06.c @@ -38,9 +38,9 @@ int main(int argc, char* argv[]) long longval; int global_size[2]; - PC_int(PC_get(conf, ".global_size.height"), &longval); + PC_int(PC_get(conf, ".global_size.height"), &longval); global_size[0] = longval; - PC_int(PC_get(conf, ".global_size.width"), &longval); + PC_int(PC_get(conf, ".global_size.width"), &longval); global_size[1] = longval; // # As the value is shared with pdi.h, it can be reclaimed in a second time. From 2b8e521f70ff44d3e8b2f9eeea7fc7405f0b0064 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 20 Jan 2025 10:10:42 +0100 Subject: [PATCH 8/9] Add CMake option to disable PDI --- CMakeLists.txt | 433 +++++++++++++++++++++++++-------- pdi/include/pdi.h | 182 +++++++++++++- pdi/include/pdi_deactivation.h | 304 ----------------------- tests/CMakeLists.txt | 17 +- tests/test_06.c | 6 +- 5 files changed, 532 insertions(+), 410 deletions(-) delete mode 100644 pdi/include/pdi_deactivation.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cc48d5adb..582949415 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) +# Copyright (C) 2015-2023 Commissariat a l'energie atomique et aux energies alternatives (CEA) # # All rights reserved. # @@ -31,7 +31,7 @@ ### Project header -cmake_minimum_required(VERSION 3.16...3.29) +cmake_minimum_required(VERSION 3.10...3.25) project(PDI_DIST LANGUAGES C CXX) @@ -45,13 +45,17 @@ set_property(CACHE DIST_PROFILE PROPERTY STRINGS User Devel) if(User STREQUAL "${DIST_PROFILE}") option(BUILD_DOCUMENTATION "Build documentation" OFF) + option(BUILD_INDENT "Enable automatic code indentation" OFF) option(BUILD_TESTING "Build tests" OFF) option(BUILD_UNSTABLE "Build all features by default including those not stable yet" OFF) + option(DEACTIVATE_PDI "Disable PDI without deleting code, as a toggle" OFF) set(DEFAULT_BUILD_TYPE "Release") elseif(Devel STREQUAL "${DIST_PROFILE}") option(BUILD_DOCUMENTATION "Build documentation" ON) + option(BUILD_INDENT "Enable automatic code indentation" ON) option(BUILD_TESTING "Build tests" ON) option(BUILD_UNSTABLE "Build all features by default including those not stable yet" ON) + option(DEACTIVATE_PDI "Disable PDI without deleting code, as a toggle" OFF) set(DEFAULT_BUILD_TYPE "Debug") else() message(FATAL_ERROR "DIST_PROFILE should be set to one of: User, Devel") @@ -64,9 +68,13 @@ set(USE_DEFAULT AUTO CACHE STRING "Default version of libraries to use; this can # Modules to build option(BUILD_BENCHMARKING "Build PDI benchmarks" ON) +option(BUILD_CFG_VALIDATOR "Build config validation script" "${BUILD_UNSTABLE}") option(BUILD_DECL_HDF5_PLUGIN "Build Decl'HDF5 plug-in" ON) -option(BUILD_DECL_NETCDF_PLUGIN "Build Decl'NetCDF plug-in" ON) +option(BUILD_DECL_NETCDF_PLUGIN "Build Decl'NetCDF plug-in" "${BUILD_UNSTABLE}") +option(BUILD_DECL_SION_PLUGIN "Build Decl'SION plug-in" "${BUILD_UNSTABLE}") +option(BUILD_FLOWVR_PLUGIN "Build FlowVR plug-in" "${BUILD_UNSTABLE}") option(BUILD_FORTRAN "Build with Fortran support" ON) +option(BUILD_FTI_PLUGIN "Build FTI plug-in." "${BUILD_UNSTABLE}") option(BUILD_HDF5_PARALLEL "Build Decl'HDF5 in parallel mode" ON) option(BUILD_MPI_PLUGIN "Build MPI plug-in" ON) option(BUILD_NETCDF_PARALLEL "Build Decl'NetCDF in parallel mode" ON) @@ -75,14 +83,13 @@ option(BUILD_PYTHON "Build with Python support" "${BUILD_UNSTABLE}") option(BUILD_SET_VALUE_PLUGIN "Build Set_value plug-in" ON) option(BUILD_SERIALIZE_PLUGIN "Build Serialize plug-in" ON) option(BUILD_SHARED_LIBS "Build shared libraries rather than static ones" ON) +option(BUILD_TEST_PLUGIN "Build Test plugin" "${BUILD_UNSTABLE}") option(BUILD_TRACE_PLUGIN "Build Trace plugin" ON) option(BUILD_USER_CODE_PLUGIN "Build User-code plugin" ON) -option(BUILD_JSON_PLUGIN "Build JSON plugin" OFF) option(BUILD_DEISA_PLUGIN "Build Deisa plug-in" OFF) - ### Default build type if(NOT "${CMAKE_BUILD_TYPE}") @@ -93,14 +100,16 @@ message(STATUS " **Profile**: Build type is: `${CMAKE_BUILD_TYPE}' (-DCMAKE_BUIL message(STATUS " **Profile**: Prefix path is: `${CMAKE_PREFIX_PATH}' (-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})") message(STATUS " **Profile**: Default use is: `${USE_DEFAULT}' (-DUSE_DEFAULT=${USE_DEFAULT})") message(STATUS " **Profile**: Unstable activation is: `${BUILD_UNSTABLE}' (-DBUILD_UNSTABLE=${BUILD_UNSTABLE})") -foreach(FEATURE FORTRAN HDF5_PARALLEL PYTHON TESTING) +foreach(FEATURE FORTRAN HDF5_PARALLEL INDENT PYTHON TESTING) set(FEATURE_ENABLED "DISABLED") if(${BUILD_${FEATURE}}) set(FEATURE_ENABLED "ENABLED ") endif() message(STATUS " **Feature**: ${FEATURE_ENABLED} ${FEATURE} (-DBUILD_${FEATURE}=${BUILD_${FEATURE}})") endforeach() - +if (DEACTIVATE_PDI) + add_definitions(-DDEACTIVATE_PDI) +endif() ### Include sub-projects find modules @@ -108,16 +117,26 @@ endforeach() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/pdi/cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/plugins/test/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/plugins/trace/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/plugins/user_code/cmake") +if("${BUILD_CFG_VALIDATOR}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/pdicfg_validator/cmake") +endif() if("${BUILD_DECL_HDF5_PLUGIN}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/decl_hdf5/cmake") endif() if("${BUILD_DECL_NETCDF_PLUGIN}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/decl_netcdf/cmake") endif() -if("${BUILD_DEISA_PLUGIN}") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/deisa/cmake") +if("${BUILD_DECL_SION_PLUGIN}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/decl_sion/cmake") +endif() +if("${BUILD_FLOWVR_PLUGIN}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/flowvr/cmake") +endif() +if("${BUILD_FTI_PLUGIN}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/fti/cmake") endif() if("${BUILD_MPI_PLUGIN}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/mpi/cmake") @@ -125,8 +144,8 @@ endif() if("${BUILD_PYCALL_PLUGIN}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/pycall/cmake") endif() -if ("${BUILD_JSON_PLUGIN}") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/json/cmake") +if("${BUILD_DEISA_PLUGIN}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/plugins/deisa/cmake") endif() if("${BUILD_TESTING}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/example/cmake") @@ -194,6 +213,14 @@ if("${BUILD_DEISA_PLUGIN}" AND NOT "${BUILD_PYTHON}") endif() +### Subtargets + +if("${BUILD_INDENT}") + add_custom_target(indent) +endif() + + + ### Dependencies include(GNUInstallDirs) @@ -214,9 +241,24 @@ endif() ## Python3 if("${BUILD_PYTHON}") - find_package(Python3Path 3.8.2 REQUIRED COMPONENTS Interpreter Development) -elseif("${BUILD_FORTRAN}") - find_package(Python3Path 3.8.2 REQUIRED COMPONENTS Interpreter) + find_package(Python3Path 3.6 REQUIRED COMPONENTS Interpreter Development) +elseif("${BUILD_CFG_VALIDATOR}" OR "${BUILD_FLOWVR_PLUGIN}" OR "${BUILD_FORTRAN}") + find_package(Python3Path 3.6 REQUIRED COMPONENTS Interpreter) +endif() + + +## Zpp + +if("${BUILD_FORTRAN}") + sbuild_add_dependency(Zpp EMBEDDED + BUILD_DEPENDENCY + EMBEDDED_PATH "vendor/zpp-1.0.15.tar" + VERSION 1.0.15 + BUILD_IN_SOURCE ON + CONFIGURE_COMMAND "${Python3_EXECUTABLE}" "-m" "venv" "/lib/zpp-venv" + BUILD_COMMAND "/lib/zpp-venv/bin/python" "/setup.py" build + INSTALL_COMMAND "/lib/zpp-venv/bin/python" "/setup.py" install "--install-data=" + ) endif() @@ -242,7 +284,7 @@ if( ("${BUILD_DECL_HDF5_PLUGIN}" AND "${BUILD_HDF5_PARALLEL}") OR ("${BUILD_DECL list(APPEND MPI_COMPONENTS Fortran) endif() endif() -if("${BUILD_MPI_PLUGIN}") +if("${BUILD_FTI_PLUGIN}" OR "${BUILD_MPI_PLUGIN}" OR "${BUILD_DECL_SION_PLUGIN}") list(APPEND MPI_COMPONENTS CXX) endif() if(NOT "x${MPI_COMPONENTS}x" STREQUAL xx) @@ -256,16 +298,16 @@ endif() ## Yaml -# if ( paraconf ) +# if ( paraconf or PyYAML ) sbuild_add_dependency(yaml "${USE_DEFAULT}" - EMBEDDED_PATH "vendor/libyaml-0.2.5" + EMBEDDED_PATH "vendor/libyaml-0.2.2.tar" CMAKE_CACHE_ARGS "-DBUILD_TESTING:BOOL=OFF" "-DINSTALL_LIB_DIR:STRING=${CMAKE_INSTALL_LIBDIR}" "-DINSTALL_BIN_DIR:STRING=${CMAKE_INSTALL_BINDIR}" "-DINSTALL_INCLUDE_DIR:STRING=${CMAKE_INSTALL_INCLUDEDIR}" "-DINSTALL_CMAKE_DIR:STRING=share/yaml/cmake" - VERSION 0.2.2 + VERSION 0.1.7 ) @@ -277,7 +319,7 @@ if("${BUILD_FORTRAN}") endif() # if ( PDI or ... ) sbuild_add_dependency(paraconf "${USE_DEFAULT}" - EMBEDDED_PATH "vendor/paraconf-1.0.0" + EMBEDDED_PATH "vendor/paraconf-1.0.0.tar" COMPONENTS ${PARACONF_COMPONENTS} SOURCE_SUBDIR "paraconf" CMAKE_CACHE_ARGS @@ -293,7 +335,7 @@ sbuild_add_dependency(paraconf "${USE_DEFAULT}" # if ( PDI or ... ) sbuild_add_dependency(spdlog "${USE_DEFAULT}" - EMBEDDED_PATH "vendor/spdlog-1.14.1" + EMBEDDED_PATH "vendor/spdlog-1.5.0.tar" CMAKE_CACHE_ARGS "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" "-DSPDLOG_BUILD_BENCH:BOOL=OFF" @@ -307,48 +349,148 @@ sbuild_add_dependency(spdlog "${USE_DEFAULT}" ## Doxygen if("${BUILD_DOCUMENTATION}") - find_package(Doxygen 1.8.17 REQUIRED OPTIONAL_COMPONENTS dot) + sbuild_add_dependency(Doxygen "${USE_DEFAULT}" + BUILD_DEPENDENCY + EMBEDDED_PATH "vendor/doxygen-1.8.15.src.tar" + VERSION 1.8.12 + OPTIONAL_COMPONENTS dot + ) +endif() + + +## Astyle + +if("${BUILD_INDENT}") + sbuild_add_dependency(Astyle "${USE_DEFAULT}" + BUILD_DEPENDENCY + EMBEDDED_PATH "vendor/astyle_3.1_linux.tar" + PATCH_COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/vendor/astyle/CMakeLists.txt" "/CMakeLists.txt" + CMAKE_CACHE_ARGS "-DBUILD_SHARED_LIBS:BOOL=OFF" + VERSION 3.1 + ) +endif() + + +## GTest + +if(${BUILD_TESTING}) + # find_package(GMock REQUIRED) + sbuild_add_dependency(GTest EMBEDDED + EMBEDDED_PATH "vendor/googletest-release-1.8.0.tar" + BUILD_DEPENDENCY + CMAKE_CACHE_ARGS + "-DBUILD_TESTING:BOOL=OFF" + # set BUILD_SHARED_LIBS=OFF to workaround https://github.com/google/googletest/issues/930 + "-DBUILD_SHARED_LIBS:BOOL=OFF" + VERSION 1.8.0 + ) +endif() + + +# Google benchmark +if(${BUILD_BENCHMARKING}) + sbuild_add_dependency(benchmark EMBEDDED + EMBEDDED_PATH "vendor/benchmark-1.5.5.tar" + BUILD_DEPENDENCY + CMAKE_CACHE_ARGS + "-DCMAKE_BUILD_TYPE:STRING=Release" + "-DBENCHMARK_BUILD_32_BITS:BOOL=OFF" + "-DBENCHMARK_ENABLE_EXCEPTIONS:BOOL=ON" + "-DBENCHMARK_ENABLE_INSTALL:BOOL=ON" + "-DBENCHMARK_ENABLE_LIBPFM:BOOL=OFF" + "-DBENCHMARK_ENABLE_LTO:BOOL=OFF" + "-DBENCHMARK_ENABLE_TESTING:BOOL=OFF" + "-DBENCHMARK_USE_LIBCXX:BOOL=OFF" + VERSION 1.5.0 + ) + set(BENCHMARKING_DEPENDENCY benchmark) +endif() + + +## OpenGL + +if("${BUILD_FLOWVR_PLUGIN}" AND "${BUILD_TESTING}") + set(OpenGL_GL_PREFERENCE LEGACY) + sbuild_add_dependency(OpenGL SYSTEM) + sbuild_add_dependency(GLUT SYSTEM) +endif() + + +## FTI + +if("${BUILD_FTI_PLUGIN}") + sbuild_add_dependency(FTI "${USE_DEFAULT}" + EMBEDDED_PATH "vendor/fti-1.6.tar" + CMAKE_CACHE_ARGS + "-DENABLE_FORTRAN:BOOL=OFF" + "-DENABLE_EXAMPLES:BOOL=OFF" + "-DENABLE_TESTS:BOOL=OFF" + "-DENABLE_DOCU:BOOL=OFF" + VERSION 1.6 + ) +endif() + + +## FlowVR + +if("${BUILD_FLOWVR_PLUGIN}") + sbuild_add_dependency(FlowVR "${USE_DEFAULT}" + EMBEDDED_PATH "vendor/flowvr-ex-v2.3.2.tar" + CMAKE_CACHE_ARGS + "-DENABLE_EXAMPLES:BOOL=OFF" + "-DENABLE_TESTS:BOOL=OFF" + "-DENABLE_DOCU:BOOL=OFF" + "-DOpenGL_GL_PREFERENCE:STRING=LEGACY" + # VERSION 2.3.2 Finding FlowVR version doesn't work with 2.3 + ) endif() ## HDF5 if("${BUILD_DECL_HDF5_PLUGIN}" OR "${BUILD_DECL_NETCDF_PLUGIN}") - - set(HDF5_CMAKE_CACHE_ARGS) - + set(HDF5_CONFIGURE_OPTS) + set(HDF5_BUILD_ENV) + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + list(APPEND HDF5_CONFIGURE_OPTS "--enable-build-mode=debug") + else() + list(APPEND HDF5_CONFIGURE_OPTS "--enable-build-mode=production") + endif() if("${BUILD_HDF5_PARALLEL}") - set(HDF5_PREFER_PARALLEL ON) - list(APPEND HDF5_CMAKE_CACHE_ARGS "-DHDF5_ENABLE_PARALLEL:BOOL=ON") + set(HDF5_PREFER_PARALLEL "ON") + list(APPEND HDF5_CONFIGURE_OPTS "--enable-parallel") + set(HDF5_BUILD_ENV "env" "CC=${MPI_C_COMPILER}") else() - set(HDF5_PREFER_PARALLEL OFF) - list(APPEND HDF5_CMAKE_CACHE_ARGS "-DHDF5_ENABLE_PARALLEL:BOOL=OFF") + set(HDF5_PREFER_PARALLEL "OFF") + list(APPEND HDF5_CONFIGURE_OPTS "--disable-parallel") endif() - if("${BUILD_DECL_NETCDF_PLUGIN}") set(HDF5_COMPONENTS C HL) - list(APPEND HDF5_CMAKE_CACHE_ARGS "-DHDF5_BUILD_HL_LIB:BOOL=ON") + list(APPEND HDF5_CONFIGURE_OPTS "--enable-hl") else() set(HDF5_COMPONENTS C) - list(APPEND HDF5_CMAKE_CACHE_ARGS "-DHDF5_BUILD_HL_LIB:BOOL=OFF") + list(APPEND HDF5_CONFIGURE_OPTS "--disable-hl") endif() - find_package(ZLIB) - sbuild_add_dependency(HDF5 "${USE_DEFAULT}" - EMBEDDED_PATH "vendor/hdf5-1.12.3" + EMBEDDED_PATH "vendor/hdf5-1.12.0.tar" COMPONENTS ${HDF5_COMPONENTS} MODULE_VARS HDF5_IS_PARALLEL HDF5_C_INCLUDE_DIRS HDF5_C_LIBRARIES HDF5_VERSION - CMAKE_CACHE_ARGS - -DBUILD_TESTING:BOOL=OFF - -DHDF5_BUILD_EXAMPLES:BOOL=OFF - -DHDF5_BUILD_TOOLS:BOOL=ON - -DHDF5_BUILD_UTILS:BOOL=OFF - ${HDF5_CMAKE_CACHE_ARGS} + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ${HDF5_BUILD_ENV} + "/configure" + #TODO: prefix should point to the final install dir, we should use a staging mechanism + "--prefix=" + "--libdir=/${CMAKE_INSTALL_LIBDIR}" + "--disable-tests" + "--disable-static" + "--disable-tools" + "--disable-sharedlib-rpath" + ${HDF5_CONFIGURE_OPTS} ) if("${HDF5_FOUND}") - if(1.10.4 VERSION_GREATER "${HDF5_VERSION}") - message(FATAL_ERROR "HDF5 version ${HDF5_VERSION} found less than required 1.10.4") + if(1.10 VERSION_GREATER "${HDF5_VERSION}") + message(FATAL_ERROR "HDF5 version ${HDF5_VERSION} found less than required 1.10.0") endif() if("${BUILD_HDF5_PARALLEL}" AND NOT "${HDF5_IS_PARALLEL}") message(FATAL_ERROR @@ -366,55 +508,40 @@ endif() ## NetCDF if("${BUILD_DECL_NETCDF_PLUGIN}") - if("${BUILD_HDF5_PARALLEL}") set(NETCDF_CC "${MPI_C_COMPILER}") else() set(NETCDF_CC "${CMAKE_C_COMPILER}") endif() - - set(NETCDF_CMAKE_CACHE_ARGS) if("${BUILD_NETCDF_PARALLEL}") - list(APPEND NETCDF_CMAKE_CACHE_ARGS "-DENABLE_PARALLEL4:BOOL=ON") + set(NETCDF_MIN_VERSION "4.6.2") else() - list(APPEND NETCDF_CMAKE_CACHE_ARGS "-DENABLE_PARALLEL4:BOOL=OFF") + set(NETCDF_MIN_VERSION "4.6.0") endif() - set(NETCDF_CPATH "${SBUILD_CPATH}") set(NETCDF_LIBRARY_PATH "${SBUILD_LIBRARY_PATH}") - - # Workaround NetCDF borken LibXML2 include path detection - find_package(LibXml2) - if("${LIBXML2_FOUND}") - foreach(INCLUDE_DIR IN LISTS LIBXML2_INCLUDE_DIRS) - set(NETCDF_CPATH "${NETCDF_CPATH}:${INCLUDE_DIR}") - get_filename_component(INCLUDE_DIR "${INCLUDE_DIR}" DIRECTORY) - set(NETCDF_CPATH "${NETCDF_CPATH}:${INCLUDE_DIR}") - endforeach() - foreach(LIB IN LISTS LIBXML2_LIBRARIES) + if("${HDF5_FOUND}") + string(REPLACE ";" ":" NETCDF_CPATH "${SBUILD_CPATH}:${HDF5_C_INCLUDE_DIRS}") + foreach(LIB IN LISTS HDF5_C_LIBRARIES) get_filename_component(LIB_DIR "${LIB}" DIRECTORY) set(NETCDF_LIBRARY_PATH "${NETCDF_LIBRARY_PATH}:${LIB_DIR}") endforeach() endif() sbuild_add_dependency(NetCDF "${USE_DEFAULT}" - EMBEDDED_PATH "vendor/netcdf-c-4.9.2" + EMBEDDED_PATH "vendor/netcdf-c-4.8.1.tar" DEPENDS HDF5 - MODULE_VARS NetCDF_FEATURES - ENV "CPATH=${NETCDF_CPATH}" "LIBRARY_PATH=${NETCDF_LIBRARY_PATH}" - CMAKE_CACHE_ARGS - "-DCMAKE_C_COMPILER:STRING=${NETCDF_CC}" - -DBUILD_TESTING:BOOL=OFF - -DBUILD_TESTSETS:BOOL=OFF - -DBUILD_UTILITIES:BOOL=OFF - -DENABLE_BASH_SCRIPT_TESTING:BOOL=OFF - -DENABLE_BYTERANGE:BOOL=OFF - -DENABLE_DAP:BOOL=OFF - -DENABLE_DAP4:BOOL=OFF - -DENABLE_EXAMPLES:BOOL=OFF - -DENABLE_FILTER_TESTING:BOOL=OFF - -DENABLE_TESTS:BOOL=OFF - VERSION 4.7.3 + BUILD_IN_SOURCE 1 + ENV "CC=${NETCDF_CC}" "CPATH=${NETCDF_CPATH}" "LIBRARY_PATH=${NETCDF_LIBRARY_PATH}" + CONFIGURE_COMMAND "/configure" + #TODO: prefix should point to the final install dir, we should use a staging mechanism + --prefix= + --disable-static + --enable-netcdf-4 + --disable-dap + --disable-utilities + --disable-testsets + VERSION "${NETCDF_MIN_VERSION}" ) if("${NETCDF_FOUND}") if("${BUILD_NETCDF_PARALLEL}" AND NOT "PARALLEL4" IN_LIST NetCDF_FEATURES) @@ -433,59 +560,152 @@ endif() ## PyBind11 if("${BUILD_PYTHON}") + # Workaround pybind11 incompatibility with cmake<3.12 if Python3_FOUND is set + set(_PDI_DIST_Python3_FOUND "${Python3_FOUND}") + unset(Python3_FOUND) set(Python_ADDITIONAL_VERSIONS "${Python3_VERSION}" CACHE STRING "Python version found by FindPython3 for coherency" FORCE) set(PYBIND11_PYTHON_VERSION "${Python3_VERSION}" CACHE STRING "Python version to use for compiling modules" FORCE) sbuild_add_dependency(pybind11 "${USE_DEFAULT}" - EMBEDDED_PATH "vendor/pybind11-2.13.1" + EMBEDDED_PATH "vendor/pybind11-2.11.1.tar" CMAKE_CACHE_ARGS "-DBUILD_TESTING:BOOL=OFF" "-DPYBIND11_TEST:BOOL=OFF" "-DPYBIND11_PYTHON_VERSION:STRING=${Python3_VERSION}" - VERSION 2.4.3 + VERSION 2.11.1 + ) + set(Python3_FOUND "${_PDI_DIST_Python3_FOUND}") +endif() + + +## PyYAML + +if("${BUILD_CFG_VALIDATOR}" OR "${BUILD_FLOWVR_PLUGIN}") + execute_process(COMMAND "${Python3_EXECUTABLE}" -m pip install --system + RESULT_VARIABLE PIP_INSTALL_ERROR + OUTPUT_QUIET + ERROR_QUIET) + if("${PIP_INSTALL_ERROR}" EQUAL 0) + set(PIP_SYSTEM "--system") + endif() + sbuild_get_env(CPATH CPATH) + sbuild_get_env(LIBRARY_PATH LIBRARY_PATH) + sbuild_add_dependency(PyYAML "${USE_DEFAULT}" + EMBEDDED_PATH "vendor/PyYAML-6.0.1.tar" + CONFIGURE_COMMAND "true" + BUILD_COMMAND "true" + INSTALL_COMMAND env + "CPATH=${CPATH}" + "LIBRARY_PATH=${LIBRARY_PATH}" + "LD_LIBRARY_PATH=${LIBRARY_PATH}" + "${Python3_EXECUTABLE}" -m pip install + ${PIP_SYSTEM} + --prefix "" + --no-cache-dir + --ignore-installed + install + "" + DEPENDS yaml ) endif() +## SIONlib + +if("${BUILD_DECL_SION_PLUGIN}") + sbuild_add_dependency(SIONlib "${USE_DEFAULT}" + EMBEDDED_PATH "vendor/sionlib-1.7.6.tar" + DEPENDS MPI + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND "/configure" + --prefix= + --disable-fortran + --disable-parutils + --disable-cxx + VERSION 1.7.6 + ) +endif() + + + ### Own modules -set(PDI_DEPENDS_LIST paraconf spdlog) +if("${BUILD_INDENT}") + set(ASTYLE_DEPENDENCY Astyle) +endif() + +set(PDI_DEPENDS_LIST paraconf spdlog "${ASTYLE_DEPENDENCY}" "${BENCHMARKING_DEPENDENCY}") +if("${BUILD_DOCUMENTATION}") + list(APPEND PDI_DEPENDS_LIST Doxygen) +endif() +if("${BUILD_TESTING}") + list(APPEND PDI_DEPENDS_LIST GTest) +endif() +if("${BUILD_FORTRAN}") + list(APPEND PDI_DEPENDS_LIST Zpp) +endif() if("${BUILD_PYTHON}") list(APPEND PDI_DEPENDS_LIST pybind11) endif() sbuild_add_module(PDI SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pdi" DEPENDS ${PDI_DEPENDS_LIST} + SUBSTEPS indent test +) + + +sbuild_add_module(PDICFG_VALIDATOR + ENABLE_BUILD_FLAG BUILD_CFG_VALIDATOR + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools/pdicfg_validator" + DEPENDS PyYAML SUBSTEPS test ) +if("${BUILD_CFG_VALIDATOR}") + set(PDICFG_DEPENDENCY PDICFG_VALIDATOR) +endif() sbuild_add_module(MPI_PLUGIN ENABLE_BUILD_FLAG BUILD_MPI_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/mpi" - DEPENDS PDI - SUBSTEPS test + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent test ) sbuild_add_module(DECL_HDF5_PLUGIN ENABLE_BUILD_FLAG BUILD_DECL_HDF5_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/decl_hdf5" - DEPENDS PDI HDF5 - SUBSTEPS test + DEPENDS PDI HDF5 ${ASTYLE_DEPENDENCY} ${PDICFG_DEPENDENCY} ${BENCHMARKING_DEPENDENCY} + SUBSTEPS indent test +) + + +sbuild_add_module(DECL_SION_PLUGIN + ENABLE_BUILD_FLAG BUILD_DECL_SION_PLUGIN + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/decl_sion" + DEPENDS PDI SIONlib ${ASTYLE_DEPENDENCY} ${PDICFG_DEPENDENCY} + SUBSTEPS indent test ) sbuild_add_module(DECL_NETCDF_PLUGIN ENABLE_BUILD_FLAG BUILD_DECL_NETCDF_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/decl_netcdf" - DEPENDS PDI NetCDF - SUBSTEPS test + DEPENDS PDI NetCDF ${ASTYLE_DEPENDENCY} ${PDICFG_DEPENDENCY} + SUBSTEPS indent test ) +sbuild_add_module(FTI_PLUGIN + ENABLE_BUILD_FLAG BUILD_FTI_PLUGIN + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/fti" + DEPENDS PDI FTI ${ASTYLE_DEPENDENCY} ${PDICFG_DEPENDENCY} + SUBSTEPS indent test +) -sbuild_add_module(JSON_PLUGIN - ENABLE_BUILD_FLAG BUILD_JSON_PLUGIN - SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/json" - DEPENDS PDI + +sbuild_add_module(FLOWVR_PLUGIN + ENABLE_BUILD_FLAG BUILD_FLOWVR_PLUGIN + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/flowvr" + DEPENDS PDI FlowVR PyYAML ${ASTYLE_DEPENDENCY} SUBSTEPS indent test ) @@ -493,49 +713,64 @@ sbuild_add_module(JSON_PLUGIN sbuild_add_module(PYCALL_PLUGIN ENABLE_BUILD_FLAG BUILD_PYCALL_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/pycall" - DEPENDS PDI - SUBSTEPS test + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent test ) sbuild_add_module(SET_VALUE_PLUGIN ENABLE_BUILD_FLAG BUILD_SET_VALUE_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/set_value" - DEPENDS PDI - SUBSTEPS test + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent test ) sbuild_add_module(SERIALIZE_PLUGIN ENABLE_BUILD_FLAG BUILD_SERIALIZE_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/serialize" - DEPENDS PDI - SUBSTEPS test + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent test +) + +sbuild_add_module(TEST_PLUGIN + ENABLE_BUILD_FLAG BUILD_TEST_PLUGIN + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/test" + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent ) sbuild_add_module(TRACE_PLUGIN ENABLE_BUILD_FLAG BUILD_TRACE_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/trace" - DEPENDS PDI + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent ) sbuild_add_module(USER_CODE_PLUGIN ENABLE_BUILD_FLAG BUILD_USER_CODE_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/user_code" - DEPENDS PDI - SUBSTEPS test + DEPENDS PDI ${ASTYLE_DEPENDENCY} + SUBSTEPS indent test ) + sbuild_add_module(DEISA_PLUGIN ENABLE_BUILD_FLAG BUILD_DEISA_PLUGIN SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugins/deisa" - DEPENDS PDI + DEPENDS PDI ${ASTYLE_DEPENDENCY} +# SUBSTEPS indent test # TODO ) + +if ("${BUILD_FLOWVR_PLUGIN}") + set(FLOWVR_DEPENDENCY FlowVR) +endif() + sbuild_add_module(PDI_EXAMPLE ENABLE_BUILD_FLAG BUILD_TESTING SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/example" - DEPENDS PDI + DEPENDS PDI ${FLOWVR_DEPENDENCY} INSTALL_COMMAND "" SUBSTEPS test ) @@ -545,5 +780,5 @@ sbuild_add_module(PDI_TESTS SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests" DEPENDS PDI INSTALL_COMMAND "" - SUBSTEPS test + SUBSTEPS indent test ) diff --git a/pdi/include/pdi.h b/pdi/include/pdi.h index e801d72ed..3cb544b31 100644 --- a/pdi/include/pdi.h +++ b/pdi/include/pdi.h @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (C) 2015-2021 Commissariat a l'energie atomique et aux energies alternatives (CEA) +* Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,7 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ -/** \file pdi.h +/** \file pdi_deactivation.h * * C user API * @@ -126,6 +126,182 @@ extern const PDI_errhandler_t PDI_EXPORT PDI_WARN_HANDLER; */ extern const PDI_errhandler_t PDI_EXPORT PDI_NULL_HANDLER; +#ifdef DISABLE_PDI + +/** Return a human-readabe message describing the last error that occured in PDI + */ +const char PDI_EXPORT * PDI_errmsg(void) = delete; + +/** Sets the error handler to use + * + * PDI_asserthandler is the default handler before this function is called + * + * \param handler the new handler to set + * \return the previous handler + */ +PDI_errhandler_t PDI_EXPORT PDI_errhandler(PDI_errhandler_t handler) = delete; + +/// \} + +/** \addtogroup init_final Initialization and finalization + * + * The initialization and finalization part of the API is used to setup PDI, + * release its resources and check version information. + * \{ + */ + +/** Initializes PDI + * \param[in] conf the configuration + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_init(PC_tree_t conf) = delete; + +/** Finalizes PDI + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_finalize(void) = delete; + +/** Checks PDI API version + * + * \param[out] provided version if non-null it is filled with the provided API version + * \param[in] expected if non-zero the expected API version + * \return an error status if the expected version is incompatible with the + * provided one + */ +PDI_status_t PDI_EXPORT PDI_version(unsigned long* provided, unsigned long expected) = delete; + +/// \} + +/** \addtogroup annotation + * \{ + */ + +/** + * Access directions + */ +typedef enum PDI_inout_e { + /// No data transfert + PDI_NONE = 0, + /// data tranfer from PDI to the main code + PDI_IN = 1, + /// data transfer from the main code to PDI + PDI_OUT = 2, + /// data transfer in both direction + PDI_INOUT = 3 + +} PDI_inout_t; + +/** Shares some data with PDI. The user code should not modify it before + * a call to either PDI_release or PDI_reclaim. + * \param[in] name the data name + * \param[in,out] data the accessed data + * \param[in] access whether the data can be accessed for read or write + * by PDI + * \return an error status + * \pre the user code owns the data buffer + * \post ownership of the data buffer is shared between PDI and the user code + * + * the access parameter is a binary OR of PDI_IN & PDI_OUT. + * * PDI_IN means PDI can set the buffer content + * * PDI_OUT means the buffer contains data that can be accessed by PDI + */ +PDI_status_t PDI_EXPORT PDI_share(const char* name, void* data, PDI_inout_t access) = delete; + +/** Requests for PDI to access a data buffer. + * \param[in] name the data name + * \param[in,out] buffer a pointer to the accessed data buffer + * \param[in] inout the access properties (PDI_IN, PDI_OUT, PDI_INOUT) + * \return an error status + * \pre PDI owns the data buffer + * \post ownership of the data buffer is shared between PDI and the user code + */ +PDI_status_t PDI_EXPORT PDI_access(const char* name, void** buffer, PDI_inout_t inout) = delete; + +/** Releases ownership of a data shared with PDI. PDI is then responsible to + * free the associated memory whenever necessary. + * \param[in] name name of the data to release + * \return an error status + * \pre ownership of the data buffer is shared between PDI and the user code + * \pre PDI owns the data buffer + */ +PDI_status_t PDI_EXPORT PDI_release(const char* name) = delete; + +/** Reclaims ownership of a data buffer shared with PDI. PDI does not manage + * the buffer memory anymore. + * \param[in] name name of the data to reclaim + * \return an error status + * \pre ownership of the data buffer is shared between PDI and the user code + * \post the user code owns the data buffer + */ +PDI_status_t PDI_EXPORT PDI_reclaim(const char* name) = delete; + +/** Triggers a PDI "event" + * \param[in] event the event name + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_event(const char* event) = delete; + +/** Shortly exposes some data to PDI. Equivalent to PDI_share + PDI_reclaim. + * \param[in] name the data name + * \param[in] data the exposed data + * \param[in] access whether the data can be accessed for read or write + * by PDI + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_expose(const char* name, void* data, PDI_inout_t access) = delete; + +/** Performs multiple exposes at once. All the data is shared in order they were specified + * and reclaimed in reversed order after an event is triggered. + * + * NULL argument indicates an end of the list. + * + * \param[in] event_name the name of the event that will be triggered when + * all data become available + * \param[in] name the data name + * \param[in] data the exposed data + * \param[in] access whether the data can be accessed for read or write by PDI + * \param[in] ... (additional arguments) additional list of data to expose, + * each should contain name, data and access, NULL argument + * inidactes an end of the list. + * \return an error status + */ +PDI_status_t PDI_EXPORT PDI_multi_expose(const char* event_name, const char* name, void* data, PDI_inout_t access, ...) = delete; + +#ifdef PDI_WITH_DEPRECATED + +/** Begin a transaction in which all PDI_expose calls are grouped. + * + * This requires a call to PDI_transaction_end to close the transaction. + * + * \deprecated the transaction part of the API is deprecated, the + * PDI_multi_expose function should be used instead. + * + * \see PDI_expose the function used to expose data inside the transaction + * \see PDI_transaction_end the function used to end the transaction + * + * \param[in] name the name of the transaction (an event thus named will be + * triggered when all data become available) + * \return an error status + */ +PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_begin(const char* name) = delete; + +/** Ends the previously opened transaction. + * + * \deprecated the transaction part of the API is deprecated, the + * PDI_multi_expose function should be used instead. + * + * \see PDI_transaction_begin the function used to start the transaction + * \see PDI_expose the function used to expose data inside the transaction + * + * \return an error status + */ +PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_end(void) = delete; + +#endif // PDI_WITH_DEPRECATED + +/// \} + +#else // DISABLE_PDI /** Return a human-readabe message describing the last error that occured in PDI */ @@ -300,6 +476,8 @@ PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_end(void); /// \} +#endif // DISABLE_PDI + #ifdef __cplusplus } // extern C #endif diff --git a/pdi/include/pdi_deactivation.h b/pdi/include/pdi_deactivation.h deleted file mode 100644 index 2378614ea..000000000 --- a/pdi/include/pdi_deactivation.h +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* -* Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of CEA nor the names of its contributors may be used to -* endorse or promote products derived from this software without specific -* prior written permission. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -******************************************************************************/ - -/** \file pdi_deactivation.h - * - * C user API - * - * The user facing API is the interface offered by PDI to C application - * developers. - * - * \defgroup init_final Initialization and finalization - * - * The initialization and finalization part of the API is used to setup PDI, - * release its resources and check version information. - * - * \defgroup annotation Code annotation - * - * The code annotation API is the main interface to use in the code. - * - * It offers functions that can be called from code with no side effect by - * default and that can therefore be considered as annotations. - * - * \defgroup error Error handling - * - * The error handling API supports checking the error status of PDI. - * - * By default, errors in PDI C API are signaled by a return code of type - * PDI_status_t and an error message can be retrieved with the PDI_errmsg - * function. This default behavior can be changed by replacing the error handler - * with the PDI_errhandler function. - * - */ - -#define PDI_H_ - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** \addtogroup error - * \{ - */ - -/** Error codes of PDI - */ -typedef enum PDI_status_e { - /// everything went well - PDI_OK = 0, - /// on an input call, no such data is available - PDI_UNAVAILABLE, - /// The configuration file is invalid - PDI_ERR_CONFIG, - /// A value expression is invalid - PDI_ERR_VALUE, - /// Tried to load a non-existing plugin - PDI_ERR_PLUGIN, - /// Implementation limitation (typically an unimplemented feature) - PDI_ERR_IMPL, - /// A system error occured (OS, etc.) - PDI_ERR_SYSTEM, - /** A call to a function has been made at a wrong time (e.g. closing an - * unopened transaction) - */ - PDI_ERR_STATE, - /// A conflict of onwership over a content has been raised - PDI_ERR_RIGHT, - /// Invalid type error - PDI_ERR_TYPE - -} PDI_status_t; - -/** Type of a callback function used when an error occurs - * \param status the error code - * \param message the human-readable error message - * \param context a user-provided context - */ -typedef void (*PDI_errfunc_f)(PDI_status_t status, const char* message, void* context); - -/** Definition of an error handler - */ -typedef struct PDI_errhandler_s { - /// The function to handle the error (none if NULL) - PDI_errfunc_f func; - - /// the context that will be provided to the function - void* context; - -} PDI_errhandler_t; - -/** Prints the error message and aborts if the status is invalid - */ -extern const PDI_errhandler_t PDI_EXPORT PDI_ASSERT_HANDLER; - -/** Prints the error message and continue if the status is invalid - */ -extern const PDI_errhandler_t PDI_EXPORT PDI_WARN_HANDLER; - -/** Does nothing - */ -extern const PDI_errhandler_t PDI_EXPORT PDI_NULL_HANDLER; - - -/** Return a human-readabe message describing the last error that occured in PDI - */ -const char PDI_EXPORT * PDI_errmsg(void){}; - -/** Sets the error handler to use - * - * PDI_asserthandler is the default handler before this function is called - * - * \param handler the new handler to set - * \return the previous handler - */ -PDI_errhandler_t PDI_EXPORT PDI_errhandler(PDI_errhandler_t handler){}; - -/// \} - -/** \addtogroup init_final Initialization and finalization - * - * The initialization and finalization part of the API is used to setup PDI, - * release its resources and check version information. - * \{ - */ - -/** Initializes PDI - * \param[in] conf the configuration - * \return an error status - */ -PDI_status_t PDI_EXPORT PDI_init(PC_tree_t conf){}; - -/** Finalizes PDI - * \return an error status - */ -PDI_status_t PDI_EXPORT PDI_finalize(void){}; - -/** Checks PDI API version - * - * \param[out] provided version if non-null it is filled with the provided API version - * \param[in] expected if non-zero the expected API version - * \return an error status if the expected version is incompatible with the - * provided one - */ -PDI_status_t PDI_EXPORT PDI_version(unsigned long* provided, unsigned long expected){}; - -/// \} - -/** \addtogroup annotation - * \{ - */ - -/** - * Access directions - */ -typedef enum PDI_inout_e { - /// No data transfert - PDI_NONE = 0, - /// data tranfer from PDI to the main code - PDI_IN = 1, - /// data transfer from the main code to PDI - PDI_OUT = 2, - /// data transfer in both direction - PDI_INOUT = 3 - -} PDI_inout_t; - -/** Shares some data with PDI. The user code should not modify it before - * a call to either PDI_release or PDI_reclaim. - * \param[in] name the data name - * \param[in,out] data the accessed data - * \param[in] access whether the data can be accessed for read or write - * by PDI - * \return an error status - * \pre the user code owns the data buffer - * \post ownership of the data buffer is shared between PDI and the user code - * - * the access parameter is a binary OR of PDI_IN & PDI_OUT. - * * PDI_IN means PDI can set the buffer content - * * PDI_OUT means the buffer contains data that can be accessed by PDI - */ -PDI_status_t PDI_EXPORT PDI_share(const char* name, void* data, PDI_inout_t access){}; - -/** Requests for PDI to access a data buffer. - * \param[in] name the data name - * \param[in,out] buffer a pointer to the accessed data buffer - * \param[in] inout the access properties (PDI_IN, PDI_OUT, PDI_INOUT) - * \return an error status - * \pre PDI owns the data buffer - * \post ownership of the data buffer is shared between PDI and the user code - */ -PDI_status_t PDI_EXPORT PDI_access(const char* name, void** buffer, PDI_inout_t inout){}; - -/** Releases ownership of a data shared with PDI. PDI is then responsible to - * free the associated memory whenever necessary. - * \param[in] name name of the data to release - * \return an error status - * \pre ownership of the data buffer is shared between PDI and the user code - * \pre PDI owns the data buffer - */ -PDI_status_t PDI_EXPORT PDI_release(const char* name){}; - -/** Reclaims ownership of a data buffer shared with PDI. PDI does not manage - * the buffer memory anymore. - * \param[in] name name of the data to reclaim - * \return an error status - * \pre ownership of the data buffer is shared between PDI and the user code - * \post the user code owns the data buffer - */ -PDI_status_t PDI_EXPORT PDI_reclaim(const char* name){}; - -/** Triggers a PDI "event" - * \param[in] event the event name - * \return an error status - */ -PDI_status_t PDI_EXPORT PDI_event(const char* event){}; - -/** Shortly exposes some data to PDI. Equivalent to PDI_share + PDI_reclaim. - * \param[in] name the data name - * \param[in] data the exposed data - * \param[in] access whether the data can be accessed for read or write - * by PDI - * \return an error status - */ -PDI_status_t PDI_EXPORT PDI_expose(const char* name, void* data, PDI_inout_t access){}; - -/** Performs multiple exposes at once. All the data is shared in order they were specified - * and reclaimed in reversed order after an event is triggered. - * - * NULL argument indicates an end of the list. - * - * \param[in] event_name the name of the event that will be triggered when - * all data become available - * \param[in] name the data name - * \param[in] data the exposed data - * \param[in] access whether the data can be accessed for read or write by PDI - * \param[in] ... (additional arguments) additional list of data to expose, - * each should contain name, data and access, NULL argument - * inidactes an end of the list. - * \return an error status - */ -PDI_status_t PDI_EXPORT PDI_multi_expose(const char* event_name, const char* name, void* data, PDI_inout_t access, ...){}; - -#ifdef PDI_WITH_DEPRECATED - -/** Begin a transaction in which all PDI_expose calls are grouped. - * - * This requires a call to PDI_transaction_end to close the transaction. - * - * \deprecated the transaction part of the API is deprecated, the - * PDI_multi_expose function should be used instead. - * - * \see PDI_expose the function used to expose data inside the transaction - * \see PDI_transaction_end the function used to end the transaction - * - * \param[in] name the name of the transaction (an event thus named will be - * triggered when all data become available) - * \return an error status - */ -PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_begin(const char* name){}; - -/** Ends the previously opened transaction. - * - * \deprecated the transaction part of the API is deprecated, the - * PDI_multi_expose function should be used instead. - * - * \see PDI_transaction_begin the function used to start the transaction - * \see PDI_expose the function used to expose data inside the transaction - * - * \return an error status - */ -PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_end(void){}; - -#endif // PDI_WITH_DEPRECATED - -/// \} - -#ifdef __cplusplus -} // extern C -#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8386477f4..7512fd9da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ #============================================================================= # Copyright (C) 2020 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC) -# Copyright (C) 2020-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) +# Copyright (C) 2020-2022 Commissariat a l'energie atomique et aux energies alternatives (CEA) # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -23,18 +23,24 @@ # THE SOFTWARE. #============================================================================= -cmake_minimum_required(VERSION 3.16...3.29) +cmake_minimum_required(VERSION 3.10...3.25) project(pdi_tests LANGUAGES C) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") set(RUNTEST_DIR "${CMAKE_CURRENT_LIST_DIR}/../cmake/runtest-dir") option(BUILD_DECL_HDF5_PLUGIN "Build Decl'HDF5 plug-in" ON) +option(BUILD_INDENT "Enable automatic code indentation" OFF) option(BUILD_SERIALIZE_PLUGIN "Build Serialize plug-in" ON) # Includes include(CTest) +# Astyle +if("${BUILD_INDENT}") + find_package(Astyle 3.1 REQUIRED) +endif() + # PDI find_package(PDI REQUIRED COMPONENTS C) @@ -68,3 +74,10 @@ target_link_libraries(test_05_C PDI::PDI_C) add_test(NAME test_05_C COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/test_05.yml") endif("${BUILD_DECL_NETCDF_PLUGIN}" AND "${BUILD_SERIALIZE_PLUGIN}") + +# Indentation +if("${BUILD_INDENT}") + Astyle_add_indent(indent TEST + OPTIONS_FILE formating.astyle + *.c *.h) +endif() diff --git a/tests/test_06.c b/tests/test_06.c index f84359a67..798ae725a 100644 --- a/tests/test_06.c +++ b/tests/test_06.c @@ -24,8 +24,8 @@ ******************************************************************************/ #include -// #include -#include +#include +// #include #include int main(int argc, char* argv[]) @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) // # As the value is shared with pdi.h, it can be reclaimed in a second time. // # In the case of pdi_deactivation.h, the value is never shared, hence the reclaim operation fails. - // PDI_share("global_size", global_size, PDI_OUT) == NULL; + PDI_share("global_size", global_size, PDI_OUT) == NULL; PDI_reclaim("global_size"); PDI_finalize(); From 803a1e2d1e995443d37b5483ed39d3a8596fd583 Mon Sep 17 00:00:00 2001 From: Julian Auriac Date: Mon, 20 Jan 2025 10:28:49 +0100 Subject: [PATCH 9/9] Removed paraconf dependency --- pdi/include/pdi.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/pdi/include/pdi.h b/pdi/include/pdi.h index 3cb544b31..4c982a502 100644 --- a/pdi/include/pdi.h +++ b/pdi/include/pdi.h @@ -55,8 +55,6 @@ #ifndef PDI_H_ #define PDI_H_ -#include - #include #include