forked from daphne-eu/daphne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DAPHNE-daphne-eu#830] Fix duplicate symbol linker issue
Compiling with Clang/LLD complains about duplicate symbols of supportsUnaryOp and supportsBinaryOp. The definition of supportsBinaryOp would need to be declared static if left i the BinaryOpCode.h header which is included in several places. Since this definition is not allowed and there is only one use, it is moved to its own file.
- Loading branch information
1 parent
8d614f0
commit ffa28b8
Showing
7 changed files
with
206 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright 2024 The DAPHNE Consortium | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <runtime/local/kernels/BinaryOpCode.h> | ||
|
||
namespace { | ||
// **************************************************************************** | ||
// Specification which binary ops should be supported on which value types | ||
// **************************************************************************** | ||
|
||
/** | ||
* @brief Template constant specifying if the given binary operation | ||
* should be supported on arguments of the given value types. | ||
* | ||
* @tparam VTRes The result value type. | ||
* @tparam VTLhs The left-hand-side argument value type. | ||
* @tparam VTRhs The right-hand-side argument value type. | ||
* @tparam op The binary operation. | ||
*/ | ||
template <BinaryOpCode op, typename VTRes, typename VTLhs, typename VTRhs> constexpr bool supportsBinaryOp = false; | ||
|
||
// Macros for concisely specifying which binary operations should be | ||
// supported on which value types. | ||
|
||
// Generates code specifying that the binary operation `Op` should be supported | ||
// on the value type `VT` (for the result and the two arguments, for | ||
// simplicity). | ||
#define SUPPORT(Op, VT) template <> constexpr bool supportsBinaryOp<BinaryOpCode::Op, VT, VT, VT> = true; | ||
|
||
// Generates code specifying that all binary operations of a certain category | ||
// should be supported on the given value type `VT` (for the result and the two | ||
// arguments, for simplicity). | ||
#define SUPPORT_ARITHMETIC(VT) \ | ||
/* Arithmetic. */ \ | ||
SUPPORT(ADD, VT) \ | ||
SUPPORT(SUB, VT) \ | ||
SUPPORT(MUL, VT) \ | ||
SUPPORT(DIV, VT) \ | ||
SUPPORT(POW, VT) \ | ||
SUPPORT(MOD, VT) \ | ||
SUPPORT(LOG, VT) | ||
#define SUPPORT_EQUALITY(VT) \ | ||
/* Comparisons. */ \ | ||
SUPPORT(EQ, VT) \ | ||
SUPPORT(NEQ, VT) | ||
#define SUPPORT_COMPARISONS(VT) \ | ||
/* Comparisons. */ \ | ||
SUPPORT(LT, VT) \ | ||
SUPPORT(LE, VT) \ | ||
SUPPORT(GT, VT) \ | ||
SUPPORT(GE, VT) \ | ||
/* Min/max. */ \ | ||
SUPPORT(MIN, VT) \ | ||
SUPPORT(MAX, VT) | ||
#define SUPPORT_LOGICAL(VT) \ | ||
/* Logical. */ \ | ||
SUPPORT(AND, VT) \ | ||
SUPPORT(OR, VT) | ||
#define SUPPORT_BITWISE(VT) \ | ||
/* Bitwise. */ \ | ||
SUPPORT(BITWISE_AND, VT) | ||
|
||
// Generates code specifying that all binary operations typically supported on a | ||
// certain category of value types should be supported on the given value type | ||
// `VT` (for the result and the two arguments, for simplicity). | ||
#define SUPPORT_NUMERIC_FP(VT) \ | ||
SUPPORT_ARITHMETIC(VT) \ | ||
SUPPORT_EQUALITY(VT) \ | ||
SUPPORT_COMPARISONS(VT) \ | ||
SUPPORT_LOGICAL(VT) | ||
#define SUPPORT_NUMERIC_INT(VT) \ | ||
SUPPORT_ARITHMETIC(VT) \ | ||
SUPPORT_EQUALITY(VT) \ | ||
SUPPORT_COMPARISONS(VT) \ | ||
SUPPORT_LOGICAL(VT) \ | ||
SUPPORT_BITWISE(VT) | ||
|
||
// Concise specification of which binary operations should be supported on | ||
// which value types. | ||
SUPPORT_NUMERIC_FP(double) | ||
SUPPORT_NUMERIC_FP(float) | ||
SUPPORT_NUMERIC_INT(int64_t) | ||
SUPPORT_NUMERIC_INT(int32_t) | ||
SUPPORT_NUMERIC_INT(int8_t) | ||
SUPPORT_NUMERIC_INT(uint64_t) | ||
SUPPORT_NUMERIC_INT(uint32_t) | ||
SUPPORT_NUMERIC_INT(uint8_t) | ||
template <> constexpr bool supportsBinaryOp<BinaryOpCode::CONCAT, const char *, const char *, const char *> = true; | ||
template <> constexpr bool supportsBinaryOp<BinaryOpCode::EQ, int64_t, const char *, const char *> = true; | ||
|
||
// Undefine helper macros. | ||
#undef SUPPORT | ||
#undef SUPPORT_ARITHMETIC | ||
#undef SUPPORT_EQUALITY | ||
#undef SUPPORT_COMPARISONS | ||
#undef SUPPORT_LOGICAL | ||
#undef SUPPORT_BITWISE | ||
#undef SUPPORT_NUMERIC_FP | ||
#undef SUPPORT_NUMERIC_INT | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright 2024 The DAPHNE Consortium | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <runtime/local/kernels/UnaryOpCode.h> | ||
|
||
#include <cstdint> | ||
|
||
// **************************************************************************** | ||
// Specification which unary ops should be supported on which value types | ||
// **************************************************************************** | ||
namespace { | ||
/** | ||
* @brief Template constant specifying if the given unary operation | ||
* should be supported on arguments of the given value type. | ||
* | ||
* @tparam op The unary operation. | ||
* @tparam VTRes The result value type. | ||
* @tparam VTArg The argument value type. | ||
*/ | ||
template <UnaryOpCode op, typename VTRes, typename VTArg> constexpr bool supportsUnaryOp = false; | ||
|
||
// Macros for concisely specifying which unary operations should be | ||
// supported on which value types. | ||
|
||
// Generates code specifying that the unary operation `Op` should be supported | ||
// on the value type `VT` (for both the result and the argument, for | ||
// simplicity). | ||
#define SUPPORT(Op, VT) template <> constexpr bool supportsUnaryOp<UnaryOpCode::Op, VT, VT> = true; | ||
|
||
// Generates code specifying that all unary operations typically supported on | ||
// numeric value types should be supported on the given value type `VT` | ||
// (for both the result and the argument, for simplicity). | ||
#define SUPPORT_NUMERIC(VT) \ | ||
/* Arithmetic/general math. */ \ | ||
SUPPORT(MINUS, VT) \ | ||
SUPPORT(ABS, VT) \ | ||
SUPPORT(SIGN, VT) \ | ||
SUPPORT(SQRT, VT) \ | ||
SUPPORT(EXP, VT) \ | ||
SUPPORT(LN, VT) \ | ||
/* Trigonometric/hyperbolic. */ \ | ||
SUPPORT(SIN, VT) \ | ||
SUPPORT(COS, VT) \ | ||
SUPPORT(TAN, VT) \ | ||
SUPPORT(ASIN, VT) \ | ||
SUPPORT(ACOS, VT) \ | ||
SUPPORT(ATAN, VT) \ | ||
SUPPORT(SINH, VT) \ | ||
SUPPORT(COSH, VT) \ | ||
SUPPORT(TANH, VT) \ | ||
/* Rounding. */ \ | ||
SUPPORT(FLOOR, VT) \ | ||
SUPPORT(CEIL, VT) \ | ||
SUPPORT(ROUND, VT) \ | ||
/* Comparison */ \ | ||
SUPPORT(ISNAN, VT) | ||
|
||
// Concise specification of which unary operations should be supported on | ||
// which value types. | ||
SUPPORT_NUMERIC(double) | ||
SUPPORT_NUMERIC(float) | ||
SUPPORT_NUMERIC(int64_t) | ||
SUPPORT_NUMERIC(int32_t) | ||
SUPPORT_NUMERIC(int8_t) | ||
SUPPORT_NUMERIC(uint64_t) | ||
SUPPORT_NUMERIC(uint32_t) | ||
SUPPORT_NUMERIC(uint8_t) | ||
|
||
// Undefine helper macros. | ||
#undef SUPPORT | ||
#undef SUPPORT_NUMERIC | ||
} |
Oops, something went wrong.