Skip to content

Commit

Permalink
Merge branch 'master' into chogan/bo_organize
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHogan committed Jan 27, 2022
2 parents b4076d4 + c834ddc commit f3c423a
Show file tree
Hide file tree
Showing 39 changed files with 2,752 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ name: GitHub Actions
# events but only for the master branch
on:
push:
branches: [ master, chogan/**, kimmy/**, hariharan/** ]
pull_request:
branches: [ master ]
workflow_dispatch:
Expand Down Expand Up @@ -52,6 +51,8 @@ jobs:
sudo apt update
sudo apt-get install -y autoconf
sudo apt-get install -y automake
sudo apt-get install -y libtool
sudo apt-get install -y libtool-bin
sudo apt-get install -y mpich
sudo apt-get install -y lcov
sudo apt-get install -y zlib1g-dev
Expand Down
66 changes: 33 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ project(HERMES)
# Version information
#------------------------------------------------------------------------------
set(HERMES_VERSION_MAJOR "0")
set(HERMES_VERSION_MINOR "2")
set(HERMES_VERSION_MINOR "3")
set(HERMES_VERSION_PATCH "0")
set(HERMES_PACKAGE "hermes")
set(HERMES_PACKAGE_NAME "HERMES")
Expand Down Expand Up @@ -152,6 +152,7 @@ option(HERMES_BUILD_BENCHMARKS "Build the Hermes benchmark suite." OFF)
option(HERMES_ENABLE_TIMING "Turn on timing of selected functions." OFF)
option(HERMES_ENABLE_COVERAGE "Enable code coverage." OFF)
option(HERMES_ENABLE_ADAPTERS "Enable hermes adapters." ON)
option(HERMES_ENABLE_VFD "Build the Hermes HDF5 Virtual File Driver" OFF)
option(HERMES_ENABLE_WRAPPER "Enable hermes C API wrapper." ON)
option(HERMES_INSTALL_TESTS "Enable installation of tests." OFF)
# Calculate code coverage with debug mode
Expand Down Expand Up @@ -183,10 +184,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
CACHE STRING "" FORCE)
endif()

if (HERMES_USE_ADDRESS_SANITIZER AND
NOT "${CMAKE_CXX_FLAGS_DEBUG}" MATCHES ".*-fsanitize=address.*")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address"
if (HERMES_USE_ADDRESS_SANITIZER)
if(NOT "${CMAKE_CXX_FLAGS_DEBUG}" MATCHES ".*-fsanitize=address.*")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address"
CACHE STRING "" FORCE)
endif()
else()
string(REPLACE
"-fsanitize=address" "" FLAGS_NO_SANITIZE "${CMAKE_CXX_FLAGS_DEBUG}")
Expand All @@ -197,10 +199,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Cannont use -fsanitize=address and -fsanitize=thread "
"at the same time")
else()
if (HERMES_USE_THREAD_SANITIZER AND
NOT "${CMAKE_CXX_FLAGS_DEBUG}" MATCHES ".*-fsanitize=thread.*")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread"
CACHE STRING "" FORCE)
if (HERMES_USE_THREAD_SANITIZER)
if(NOT "${CMAKE_CXX_FLAGS_DEBUG}" MATCHES ".*-fsanitize=thread.*")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread"
CACHE STRING "" FORCE)
endif()
else()
string(REPLACE
"-fsanitize=thread" "" FLAGS_NO_SANITIZE "${CMAKE_CXX_FLAGS_DEBUG}")
Expand Down Expand Up @@ -334,10 +337,6 @@ if(HERMES_HAVE_GOTCHA)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/gotcha_intercept)
endif()

if(HERMES_ENABLE_ADAPTERS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/adapter)
endif()

if(HERMES_ENABLE_WRAPPER)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/wrapper)
endif()
Expand All @@ -346,6 +345,28 @@ if(HERMES_BUILD_BUFFER_POOL_VISUALIZER AND SDL2_FOUND)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/buffer_pool_visualizer)
endif()

#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
include(CTest)
if(CMAKE_PROJECT_NAME STREQUAL HERMES AND BUILD_TESTING)
find_package(Catch2 REQUIRED)
find_program(IOR_EXE ior)
if(IOR_EXE)
message(STATUS "Found ior at ${IOR_EXE}")
set(HERMES_HAVE_IOR "YES")
else()
message(WARNING "Couldn't find the 'ior' executable. Some tests will be skipped.")
set(HERMES_HAVE_IOR "NO")
endif()
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
endif()

if(HERMES_ENABLE_ADAPTERS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/adapter)
endif()

#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------
Expand All @@ -365,27 +386,6 @@ if(HERMES_ENABLE_DOXYGEN)
)
endif()

#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
if(CMAKE_PROJECT_NAME STREQUAL HERMES)
include(CTest)
endif()

if(CMAKE_PROJECT_NAME STREQUAL HERMES AND BUILD_TESTING)
find_package(Catch2 REQUIRED)
find_program(IOR_EXE ior)
if(IOR_EXE)
message(STATUS "Found ior at ${IOR_EXE}")
set(HERMES_HAVE_IOR "YES")
else()
message(WARNING "Couldn't find the 'ior' executable. Some tests will be skipped.")
set(HERMES_HAVE_IOR "NO")
endif()
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
endif()

#-----------------------------------------------------------------------------
# Benchmarks
#-----------------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ set(HERMES_ADAPTER_DIR ${CMAKE_SOURCE_DIR}/adapter)
add_subdirectory(stdio)
add_subdirectory(posix)
add_subdirectory(mpiio)
add_subdirectory(pubsub)

if(HERMES_ENABLE_VFD)
if(HERMES_ENABLE_WRAPPER)
add_subdirectory(vfd)
else()
message(FATAL_ERROR "The Hermes VFD requires HERMES_ENABLE_WRAPPER=ON")
endif()
endif()

if(BUILD_TESTING)
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
endif()
endif()
2 changes: 1 addition & 1 deletion adapter/mpiio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(MPIIOAdapter VERSION 0.1.0)
project(MPIIOAdapter VERSION 0.3.0)

# MPIIO src code. We only include mpiio.cc as it includes other cc to reduce compilation time.
set(MPIIO_ADAPTER_SRC mpiio.cc)
Expand Down
2 changes: 1 addition & 1 deletion adapter/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(PosixAdapter VERSION 0.1.0)
project(PosixAdapter VERSION 0.3.0)

# POSIX src code. We only include posix.cc as it includes other cc to reduce compilation time.
set(POSIX_ADAPTER_SRC posix.cc)
Expand Down
34 changes: 34 additions & 0 deletions adapter/pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
project(PubSubAdapter VERSION 0.3.0)

set(HERMES_PUBSUB_ADAPTER_DIR ${HERMES_ADAPTER_DIR}/pubsub)

set(PUBSUB_ADAPTER_PUBLIC_HEADER pubsub.h)
set(PUBSUB_ADAPTER_PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/metadata_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/datastructures.h
${HERMES_ADAPTER_DIR}/constants.h
${HERMES_ADAPTER_DIR}/singleton.h)
set(PUBSUB_ADAPTER_SRC pubsub.cc metadata_manager.cc)

add_library(hermes_pubsub SHARED ${PUBSUB_ADAPTER_PRIVATE_HEADER} ${PUBSUB_ADAPTER_PUBLIC_HEADER} ${PUBSUB_ADAPTER_SRC})
target_include_directories(hermes_pubsub PRIVATE ${HERMES_ADAPTER_DIR})
add_dependencies(hermes_pubsub hermes)
target_link_libraries(hermes_pubsub hermes MPI::MPI_CXX)

#-----------------------------------------------------------------------------
# Add Target(s) to CMake Install
#-----------------------------------------------------------------------------
install(
TARGETS
hermes_pubsub
EXPORT
${HERMES_EXPORTED_TARGETS}
LIBRARY DESTINATION ${HERMES_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${HERMES_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${HERMES_INSTALL_BIN_DIR}
)
#-----------------------------------------------------------------------------
# Add Target(s) to Coverage
#-----------------------------------------------------------------------------
if(HERMES_ENABLE_COVERAGE)
set_coverage_flags(hermes_pubsub)
endif()
60 changes: 60 additions & 0 deletions adapter/pubsub/datastructures.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Distributed under BSD 3-Clause license. *
* Copyright by The HDF Group. *
* Copyright by the Illinois Institute of Technology. *
* All rights reserved. *
* *
* This file is part of Hermes. The full Hermes copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the top directory. If you do not *
* have access to the file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef HERMES_PUBSUB_ADAPTER_DATASTRUCTURES_H
#define HERMES_PUBSUB_ADAPTER_DATASTRUCTURES_H

/**
* Standard header
*/
#include <string>

/**
* Internal header
*/
#include <bucket.h>
#include <buffer_pool.h>
#include <hermes_types.h>

/**
* Namespace simplification.
*/
namespace hapi = hermes::api;

namespace hermes::adapter::pubsub {

/**
* Struct that defines the metadata required for the pubsub adapter.
*/
struct ClientMetadata {
/**
* attributes
*/
std::shared_ptr<hapi::Bucket> st_bkid; /* bucket associated with the topic */
u64 last_subscribed_blob; /* Current blob being used */
timespec st_atim; /* time of last access */
/**
* Constructor
*/
ClientMetadata()
: st_bkid(),
last_subscribed_blob(0),
st_atim() {} /* default constructor */
explicit ClientMetadata(const struct ClientMetadata &st)
: st_bkid(st.st_bkid),
last_subscribed_blob(st.last_subscribed_blob),
st_atim(st.st_atim) {} /* parameterized constructor */
};

} // namespace hermes::adapter::pubsub

#endif // HERMES_PUBSUB_ADAPTER_DATASTRUCTURES_H
60 changes: 60 additions & 0 deletions adapter/pubsub/metadata_manager.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Distributed under BSD 3-Clause license. *
* Copyright by The HDF Group. *
* Copyright by the Illinois Institute of Technology. *
* All rights reserved. *
* *
* This file is part of Hermes. The full Hermes copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the top directory. If you do not *
* have access to the file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include "metadata_manager.h"

/**
* Namespace declarations for cleaner code.
*/
using hermes::adapter::pubsub::MetadataManager;
using hermes::adapter::pubsub::MetadataManager;

bool MetadataManager::Create(const std::string& topic,
const ClientMetadata&stat) {
LOG(INFO) << "Create metadata for topic: " << topic << std::endl;
auto ret = metadata.emplace(topic, stat);
return ret.second;
}

bool MetadataManager::Update(const std::string& topic,
const ClientMetadata&stat) {
LOG(INFO) << "Update metadata for topic: " << topic << std::endl;
auto iter = metadata.find(topic);
if (iter != metadata.end()) {
metadata.erase(iter);
auto ret = metadata.emplace(topic, stat);
return ret.second;
} else {
return false;
}
}

std::pair<ClientMetadata, bool> MetadataManager::Find(
const std::string& topic) {
typedef std::pair<ClientMetadata, bool> MetadataReturn;
auto iter = metadata.find(topic);
if (iter == metadata.end())
return MetadataReturn(ClientMetadata(), false);
else
return MetadataReturn(iter->second, true);
}

bool MetadataManager::Delete(const std::string& topic) {
LOG(INFO) << "Delete metadata for topic: " << topic << std::endl;
auto iter = metadata.find(topic);
if (iter != metadata.end()) {
metadata.erase(iter);
return true;
} else {
return false;
}
}
Loading

0 comments on commit f3c423a

Please sign in to comment.