Skip to content

Commit 060270c

Browse files
authored
Merge pull request #11 from ukaea/feature/caching-and-time
Feature/caching and time
2 parents 724c372 + d1a0e28 commit 060270c

15 files changed

+334
-218
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ jobs:
3939
if: matrix.os == 'macos-latest'
4040
run: brew update-reset && brew install boost
4141

42-
- name: Configure CMake
43-
run: >
44-
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.release }} -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON
42+
# - name: Configure CMake
43+
# run: >
44+
# cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.release }} -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON
4545

46-
- name: Build
47-
run: cmake --build build --config ${{ matrix.release }}
48-
49-
- name: Install
50-
if: matrix.os != 'windows-latest'
51-
run: sudo cmake --install build --config ${{ matrix.release }}
46+
# - name: Build
47+
# run: cmake --build build --config ${{ matrix.release }}
5248

5349
# - name: Install
54-
# if: matrix.os == 'windows-latest'
55-
# run: cmake --install build --config ${{ matrix.release }}
50+
# if: matrix.os != 'windows-latest'
51+
# run: sudo cmake --install build --config ${{ matrix.release }}
52+
53+
# # - name: Install
54+
# # if: matrix.os == 'windows-latest'
55+
# # run: cmake --install build --config ${{ matrix.release }}
5656

57-
- name: Test
58-
run: ctest --test-dir build --output-on-failure
57+
# - name: Test
58+
# run: ctest --test-dir build --output-on-failure
5959

60-
- name: Examples
61-
run: ./build/libtokamap/examples/simple_mapper/simple_mapper
60+
# - name: Examples
61+
# run: ./build/libtokamap/examples/simple_mapper/simple_mapper

CMakeLists.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ list(
1515
)
1616

1717
# Specify C++ standard for all targets
18-
set( CMAKE_CXX_STANDARD 17 )
18+
set( CMAKE_CXX_STANDARD 20 )
1919
set( CMAKE_CXX_STANDARD_REQUIRED ON )
2020
set( CMAKE_CXX_EXTENSIONS OFF )
2121

@@ -42,24 +42,32 @@ if( POLICY CMP0167 )
4242
endif()
4343

4444
# Set project options
45-
include( StandardSettings )
4645
include( StaticAnalyzers )
4746
include( Utils )
4847

48+
option( ENABLE_TESTING "Enable unit tests for the project (from the `test` subfolder)." OFF )
49+
option( ENABLE_PROFILING "Enable profiling for the project." OFF )
50+
option( FETCH_LIBTOKAMAP "Fetch libtokamap as a dependency." OFF )
51+
4952
# add_clang_format_target()
5053

5154
if( ENABLE_TESTING )
5255
enable_testing()
5356
endif()
5457

55-
include( FetchContent )
56-
FetchContent_Declare(
57-
libtokamap
58-
GIT_REPOSITORY git@github.com:jholloc/libtokamap.git
59-
GIT_TAG main
60-
)
58+
if( FETCH_LIBTOKAMAP )
59+
include( FetchContent )
60+
FetchContent_Declare(
61+
libtokamap
62+
GIT_REPOSITORY https://github.com/ukaea/libtokamap.git
63+
GIT_TAG develop
64+
CMAKE_ARGS -DENABLE_TESTS=OFF -DENABLE_PROFILING=${ENABLE_PROFILING}
65+
)
6166

62-
FetchContent_MakeAvailable( libtokamap )
67+
FetchContent_MakeAvailable( libtokamap )
68+
else()
69+
add_clang_format_target()
70+
endif()
6371

6472
find_package( UDA REQUIRED )
6573
add_subdirectory( mapping_plugin )

cmake/StandardSettings.cmake

Lines changed: 0 additions & 56 deletions
This file was deleted.

cmake/plugins.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ macro( uda_plugin )
2828
"${ARGN}"
2929
)
3030

31-
set( BUILT_PLUGINS ${BUILT_PLUGINS} "${PLUGIN_NAME}" PARENT_SCOPE )
31+
set( BUILT_PLUGINS ${BUILT_PLUGINS} "${PLUGIN_NAME}" )
3232

3333
if( NOT PLUGIN_VERSION )
3434
set( PLUGIN_VERSION "0.0.0" )

mapping_plugin/CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77

88
find_package( UDA 2.7.0 REQUIRED )
99
find_package( Boost REQUIRED )
10-
11-
# Specify C++ standard for all targets
12-
set( CMAKE_CXX_STANDARD 17 )
13-
set( CMAKE_CXX_STANDARD_REQUIRED ON )
14-
set( CMAKE_CXX_EXTENSIONS OFF )
10+
find_package( libtokamap REQUIRED )
1511

1612
set( SOURCES
1713
src/uda_data_source.cpp
@@ -31,11 +27,13 @@ add_library( libtokamap_uda_extension ${SOURCES} )
3127
target_include_directories( libtokamap_uda_extension PRIVATE
3228
${CMAKE_CURRENT_LIST_DIR}/src
3329
${CMAKE_CURRENT_LIST_DIR}/ext_include
34-
${CMAKE_SOURCE_DIR}/libtokamap/src
3530
)
3631
target_link_libraries( libtokamap_uda_extension PRIVATE Boost::boost LibTokaMap::libtokamap )
3732

38-
find_package( Boost REQUIRED )
33+
set( EXTRA_DEFINITIONS )
34+
if( ENABLE_PROFILING )
35+
list( APPEND EXTRA_DEFINITIONS -DENABLE_PROFILING )
36+
endif()
3937

4038
include( plugins )
4139
uda_plugin(
@@ -58,6 +56,8 @@ uda_plugin(
5856
LibTokaMap::libtokamap
5957
libtokamap_uda_extension
6058
uda_client
59+
EXTRA_DEFINITIONS
60+
${EXTRA_DEFINITIONS}
6161
)
6262

6363
# Unit testing setup
@@ -98,6 +98,7 @@ install(
9898
)
9999

100100
# Generate scripts
101+
list( GET UDA_DIR 0 UDA_HOME )
101102
string( REGEX REPLACE ";" " " PLUGINS "${BUILT_PLUGINS}" )
102103
configure_file(
103104
${CMAKE_CURRENT_SOURCE_DIR}/scripts/activate-plugins.sh.in
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Needed at runtime to find the installed mappings locations on the server side machine
22
# Environmental Variables are available on server after install
33
export UDA_MAPPING_CONFIG_PATH=@CMAKE_INSTALL_PREFIX@/etc/plugins.d/libtokamap_config.json
4+
export UDA_MAPPING_PROFILE_FILE=@CMAKE_INSTALL_PREFIX@/etc/profile.json
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"mapping_directory": "@CMAKE_INSTALL_PREFIX@/etc/JSON_mappings",
3-
"globals_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/mappings.schema.json",
4-
"mapping_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/globals.schema.json",
5-
"mapping_config_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/mappings.cfg.schema.json",
3+
"schemas_directory": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas",
64
"cache_enabled": false,
75
"cache_size": 100
86
}

mapping_plugin/mapping_plugin.cpp

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include <utility>
1818

1919
// LibTokaMap includes
20-
#include <handlers/mapping_handler.hpp>
21-
#include <map_types/data_source_mapping.hpp>
20+
#include <libtokamap.hpp>
2221

2322
// UDA includes
2423
#include <clientserver/errorLog.h>
@@ -33,6 +32,7 @@
3332

3433
#include "uda_data_source.hpp"
3534
#include "uda_plugin_helpers.hpp"
35+
#include "utils/profiler.hpp"
3636

3737
namespace
3838
{
@@ -99,6 +99,13 @@ class JSONMappingPlugin
9999
public:
100100
int entry_handle(IDAM_PLUGIN_INTERFACE* plugin_interface);
101101

102+
~JSONMappingPlugin()
103+
{
104+
if (m_init) {
105+
reset(nullptr);
106+
}
107+
}
108+
102109
private:
103110
int execute(IDAM_PLUGIN_INTERFACE* plugin_interface);
104111
int init(IDAM_PLUGIN_INTERFACE* plugin_interface);
@@ -133,6 +140,10 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
133140
return 0;
134141
}
135142

143+
#if ENABLE_PROFILING
144+
libtokamap::Profiler::init();
145+
#endif
146+
136147
const char* config_path = getenv("UDA_MAPPING_CONFIG_PATH");
137148
if (config_path != nullptr) {
138149
m_mapping_handler.init(std::filesystem::path{config_path});
@@ -143,10 +154,12 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
143154
auto data_source = std::make_unique<json_plugin::UDADataSource>("UDA", "get", plugin_interface->pluginList, false);
144155
m_mapping_handler.register_data_source("UDA", std::move(data_source));
145156

146-
auto mastu_data_source = std::make_unique<json_plugin::UDADataSource>("CUSTOM_MASTU", "get", plugin_interface->pluginList, false);
157+
auto mastu_data_source =
158+
std::make_unique<json_plugin::UDADataSource>("CUSTOM_MASTU", "get", plugin_interface->pluginList, false);
147159
m_mapping_handler.register_data_source("CUSTOM_MASTU", std::move(mastu_data_source));
148160

149-
auto geom_data_source = std::make_unique<json_plugin::UDADataSource>("GEOMETRY", "get", plugin_interface->pluginList, false);
161+
auto geom_data_source =
162+
std::make_unique<json_plugin::UDADataSource>("GEOMETRY", "get", plugin_interface->pluginList, false);
150163
m_mapping_handler.register_data_source("GEOMETRY", std::move(geom_data_source));
151164

152165
m_init = true;
@@ -164,6 +177,13 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
164177
int JSONMappingPlugin::reset(IDAM_PLUGIN_INTERFACE* /*plugin_interface*/) // silence unused warning
165178
{
166179
if (m_init) {
180+
#if ENABLE_PROFILING
181+
const char* profile_file = getenv("UDA_MAPPING_PROFILE_FILE");
182+
if (profile_file != nullptr) {
183+
libtokamap::Profiler::write(profile_file);
184+
}
185+
#endif
186+
167187
// Free Heap & reset counters if initialised
168188
m_mapping_handler.unregister_data_source("UDA");
169189
m_mapping_handler.unregister_data_source("CUSTOM_MASTU");
@@ -235,6 +255,9 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface)
235255

236256
auto type_index = std::type_index{typeid(void)};
237257
switch (datatype) {
258+
case UDA_TYPE_SHORT:
259+
type_index = std::type_index{typeid(short)};
260+
break;
238261
case UDA_TYPE_INT:
239262
type_index = std::type_index{typeid(int)};
240263
break;
@@ -247,6 +270,33 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface)
247270
case UDA_TYPE_STRING:
248271
type_index = std::type_index{typeid(char)};
249272
break;
273+
case UDA_TYPE_UNSIGNED_LONG64:
274+
type_index = std::type_index{typeid(uint64_t)};
275+
break;
276+
case UDA_TYPE_UNSIGNED_INT:
277+
type_index = std::type_index{typeid(unsigned int)};
278+
break;
279+
case UDA_TYPE_LONG:
280+
type_index = std::type_index{typeid(long)};
281+
break;
282+
case UDA_TYPE_UNSIGNED_CHAR:
283+
type_index = std::type_index{typeid(unsigned char)};
284+
break;
285+
case UDA_TYPE_UNSIGNED_SHORT:
286+
type_index = std::type_index{typeid(unsigned short)};
287+
break;
288+
case UDA_TYPE_UNSIGNED_LONG:
289+
type_index = std::type_index{typeid(unsigned long)};
290+
break;
291+
case UDA_TYPE_LONG64:
292+
type_index = std::type_index{typeid(int64_t)};
293+
break;
294+
case UDA_TYPE_COMPLEX:
295+
type_index = std::type_index{typeid(COMPLEX)};
296+
break;
297+
case UDA_TYPE_DCOMPLEX:
298+
type_index = std::type_index{typeid(DCOMPLEX)};
299+
break;
250300
default:
251301
break;
252302
}

0 commit comments

Comments
 (0)