Skip to content

Commit 32d6485

Browse files
committed
Merge branch 'develop' of github.com:llnl/Umpire into task/available-allocators-errors
2 parents 6470d48 + f81afca commit 32d6485

24 files changed

Lines changed: 2098 additions & 24 deletions

.github/actions/shroud/entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -euo pipefail
4+
35
git config --global --add safe.directory /github/workspace
46
git config --global --add safe.directory /github/workspace/.radiuss-ci
57
git config --global --add safe.directory /github/workspace/blt
@@ -13,4 +15,3 @@ git submodule update --init --recursive
1315
mkdir build && cd build
1416
cmake -DCMAKE_CXX_COMPILER=clang++ -DSHROUD_EXECUTABLE=/usr/local/bin/shroud ..
1517
make -j 3 generate_umpire_shroud
16-

.github/workflows/generate-shroud.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
on:
1+
on:
2+
workflow_dispatch:
23
pull_request:
34
paths:
45
- '**umpire_shroud.yaml'
56
- '**genfumpiresplicer.f'
7+
- '**gencumpiresplicer.inc'
68

79
name: Generate C/FORTRAN Interface
810
jobs:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ install(FILES
197197
"${PROJECT_BINARY_DIR}/umpire-config-version.cmake"
198198
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/umpire)
199199

200-
install(EXPORT umpire-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/umpire)
200+
install(EXPORT umpire-targets NAMESPACE umpire:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/umpire)
201201

202202
if (UMPIRE_ENABLE_TESTS)
203203
add_subdirectory(tests)

cmake/SetupUmpireOptions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ option(UMPIRE_ENABLE_SANITIZER_TESTS "Enable address sanitizer tests" Off)
3939
option(UMPIRE_ENABLE_DEVICE_ALLOCATOR "Enable Device Allocator" Off)
4040
option(UMPIRE_ENABLE_SQLITE_EXPERIMENTAL "Build with sqlite event integration (experimental)" Off)
4141
option(UMPIRE_DISABLE_ALLOCATIONMAP_DEBUG "Disable verbose output from AllocationMap during debug builds" Off)
42+
option(UMPIRE_DISABLE_ALIAS_TARGETS "Disable non-namespaced alias targets (e.g., umpire) for exported targets" Off)
4243
set(UMPIRE_FMT_TARGET fmt::fmt-header-only CACHE STRING "Name of fmt target to use")
4344

4445
if (UMPIRE_ENABLE_INACCESSIBILITY_TESTS)

docs/sphinx/getting_started.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ point to the root of your Umpire installation, you can call
6464
``find_package(umpire)`` inside your CMake project and Umpire will be
6565
automatically detected and available for use.
6666

67+
When using Umpire in your CMake project, link against the namespaced target
68+
``umpire::umpire``:
69+
70+
.. code-block:: cmake
71+
72+
find_package(umpire REQUIRED)
73+
target_link_libraries(your_target umpire::umpire)
74+
75+
For backwards compatibility, the non-namespaced target ``umpire`` is still
76+
available but deprecated. Using namespaced targets provides better error
77+
diagnostics when ``find_package()`` is missing.
78+
6779
-----------
6880
Basic Usage
6981
-----------

docs/sphinx/tutorial/fortran/allocators.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
=======================
44
FORTRAN API: Allocators
55
=======================
6-
6+
77
The fundamental concept for accessing memory through Umpire is an
88
:class:`umpire:Allocator`. In FORTRAN, this means using the type
99
``UmpireAllocator``. This type provides an ``allocate_pointer`` function to
1010
allocate raw memory, and a generic ``allocate`` procedure that takes an array
1111
pointer and an array of dimensions and will allocate the correct amount of
1212
memory.
13-
13+
1414
As with the native C++ interface, all allocators are accessed via the
1515
:class:`umpire::ResourceManager`. In the FORTRAN API, there is a corresponding
1616
``UmpireResourceManager`` type. To get an ``UmpireAllocator``:
@@ -31,3 +31,7 @@ deallocate memory:
3131

3232
In this case, we allocate a one-dimensional array using the generic
3333
``allocate`` function.
34+
35+
.. note::
36+
37+
Umpire's FORTRAN interface is generated with the help of `Shroud <https://shroud.readthedocs.io/en/latest/>`_.

src/umpire/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ if (UMPIRE_ENABLE_DEVICE_ALLOCATOR AND (UMPIRE_ENABLE_CUDA OR UMPIRE_ENABLE_HIP)
6565
SOURCES ${umpire_device_sources}
6666
DEPENDS_ON ${umpire_device_depends})
6767

68+
# Create namespaced alias for build tree
69+
add_library(umpire::umpire_device ALIAS umpire_device)
70+
6871
target_include_directories(
6972
umpire_device
7073
PUBLIC
@@ -139,6 +142,9 @@ blt_add_library(
139142
DEPENDS_ON ${umpire_depends}
140143
DEFINES ${umpire_defines})
141144

145+
# Create namespaced alias for build tree
146+
add_library(umpire::umpire ALIAS umpire)
147+
142148
if (NOT WIN32 AND NOT ${CMAKE_VERSION} VERSION_LESS 3.18)
143149
target_link_options(
144150
umpire INTERFACE

src/umpire/event/event.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ inline std::string to_string(const camp::resources::Resource& r)
4747
return "camp::resource::Undefined";
4848
}
4949

50-
return "unkown resource";
50+
return "unknown resource";
5151
}
5252

5353
} // namespace v1

src/umpire/event/json_file_store.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "fmt/format.h"
1818
#include "umpire/event/event_json.hpp"
1919
#include "umpire/json/json.hpp"
20+
#include "umpire/util/Macros.hpp"
2021
#include "umpire/util/error.hpp"
2122

2223
namespace umpire {
@@ -25,11 +26,26 @@ namespace event {
2526
json_file_store::json_file_store(const std::string& filename, bool read_only)
2627
: m_filename{filename}, m_read_only{read_only}
2728
{
29+
m_fstream = fopen(m_filename.c_str(), m_read_only ? "r" : "w");
30+
31+
if (m_fstream == NULL) {
32+
UMPIRE_ERROR(umpire::runtime_error, fmt::format("Failed to open {}", m_filename));
33+
}
34+
}
35+
36+
json_file_store::~json_file_store()
37+
{
38+
if (m_fstream != nullptr) {
39+
if (!m_read_only) {
40+
fflush(m_fstream); // Flush buffered writes before close.
41+
}
42+
fclose(m_fstream); // Close the file
43+
m_fstream = nullptr;
44+
}
2845
}
2946

3047
void json_file_store::insert(const event& e)
3148
{
32-
open_store();
3349
nlohmann::json json_event = e;
3450
std::stringstream ss;
3551
ss << json_event;
@@ -112,7 +128,6 @@ std::vector<event> json_file_store::get_events()
112128
std::vector<event> events;
113129
std::size_t line_number{1};
114130

115-
open_store();
116131
while (getline(&line, &len, m_fstream) != -1) {
117132
nlohmann::json json_event;
118133
event e;
@@ -166,17 +181,5 @@ std::vector<event> json_file_store::get_events()
166181
return events;
167182
}
168183
#endif
169-
170-
void json_file_store::open_store()
171-
{
172-
if (m_fstream == NULL) {
173-
m_fstream = fopen(m_filename.c_str(), m_read_only ? "r" : "w");
174-
175-
if (m_fstream == NULL) {
176-
UMPIRE_ERROR(umpire::runtime_error, fmt::format("Failed to open {}", m_filename));
177-
}
178-
}
179-
}
180-
181184
} // namespace event
182185
} // namespace umpire

src/umpire/event/json_file_store.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct deallocate_resource;
2727
class json_file_store : public event_store {
2828
public:
2929
json_file_store(const std::string& filename, bool read_only = false);
30+
~json_file_store();
3031

3132
virtual void insert(const event& e);
3233
virtual void insert(const allocate& e);
@@ -38,7 +39,6 @@ class json_file_store : public event_store {
3839
virtual std::vector<event> get_events();
3940

4041
private:
41-
void open_store();
4242
FILE* m_fstream{nullptr};
4343
std::string m_filename;
4444
bool m_read_only;

0 commit comments

Comments
 (0)