Skip to content

Commit

Permalink
fix(FAM): OpenCUBE related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mcakircali committed Nov 6, 2024
1 parent 4ffb14a commit 9918477
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 15 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ endif()

ecbuild_add_option( FEATURE OPENFAM
DEFAULT OFF
REQUIRED_PACKAGES "LibUUID REQUIRED" "protobuf REQUIRED" "gRPC REQUIRED" "OpenFAM REQUIRED"
REQUIRED_PACKAGES "LibUUID REQUIRED" "OpenFAM REQUIRED"
DESCRIPTION "Enables OpenFAM support" )

if( eckit_HAVE_OPENFAM )
find_package( LibUUID REQUIRED )
find_package( protobuf CONFIG REQUIRED )
find_package( gRPC CONFIG REQUIRED )
find_package( OpenFAM 3.0.1 CONFIG REQUIRED )
find_package( OpenFAM REQUIRED )
endif()

### RADOS
Expand Down
109 changes: 109 additions & 0 deletions cmake/FindOpenFAM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright 2024- European Centre for Medium-Range Weather Forecasts (ECMWF)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.
#
# Requires:
# FindPackageHandleStandardArgs (CMake standard module)
#

#[=======================================================================[.rst:
FindLibOpenFAM
--------
This module finds the openfam library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``LibOpenFAM``
The openfam library
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``OpenFAM_FOUND``
True if the openfam library is found.
``OpenFAM_INCLUDE_DIRS``
Include directories needed to use openfam.
``OpenFAM_LIBRARIES``
Libraries needed to link to openfam.
Cache variables
^^^^^^^^^^^^^^^
The following cache variables may also be set to help find openfam library:
``OpenFAM_INCLUDE_DIR``
where to find the openfam headers.
``OpenFAM_LIBRARY``
where to find the openfam library.
Hints
^^^^^
The environment variables ``OpenFAM_ROOT``, ``OpenFAM_DIR``, and ``OpenFAM_PATH``
may also be set to help find openfam library.
#]=======================================================================]

find_path(OpenFAM_INCLUDE_DIR fam/fam.h
HINTS
${OpenFAM_ROOT}
${OpenFAM_DIR}
${OpenFAM_PATH}
ENV OpenFAM_ROOT
ENV OpenFAM_DIR
ENV OpenFAM_PATH
)

find_library(OpenFAM_LIBRARY
NAMES openfam
HINTS
${OpenFAM_ROOT}
${OpenFAM_DIR}
${OpenFAM_PATH}
ENV OpenFAM_ROOT
ENV OpenFAM_DIR
ENV OpenFAM_PATH
PATH_SUFFIXES lib lib64
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(OpenFAM
FOUND_VAR OpenFAM_FOUND
REQUIRED_VARS
OpenFAM_LIBRARY
OpenFAM_INCLUDE_DIR)

if (OpenFAM_FOUND)
set(OpenFAM_INCLUDE_DIRS ${OpenFAM_INCLUDE_DIR}/fam)
set(OpenFAM_LIBRARIES ${OpenFAM_LIBRARY})
if(NOT TARGET OpenFAM)
add_library(OpenFAM INTERFACE IMPORTED)
set_target_properties(OpenFAM PROPERTIES
IMPORTED_LOCATION "${OpenFAM_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OpenFAM_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OpenFAM_LIBRARY}")
endif()
endif()

mark_as_advanced(OpenFAM_INCLUDE_DIR OpenFAM_LIBRARY)
2 changes: 1 addition & 1 deletion src/eckit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ ecbuild_add_library(
"${CURL_LIBRARIES}"
"${AIO_LIBRARIES}"
"${RADOS_LIBRARIES}"
$<${HAVE_OPENFAM}:OpenFAM::openfam>
$<${HAVE_OPENFAM}:OpenFAM>

PUBLIC_LIBS
${CMATH_LIBRARIES}
Expand Down
2 changes: 1 addition & 1 deletion tests/io/fam_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline auto randomNumber() -> std::string {
return std::to_string(::random());
}

const auto testEndpoint = "127.0.0.1:8880"s;
const auto testEndpoint = "10.115.3.2:8080"s;

class TestFam {
public:
Expand Down
20 changes: 11 additions & 9 deletions tests/io/test_fam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,17 @@ CASE("FamObject: lookup, create, and destroy") {

EXPECT_NO_THROW(FamRegionName(fam::testEndpoint, path).create(regionSize, regionPerm));

FamObject::UPtr object;
{
FamObject::UPtr object;

// object inherits permissions from region
EXPECT_NO_THROW(object = FamObjectName(fam::testEndpoint, path).allocate(objectSize).clone());
// object inherits permissions from region
EXPECT_NO_THROW(object = FamObjectName(fam::testEndpoint, path).allocate(objectSize).clone());

const FamProperty prop {objectSize, regionPerm, objectName};
EXPECT_EQUAL(prop, object->property());
const FamProperty objectProp {objectSize, regionPerm, objectName, 10005, 10005};
EXPECT_EQUAL(objectProp, object->property());

EXPECT_NO_THROW(object->deallocate());
EXPECT_NO_THROW(object->deallocate());
}

{
auto name = FamRegionName(fam::testEndpoint, "");
Expand All @@ -185,16 +187,16 @@ CASE("FamObject: lookup, create, and destroy") {
{
const auto size = 12;
EXPECT_NO_THROW(region.allocateObject(size, objectPerm, objectName));
EXPECT(region.lookupObject(objectName).size() == size);
EXPECT_EQUAL(region.lookupObject(objectName).size(), size);
}

// overwrite: allocate with different size
EXPECT_NO_THROW(region.allocateObject(objectSize, objectPerm, objectName, true));

auto object = region.lookupObject(objectName);

const FamProperty prop {objectSize, objectPerm, objectName};
EXPECT(object.property() == prop);
const FamProperty objectProp {objectSize, objectPerm, objectName, 10005, 10005};
EXPECT_EQUAL(objectProp, object.property());

EXPECT_NO_THROW(object.deallocate());

Expand Down

0 comments on commit 9918477

Please sign in to comment.