Skip to content

Commit

Permalink
compat to low glibc
Browse files Browse the repository at this point in the history
  • Loading branch information
donghufeng committed Feb 8, 2024
1 parent 13e6af5 commit 74deb8c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions ccsrc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
set(MQ_BASE_HEADERS
config/popcnt.h
config/config.h
config/libc_compat.h
config/type_traits.h
core/sparse/algo.h
core/sparse/csrhdmatrix.h
Expand Down
25 changes: 25 additions & 0 deletions ccsrc/include/config/libc_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
*
* 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.
*/
#ifndef MQ_CONFIG_LIBC_COMPAT_H_
#define MQ_CONFIG_LIBC_COMPAT_H_
#ifdef __linux__
extern "C" {
double __exp_finite(double x);
float __expf_finite(float x);
double __pow_finite(double x, double y);
}
#endif
#endif
1 change: 1 addition & 0 deletions ccsrc/lib/math/tensor/ops/advance_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdexcept>
#include <vector>

#include "config/libc_compat.h"
#include "math/tensor/ops_cpu/advance_math.h"
#include "math/tensor/tensor.h"
#include "math/tensor/traits.h"
Expand Down
2 changes: 1 addition & 1 deletion ccsrc/lib/mq_base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

target_sources(
mq_base PRIVATE ${CMAKE_CURRENT_LIST_DIR}/utils.cc $<$<BOOL:${ENABLE_LOGGING}>:${CMAKE_CURRENT_LIST_DIR}/logging.cpp>
${CMAKE_CURRENT_LIST_DIR}/gates/gates.cpp)
${CMAKE_CURRENT_LIST_DIR}/gates/gates.cpp ${CMAKE_CURRENT_LIST_DIR}/libc_compat.cpp)

if(ENABLE_CUDA)
target_compile_definitions(mq_base PUBLIC GPUACCELERATED)
Expand Down
30 changes: 30 additions & 0 deletions ccsrc/lib/mq_base/libc_compat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
*
* 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.
*/
#ifdef __linux__
# include "config/libc_compat.h"

# include <features.h>
# include <math.h>
double __exp_finite(double x) {
return exp(x);
}
float __expf_finite(float x) {
return expf(x);
}
double __pow_finite(double x, double y) {
return pow(x, y);
}
#endif

0 comments on commit 74deb8c

Please sign in to comment.