Skip to content

Commit

Permalink
Extract dummyShouldNotBeCalled function and hic namespace macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
l90lpa committed Nov 15, 2024
1 parent fc85c7e commit 317c499
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
2 changes: 2 additions & 0 deletions hic/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ecbuild_add_library( TARGET hic
install( FILES ${PROJECT_BINARY_DIR}/src/hic/hic_config.h DESTINATION include/hic )
install( FILES hic/hic.h DESTINATION include/hic )
install( FILES hic/hic_runtime.h DESTINATION include/hic )
install( FILES hic/hic_namespace_macro.h DESTINATION include/hic )
install( FILES hic/hic_dummy/dummyShouldNotBeCalled.h DESTINATION include/hic/hic_dummy )
install( FILES hic/hic_dummy/hic_dummy_runtime.h DESTINATION include/hic/hic_dummy )

if( HAVE_CUDA )
Expand Down
21 changes: 21 additions & 0 deletions hic/src/hic/hic_dummy/dummyShouldNotBeCalled.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* (C) Copyright 2024- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* 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.
*/
#pragma once

#include <stdexcept>
#include <string>

namespace {

[[noreturn]] void dummyShouldNotBeCalled(const char* symbol) {
throw std::runtime_error(std::string(symbol)+" is using the dummy backend and should not be called");
}

}
7 changes: 1 addition & 6 deletions hic/src/hic/hic_dummy/hic_dummy_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
* nor does it submit to any jurisdiction.
*/

#include <stdexcept>
#include <string>
#include "hic/hic_dummy/dummyShouldNotBeCalled.h"

#define DUMMY_SHOULD_NOT_BE_CALLED(SYMBOL) dummyShouldNotBeCalled( #SYMBOL )
#define DUMMY_FUNCTION(SYMBOL) \
Expand All @@ -23,10 +22,6 @@

namespace {

[[noreturn]] void dummyShouldNotBeCalled(const char* symbol) {
throw std::runtime_error(std::string(symbol)+" is using the dummy backend and should not be called");
}

using dummyError_t = int;
using dummyEvent_t = void*;
using dummyStream_t = void*;
Expand Down
19 changes: 19 additions & 0 deletions hic/src/hic/hic_namespace_macro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* (C) Copyright 2024- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* 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.
*/
#pragma once

#if !defined(HIC_NAMESPACE)
#define HIC_NAMESPACE
#define HIC_NAMESPACE_BEGIN
#define HIC_NAMESPACE_END
#else
#define HIC_NAMESPACE_BEGIN namespace HIC_NAMESPACE {
#define HIC_NAMESPACE_END }
#endif
9 changes: 1 addition & 8 deletions hic/src/hic/hic_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@
*/
#pragma once

#if !defined(HIC_NAMESPACE)
#define HIC_NAMESPACE
#define HIC_NAMESPACE_BEGIN
#define HIC_NAMESPACE_END
#else
#define HIC_NAMESPACE_BEGIN namespace HIC_NAMESPACE {
#define HIC_NAMESPACE_END }
#endif
#include "hic/hic_namespace_macro.h"

#if HIC_BACKEND_CUDA
#define HIC_BACKEND cuda
Expand Down

0 comments on commit 317c499

Please sign in to comment.