From 2c00523a57e93f3d570600093d90f1b406de64f8 Mon Sep 17 00:00:00 2001 From: Abhiram S Date: Fri, 19 Sep 2025 17:05:15 +0530 Subject: [PATCH 1/3] DLP: Added version API Signed-off-by: Abhiram S --- classic/frame/runtime/dlp_runtime.c | 15 +++++++++ examples/classic/CMakeLists.txt | 1 + examples/classic/version.c | 40 +++++++++++++++++++++++ include/classic/aocl_lib_interface_apis.h | 2 ++ 4 files changed, 58 insertions(+) create mode 100644 examples/classic/version.c diff --git a/classic/frame/runtime/dlp_runtime.c b/classic/frame/runtime/dlp_runtime.c index 6bbf60a..c0d129f 100644 --- a/classic/frame/runtime/dlp_runtime.c +++ b/classic/frame/runtime/dlp_runtime.c @@ -28,6 +28,7 @@ #include +#include "aocl_dlp_config.h" #include "bindings/c_wrappers/capi_env_config.h" #include "classic/aocl_lib_interface_apis.h" #include "runtime/dlp_runtime.h" @@ -212,3 +213,17 @@ dlp_thread_set_num_threads(md_t n_threads) // env variables will not be of effect going forward. dlp_tl_rntm.ext_mt_ctr_var = FALSE; } + +void +dlp_version_query(int* major, int* minor, int* patch) +{ + char* AOCL_DLP_VERSION_MAJOR_STR = AOCL_DLP_VERSION_MAJOR; + char* AOCL_DLP_VERSION_MINOR_STR = AOCL_DLP_VERSION_MINOR; + char* AOCL_DLP_VERSION_PATCH_STR = AOCL_DLP_VERSION_PATCH; + if (major) + *major = atoi(AOCL_DLP_VERSION_MAJOR_STR); + if (minor) + *minor = atoi(AOCL_DLP_VERSION_MINOR_STR); + if (patch) + *patch = atoi(AOCL_DLP_VERSION_PATCH_STR); +} diff --git a/examples/classic/CMakeLists.txt b/examples/classic/CMakeLists.txt index b48df4f..895c66f 100644 --- a/examples/classic/CMakeLists.txt +++ b/examples/classic/CMakeLists.txt @@ -34,6 +34,7 @@ set(EXAMPLE_SOURCES quantization.c post_ops_combinations.c eltwise_ops.c + version.c ) # Create an executable for each example source file diff --git a/examples/classic/version.c b/examples/classic/version.c new file mode 100644 index 0000000..63e9604 --- /dev/null +++ b/examples/classic/version.c @@ -0,0 +1,40 @@ +/* + * Copyright © Advanced Micro Devices, Inc., or its affiliates. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "aocl_dlp.h" + +#include + +int +main() +{ + int major, minor, patch; + dlp_version_query(&major, &minor, &patch); + printf("AOCL-DLP Version: %d.%d.%d\n", major, minor, patch); + return 0; +} diff --git a/include/classic/aocl_lib_interface_apis.h b/include/classic/aocl_lib_interface_apis.h index e87b125..3dc67f7 100644 --- a/include/classic/aocl_lib_interface_apis.h +++ b/include/classic/aocl_lib_interface_apis.h @@ -38,5 +38,7 @@ DLP_CLASSIC_EXPORT void dlp_thread_set_num_threads(md_t n_threads); DLP_CLASSIC_EXPORT bool dlp_aocl_enable_instruction_query(void); +DLP_CLASSIC_EXPORT void +dlp_version_query(int* major, int* minor, int* patch); #endif // AOCL_LIB_INTERFACE_H From 0cf0f3756003044f3cbf52d9d04567f504766691 Mon Sep 17 00:00:00 2001 From: Abhiram S Date: Fri, 19 Sep 2025 17:34:35 +0530 Subject: [PATCH 2/3] DLP: Remove un-necessary variables This commit addresses https://github.com/amd/aocl-dlp/pull/2#discussion_r2362664380 Signed-off-by: Abhiram S --- classic/frame/runtime/dlp_runtime.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/classic/frame/runtime/dlp_runtime.c b/classic/frame/runtime/dlp_runtime.c index c0d129f..23b18a7 100644 --- a/classic/frame/runtime/dlp_runtime.c +++ b/classic/frame/runtime/dlp_runtime.c @@ -217,13 +217,10 @@ dlp_thread_set_num_threads(md_t n_threads) void dlp_version_query(int* major, int* minor, int* patch) { - char* AOCL_DLP_VERSION_MAJOR_STR = AOCL_DLP_VERSION_MAJOR; - char* AOCL_DLP_VERSION_MINOR_STR = AOCL_DLP_VERSION_MINOR; - char* AOCL_DLP_VERSION_PATCH_STR = AOCL_DLP_VERSION_PATCH; if (major) - *major = atoi(AOCL_DLP_VERSION_MAJOR_STR); + *major = atoi(AOCL_DLP_VERSION_MAJOR); if (minor) - *minor = atoi(AOCL_DLP_VERSION_MINOR_STR); + *minor = atoi(AOCL_DLP_VERSION_MINOR); if (patch) - *patch = atoi(AOCL_DLP_VERSION_PATCH_STR); + *patch = atoi(AOCL_DLP_VERSION_PATCH); } From 5487fcb812b086dd07bd771a1f47fae804059aa2 Mon Sep 17 00:00:00 2001 From: Abhiram S Date: Tue, 23 Sep 2025 13:08:05 +0530 Subject: [PATCH 3/3] CMake: Change version to literal from string Signed-off-by: Abhiram S --- classic/frame/runtime/dlp_runtime.c | 6 +++--- cmake/aocl_dlp_config.h.in | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/classic/frame/runtime/dlp_runtime.c b/classic/frame/runtime/dlp_runtime.c index 23b18a7..04f7745 100644 --- a/classic/frame/runtime/dlp_runtime.c +++ b/classic/frame/runtime/dlp_runtime.c @@ -218,9 +218,9 @@ void dlp_version_query(int* major, int* minor, int* patch) { if (major) - *major = atoi(AOCL_DLP_VERSION_MAJOR); + *major = AOCL_DLP_VERSION_MAJOR; if (minor) - *minor = atoi(AOCL_DLP_VERSION_MINOR); + *minor = AOCL_DLP_VERSION_MINOR; if (patch) - *patch = atoi(AOCL_DLP_VERSION_PATCH); + *patch = AOCL_DLP_VERSION_PATCH; } diff --git a/cmake/aocl_dlp_config.h.in b/cmake/aocl_dlp_config.h.in index 80ffb40..308816e 100644 --- a/cmake/aocl_dlp_config.h.in +++ b/cmake/aocl_dlp_config.h.in @@ -1,12 +1,18 @@ #ifndef AOCL_DLP_CONFIG_H #define AOCL_DLP_CONFIG_H -// Version information -#define AOCL_DLP_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@" -#define AOCL_DLP_VERSION_MINOR "@PROJECT_VERSION_MINOR@" -#define AOCL_DLP_VERSION_PATCH "@PROJECT_VERSION_PATCH@" - -#define AOCL_DLP_VERSION "@PROJECT_VERSION@" +// Version information - numeric constants +// clang-format off +#define AOCL_DLP_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define AOCL_DLP_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define AOCL_DLP_VERSION_PATCH @PROJECT_VERSION_PATCH@ +// clang-format on + +// Version information - string constants +#define AOCL_DLP_VERSION_MAJOR_STR "@PROJECT_VERSION_MAJOR@" +#define AOCL_DLP_VERSION_MINOR_STR "@PROJECT_VERSION_MINOR@" +#define AOCL_DLP_VERSION_PATCH_STR "@PROJECT_VERSION_PATCH@" +#define AOCL_DLP_VERSION_STRING "@PROJECT_VERSION@" // Build configuration #cmakedefine DLP_ENABLE_OPENMP