Skip to content

Commit 3acb5f4

Browse files
authored
update ipu related cmake (PaddlePaddle#406)
* update ipu related cmake * up0
1 parent 5ce1712 commit 3acb5f4

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

paddle/fluid/operators/jit/CMakeLists.txt

+2-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@ if(WITH_XBYAK)
2121
add_subdirectory(gen)
2222
endif()
2323

24-
if(WITH_IPU)
25-
set(JIT_IPU_DEPS ipu_backend)
26-
elseif(WITH_IPU)
27-
set(JIT_IPU_DEPS "")
28-
endif()
29-
30-
cc_library(jit_kernel_helper INTERFACE SRCS ${jit_kernel_cc_srcs} DEPS jit_kernel_base ${JIT_KERNEL_DEPS} ${JIT_IPU_DEPS})
31-
cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel_helper ${JIT_IPU_DEPS})
24+
cc_library(jit_kernel_helper INTERFACE SRCS ${jit_kernel_cc_srcs} DEPS jit_kernel_base ${JIT_KERNEL_DEPS})
25+
cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel_helper)
3226
if(NOT WIN32)
3327
cc_binary(jit_kernel_benchmark SRCS benchmark.cc DEPS jit_kernel_helper device_tracer tensor)
3428
endif()

paddle/fluid/platform/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ IF(WITH_GPU OR WITH_ROCM)
7575
ENDIF()
7676

7777
IF(WITH_IPU)
78-
set(IPU_CTX_DEPS ipu_backend)
78+
set(IPU_CTX_DEPS ipu_info)
7979
ELSE()
8080
set(IPU_CTX_DEPS)
8181
ENDIF(WITH_IPU)
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
IF(WITH_IPU)
22
FILE(GLOB POPART_CANONICALIZATION_SRC ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/device/ipu/popart_canonicalization/*.cc)
33
list(APPEND PADDLE_IPU_SRC ${POPART_CANONICALIZATION_SRC})
4-
set(PADDLE_IPU_LIB "${CMAKE_CURRENT_BINARY_DIR}/libpaddle_ipu.so" CACHE STRING "")
5-
set(PADDLE_IPU_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
64
set(IPU_BACKEND_SRC
7-
"ipu_device.cc"
85
"ipu_strategy.cc"
96
"ipu_executor.cc"
107
"ipu_compiler.cc"
118
"ipu_backend.cc"
129
"ipu_utils.cc"
1310
)
11+
set(IPU_INFO_SRC
12+
"ipu_info.cc"
13+
"ipu_device.cc"
14+
)
1415

15-
cc_library(ipu_backend SRCS ${IPU_BACKEND_SRC} DEPS popart graph framework_proto enforce graph_helper timer)
16-
cc_library(ipu_info SRCS ipu_info.cc DEPS ipu_backend)
17-
cc_library(paddle_ipu SHARED SRCS ${PADDLE_IPU_SRC} DEPS popart)
16+
cc_library(ipu_backend SRCS ${IPU_BACKEND_SRC} DEPS popart graph graph_helper)
17+
cc_library(ipu_info SRCS ${IPU_INFO_SRC} DEPS popart enforce)
18+
cc_library(paddle_ipu SHARED SRCS ${PADDLE_IPU_SRC} DEPS popart graph_helper)
1819
add_dependencies(paddle_ipu ipu_backend)
20+
set(PADDLE_IPU_LIB "${CMAKE_CURRENT_BINARY_DIR}/libpaddle_ipu.so" CACHE STRING "")
21+
set(PADDLE_IPU_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
1922
ENDIF()

paddle/fluid/platform/device/ipu/ipu_device.cc

+15-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#include "paddle/fluid/platform/device/ipu/ipu_device.h"
16-
#include "paddle/fluid/platform/device/ipu/ipu_utils.h"
16+
#include "paddle/fluid/platform/enforce.h"
1717

1818
namespace paddle {
1919
namespace platform {
2020
namespace ipu {
2121

22+
// TODO(alleng) merge with ipu_utils
23+
static bool GetBoolEnv(std::string str) {
24+
char* str_val = getenv(str.c_str());
25+
if (str_val == NULL) {
26+
return false;
27+
} else {
28+
bool val = false;
29+
if (strcmp(str_val, "1") == 0 || strcmp(str_val, "true") == 0 ||
30+
strcmp(str_val, "True") == 0 || strcmp(str_val, "TRUE") == 0)
31+
val = true;
32+
return val;
33+
}
34+
}
35+
2236
int GetNumDevices() {
2337
bool ipu_model = GetBoolEnv("POPLAR_IPUMODEL");
2438
if (ipu_model) {

paddle/fluid/platform/device/ipu/ipu_device.h

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License. */
1515
#pragma once
1616

1717
#include <popart/devicemanager.hpp>
18-
#include "paddle/fluid/platform/enforce.h"
1918

2019
namespace paddle {
2120
namespace platform {

paddle/fluid/platform/device/ipu/ipu_info.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ namespace paddle {
1616
namespace platform {
1717

1818
//! Get a list of device ids from environment variable or use all.
19-
std::vector<int> GetSelectedIPUDevices() {
20-
return platform::ipu::GetDeviceIds();
21-
}
19+
std::vector<int> GetSelectedIPUDevices() { return ipu::GetDeviceIds(); }
2220

2321
//! Get the total number of IPU devices in system.
24-
int GetIPUDeviceCount() { return platform::ipu::GetNumDevices(); }
22+
int GetIPUDeviceCount() { return ipu::GetNumDevices(); }
2523

2624
} // namespace platform
2725
} // namespace paddle

python/paddle/fluid/tests/unittests/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -806,10 +806,6 @@ if (WITH_MKLDNN)
806806
add_subdirectory(mkldnn)
807807
endif()
808808

809-
if (WITH_IPU)
810-
add_subdirectory(ipu)
811-
endif()
812-
813809
if (WITH_MLU)
814810
add_subdirectory(mlu)
815811
endif()

0 commit comments

Comments
 (0)