diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c86015fe44e6a96874a078e53d5c8a609b9ca70..3d7f7b60a002e23702d5d11a819641c4e0c205f5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,7 @@ option(WITH_XPU_BKCL "Compile PaddlePaddle with BAIDU KUNLUN XPU BKCL" OFF) option(WITH_CRYPTO "Compile PaddlePaddle with crypto support" ON) option(WITH_ARM "Compile PaddlePaddle with arm support" OFF) option(WITH_SW "Compile PaddlePaddle with sw support" OFF) +option(WITH_MIPS "Compile PaddlePaddle with mips support" OFF) option(WITH_MUSL "Compile with musl libc instead of gblic" OFF) option(WITH_UNITY_BUILD "Compile with UnityBuild mode" OFF) @@ -307,6 +308,11 @@ if (WITH_SW) add_definitions(-DPADDLE_WITH_SW) endif() +if (WITH_MIPS) + set(WITH_XBYAK OFF CACHE STRING "Disable XBYAK when compiling WITH_MIPS=ON" FORCE) + add_definitions(-DPADDLE_WITH_MIPS) +endif() + set(PADDLE_PYTHON_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/python/build") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") diff --git a/cmake/external/openblas.cmake b/cmake/external/openblas.cmake index afe498cb5c99add8c4f53e26293eaf46a49aaef4..19ba6d15c59ea802cc94ea6138871c15cb49077b 100644 --- a/cmake/external/openblas.cmake +++ b/cmake/external/openblas.cmake @@ -19,6 +19,9 @@ SET(CBLAS_SOURCE_DIR ${THIRD_PARTY_PATH}/openblas/src/extern_openblas) SET(CBLAS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/openblas) SET(CBLAS_REPOSITORY ${GIT_URL}/xianyi/OpenBLAS.git) SET(CBLAS_TAG v0.3.7) +if(WITH_MIPS) + SET(CBLAS_TAG v0.3.13) +endif() cache_third_party(extern_openblas REPOSITORY ${CBLAS_REPOSITORY} diff --git a/cmake/flags.cmake b/cmake/flags.cmake index bd4962908d7cda16419f3b974eac3de96c64af81..4e3dcac5326a45378bbeef393e823c1e2f9e0bd3 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -183,7 +183,7 @@ set(GPU_COMMON_FLAGS -Wno-error=unused-function # Warnings in Numpy Header. -Wno-error=array-bounds # Warnings in Eigen::array ) -if (NOT WITH_NV_JETSON AND NOT WITH_ARM AND NOT WITH_SW) +if (NOT WITH_NV_JETSON AND NOT WITH_ARM AND NOT WITH_SW AND NOT WITH_MIPS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") endif() endif(NOT WIN32) diff --git a/paddle/fluid/operators/search_compute.h b/paddle/fluid/operators/search_compute.h index df302310517413e5bdacff66eab6e663eeb292bf..d0618bf2c302b2627dc9dc1fc1034e8420c7148b 100644 --- a/paddle/fluid/operators/search_compute.h +++ b/paddle/fluid/operators/search_compute.h @@ -14,7 +14,8 @@ limitations under the License. */ #pragma once -#if !defined(PADDLE_WITH_ARM) && !defined(PADDLE_WITH_SW) +#if !defined(PADDLE_WITH_ARM) && !defined(PADDLE_WITH_SW) && \ + !defined(PADDLE_WITH_MIPS) #include #endif #include @@ -74,7 +75,8 @@ void call_gemm_batched(const framework::ExecutionContext& ctx, } } -#if !defined(PADDLE_WITH_ARM) && !defined(PADDLE_WITH_SW) +#if !defined(PADDLE_WITH_ARM) && !defined(PADDLE_WITH_SW) && \ + !defined(PADDLE_WITH_MIPS) #define __m256x __m256 @@ -114,7 +116,8 @@ inline void axpy(const T* x, T* y, size_t len, const T alpha) { _mm256_add_px(_mm256_load_px(y + jjj), _mm256_mul_px(mm_alpha, _mm256_load_px(x + jjj)))); } -#elif defined(PADDLE_WITH_ARM) || defined(PADDLE_WITH_SW) +#elif defined(PADDLE_WITH_ARM) || defined(PADDLE_WITH_SW) || \ + defined(PADDLE_WITH_MIPS) PADDLE_THROW(platform::errors::Unimplemented("axpy is not supported")); #else lll = len & ~SSE_CUT_LEN_MASK; @@ -143,7 +146,8 @@ inline void axpy_noadd(const T* x, T* y, size_t len, const T alpha) { for (jjj = 0; jjj < lll; jjj += AVX_STEP_SIZE) { _mm256_store_px(y + jjj, _mm256_mul_px(mm_alpha, _mm256_load_px(x + jjj))); } -#elif defined(PADDLE_WITH_ARM) || defined(PADDLE_WITH_SW) +#elif defined(PADDLE_WITH_ARM) || defined(PADDLE_WITH_SW) || \ + defined(PADDLE_WITH_MIPS) PADDLE_THROW(platform::errors::Unimplemented("axpy_noadd is not supported")); #else lll = len & ~SSE_CUT_LEN_MASK; diff --git a/paddle/fluid/platform/cpu_info.cc b/paddle/fluid/platform/cpu_info.cc index 6f25df107f6ec2dfd86a12adae4d903e407843c4..b6d42f1c790649bc9105ff7004dbcc2a109ec8d0 100644 --- a/paddle/fluid/platform/cpu_info.cc +++ b/paddle/fluid/platform/cpu_info.cc @@ -141,7 +141,7 @@ bool MayIUse(const cpu_isa_t cpu_isa) { return true; } else { #if !defined(WITH_NV_JETSON) && !defined(PADDLE_WITH_ARM) && \ - !defined(PADDLE_WITH_SW) + !defined(PADDLE_WITH_SW) && !defined(PADDLE_WITH_MIPS) int reg[4]; cpuid(reg, 0); int nIds = reg[0]; diff --git a/paddle/fluid/platform/cpu_info.h b/paddle/fluid/platform/cpu_info.h index 10870b2b728a4275e0f378b2e12ee1caa9f46140..3c74e6fb2acb0a15cb2e034f1bcb2871578eae01 100644 --- a/paddle/fluid/platform/cpu_info.h +++ b/paddle/fluid/platform/cpu_info.h @@ -41,7 +41,7 @@ limitations under the License. */ #define cpuid(reg, x) __cpuidex(reg, x, 0) #else #if !defined(WITH_NV_JETSON) && !defined(PADDLE_WITH_ARM) && \ - !defined(PADDLE_WITH_SW) + !defined(PADDLE_WITH_SW) && !defined(PADDLE_WITH_MIPS) #include inline void cpuid(int reg[4], int x) { __cpuid_count(x, 0, reg[0], reg[1], reg[2], reg[3]); diff --git a/python/setup.py.in b/python/setup.py.in index 63a8ca895614201859a58e0d7f1b3a239fce91b7..c732a8921670e6e9f8e66f0ce4a567603ab010c5 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -348,7 +348,7 @@ if '${CMAKE_BUILD_TYPE}' == 'Release': # The dynamic library compiled under aarch64 is greater than 64M, # and an oversize error will be reported when using patchelf. # The sw_64 not suppot patchelf, so we just disable that. - if platform.machine() != 'aarch64' and platform.machine() != 'sw_64': + if platform.machine() != 'aarch64' and platform.machine() != 'sw_64' and platform.machine() != 'mips64': if os.system(command) != 0: raise Exception("patch ${FLUID_CORE_NAME}.%s failed, command: %s" % (ext_name, command))