Skip to content

Commit 4fa3cee

Browse files
authored
Windows/hidden file (#13139)
* framework cmake * Update CMakeLists.txt
1 parent 84c540e commit 4fa3cee

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

paddle/fluid/framework/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.tensor_util.cu
2+
.data_type_transform.cu

paddle/fluid/framework/CMakeLists.txt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# windows treat symbolic file as a real file, which is different with unix
2+
# We create a hidden file and compile it instead of origin source file.
3+
function(windows_symbolic TARGET)
4+
set(oneValueArgs "")
5+
set(multiValueArgs SRCS DEPS)
6+
cmake_parse_arguments(windows_symbolic "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
7+
foreach(src ${windows_symbolic_SRCS})
8+
get_filename_component(src ${src} NAME_WE)
9+
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.cu)
10+
message(FATAL " ${src}.cc and ${src}.cu must exsits, and ${src}.cu must be symbolic file.")
11+
endif()
12+
add_custom_command(OUTPUT .${src}.cu
13+
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu
14+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${src}.cc" "${CMAKE_CURRENT_SOURCE_DIR}/.${src}.cu"
15+
COMMENT "create hidden file of ${src}.cu")
16+
add_custom_target(${TARGET} ALL DEPENDS .${src}.cu)
17+
endforeach()
18+
endfunction()
19+
120
add_subdirectory(ir)
221
if (NOT WIN32)
322
add_subdirectory(details)
@@ -11,7 +30,13 @@ nv_test(dim_test SRCS dim_test.cu DEPS ddim)
1130
cc_library(data_type SRCS data_type.cc DEPS framework_proto ddim device_context)
1231
cc_test(data_type_test SRCS data_type_test.cc DEPS data_type place tensor)
1332
if(WITH_GPU)
14-
nv_library(tensor SRCS tensor.cc tensor_util.cu DEPS place memory data_type device_context)
33+
if (WIN32)
34+
windows_symbolic(tensor_util SRCS tensor_util.cu)
35+
nv_library(tensor SRCS tensor.cc .tensor_util.cu DEPS place memory data_type device_context)
36+
add_dependencies(tensor tensor_util)
37+
else()
38+
nv_library(tensor SRCS tensor.cc tensor_util.cu DEPS place memory data_type device_context)
39+
endif(WIN32)
1540
else()
1641
cc_library(tensor SRCS tensor.cc tensor_util.cc DEPS place memory data_type device_context)
1742
endif()
@@ -55,7 +80,13 @@ nv_test(data_device_transform_test SRCS data_device_transform_test.cu
5580
DEPS operator op_registry device_context math_function)
5681

5782
if(WITH_GPU)
58-
nv_library(data_type_transform SRCS data_type_transform.cu DEPS tensor)
83+
if (WIN32)
84+
windows_symbolic(hidden_file SRCS data_type_transform.cu)
85+
nv_library(data_type_transform SRCS .data_type_transform.cu DEPS tensor)
86+
add_dependencies(data_type_transform hidden_file)
87+
else()
88+
nv_library(data_type_transform SRCS data_type_transform.cu DEPS tensor)
89+
endif(WIN32)
5990
nv_test(data_type_transform_test SRCS data_type_transform_test.cc data_type_transform_test.cu DEPS data_type_transform)
6091
else()
6192
cc_library(data_type_transform SRCS data_type_transform.cc DEPS tensor)

0 commit comments

Comments
 (0)