Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
70c31c07
Commit
70c31c07
authored
Dec 07, 2016
by
Guolin Ke
Browse files
simplify cmake
parent
2cd024e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
52 deletions
+82
-52
CMakeLists.txt
CMakeLists.txt
+75
-8
include/LightGBM/utils/text_reader.h
include/LightGBM/utils/text_reader.h
+2
-2
src/CMakeLists.txt
src/CMakeLists.txt
+0
-39
windows/LightGBM.vcxproj
windows/LightGBM.vcxproj
+5
-3
No files found.
CMakeLists.txt
View file @
70c31c07
...
@@ -5,23 +5,90 @@ PROJECT(lightgbm)
...
@@ -5,23 +5,90 @@ PROJECT(lightgbm)
OPTION
(
USE_MPI
"MPI based parallel learning"
OFF
)
OPTION
(
USE_MPI
"MPI based parallel learning"
OFF
)
if
(
USE_MPI
)
if
(
USE_MPI
)
find_package
(
MPI REQUIRED
)
find_package
(
MPI REQUIRED
)
ADD_DEFINITIONS
(
-DUSE_MPI
)
ADD_DEFINITIONS
(
-DUSE_MPI
)
MESSAGE
(
${
MPI_LIBRARIES
}
)
MESSAGE
(
${
MPI_LIBRARIES
}
)
MESSAGE
(
${
MPI_CXX_LIBRARIES
}
)
MESSAGE
(
${
MPI_CXX_LIBRARIES
}
)
else
()
else
()
ADD_DEFINITIONS
(
-DUSE_SOCKET
)
ADD_DEFINITIONS
(
-DUSE_SOCKET
)
endif
()
endif
()
find_package
(
OpenMP
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
OpenMP_CXX_FLAGS
}
"
)
if
(
UNIX
)
if
(
UNIX
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -fopenmp -pthread -O2 -std=c++11"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-pthread -O3 -Wall -std=c++11"
)
endif
()
if
(
MSVC
)
if
(
MSVC_VERSION LESS 1800
)
message
(
STATUS
"The compiler
${
CMAKE_CXX_COMPILER
}
has no C++11 support. Please use a newer msvc."
)
endif
()
SET
(
variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
foreach
(
variable
${
variables
}
)
if
(
${
variable
}
MATCHES
"/MD"
)
string
(
REGEX REPLACE
"/MD"
"/MT"
${
variable
}
"
${${
variable
}}
"
)
endif
()
endforeach
()
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/W4 /O2 /Ob2 /Oi /Ot /Oy /GL"
)
else
()
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fPIC"
)
endif
()
endif
()
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -fopenmp -O2 -std=c++11"
)
SET
(
LightGBM_HEADER_DIR
${
PROJECT_SOURCE_DIR
}
/include
)
SET
(
LightGBM_HEADER_DIR
${
PROJECT_SOURCE_DIR
}
/include
)
SET
(
EXECUTABLE_OUTPUT_PATH
${
PROJECT_SOURCE_DIR
}
)
SET
(
EXECUTABLE_OUTPUT_PATH
${
PROJECT_SOURCE_DIR
}
)
SET
(
LIBRARY_OUTPUT_PATH
${
PROJECT_SOURCE_DIR
}
)
SET
(
LIBRARY_OUTPUT_PATH
${
PROJECT_SOURCE_DIR
}
)
ADD_SUBDIRECTORY
(
src
)
include_directories
(
${
LightGBM_HEADER_DIR
}
)
if
(
APPLE
)
SET
(
CMAKE_SHARED_LIBRARY_SUFFIX
".so"
)
endif
(
APPLE
)
if
(
USE_MPI
)
include_directories
(
${
MPI_CXX_INCLUDE_PATH
}
)
endif
()
file
(
GLOB SOURCES
src/application/*.cpp
src/boosting/*.cpp
src/io/*.cpp
src/metric/*.cpp
src/objective/*.cpp
src/network/*.cpp
src/treelearner/*.cpp
)
add_executable
(
lightgbm src/main.cpp
${
SOURCES
}
)
add_library
(
_lightgbm SHARED src/c_api.cpp
${
SOURCES
}
)
if
(
USE_MPI
)
TARGET_LINK_LIBRARIES
(
lightgbm
${
MPI_CXX_LIBRARIES
}
)
TARGET_LINK_LIBRARIES
(
_lightgbm
${
MPI_CXX_LIBRARIES
}
)
endif
(
USE_MPI
)
if
(
WIN32
)
TARGET_LINK_LIBRARIES
(
lightgbm Ws2_32
)
TARGET_LINK_LIBRARIES
(
_lightgbm Ws2_32
)
TARGET_LINK_LIBRARIES
(
lightgbm IPHLPAPI
)
TARGET_LINK_LIBRARIES
(
_lightgbm IPHLPAPI
)
endif
(
WIN32
)
install
(
TARGETS lightgbm _lightgbm
RUNTIME DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/bin
LIBRARY DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/lib
)
install
(
DIRECTORY
${
LightGBM_HEADER_DIR
}
/LightGBM DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/include
)
\ No newline at end of file
include/LightGBM/utils/text_reader.h
View file @
70c31c07
...
@@ -158,7 +158,7 @@ public:
...
@@ -158,7 +158,7 @@ public:
++
cur_sample_cnt
;
++
cur_sample_cnt
;
}
}
else
{
else
{
const
size_t
idx
=
random
.
NextInt
(
0
,
line_idx
+
1
);
const
size_t
idx
=
static_cast
<
size_t
>
(
random
.
NextInt
(
0
,
line_idx
+
1
)
)
;
if
(
idx
<
static_cast
<
size_t
>
(
sample_cnt
))
{
if
(
idx
<
static_cast
<
size_t
>
(
sample_cnt
))
{
out_sampled_data
->
operator
[](
idx
)
=
std
::
string
(
buffer
,
size
);
out_sampled_data
->
operator
[](
idx
)
=
std
::
string
(
buffer
,
size
);
}
}
...
@@ -198,7 +198,7 @@ public:
...
@@ -198,7 +198,7 @@ public:
++
cur_sample_cnt
;
++
cur_sample_cnt
;
}
}
else
{
else
{
const
size_t
idx
=
random
.
NextInt
(
0
,
out_used_data_indices
->
size
());
const
size_t
idx
=
static_cast
<
size_t
>
(
random
.
NextInt
(
0
,
out_used_data_indices
->
size
())
)
;
if
(
idx
<
static_cast
<
size_t
>
(
sample_cnt
)
)
{
if
(
idx
<
static_cast
<
size_t
>
(
sample_cnt
)
)
{
out_sampled_data
->
operator
[](
idx
)
=
std
::
string
(
buffer
,
size
);
out_sampled_data
->
operator
[](
idx
)
=
std
::
string
(
buffer
,
size
);
}
}
...
...
src/CMakeLists.txt
deleted
100644 → 0
View file @
2cd024e9
include_directories
(
${
LightGBM_HEADER_DIR
}
)
if
(
APPLE
)
set
(
CMAKE_SHARED_LIBRARY_SUFFIX
".so"
)
endif
(
APPLE
)
if
(
USE_MPI
)
include_directories
(
${
MPI_CXX_INCLUDE_PATH
}
)
endif
()
AUX_SOURCE_DIRECTORY
(
./application/ APPLICATION_SRC
)
AUX_SOURCE_DIRECTORY
(
./boosting/ BOOSTING_SRC
)
AUX_SOURCE_DIRECTORY
(
./io/ IO_SRC
)
AUX_SOURCE_DIRECTORY
(
./metric/ METRIC_SRC
)
AUX_SOURCE_DIRECTORY
(
./objective/ OBJECTIVE_SRC
)
AUX_SOURCE_DIRECTORY
(
./network/ NETWORK_SRC
)
AUX_SOURCE_DIRECTORY
(
./treelearner/ TREELEARNER_SRC
)
add_executable
(
lightgbm main.cpp
${
APPLICATION_SRC
}
${
BOOSTING_SRC
}
${
IO_SRC
}
${
METRIC_SRC
}
${
OBJECTIVE_SRC
}
${
NETWORK_SRC
}
${
TREELEARNER_SRC
}
)
add_library
(
_lightgbm SHARED c_api.cpp
${
APPLICATION_SRC
}
${
BOOSTING_SRC
}
${
IO_SRC
}
${
METRIC_SRC
}
${
OBJECTIVE_SRC
}
${
NETWORK_SRC
}
${
TREELEARNER_SRC
}
)
if
(
USE_MPI
)
TARGET_LINK_LIBRARIES
(
lightgbm
${
MPI_CXX_LIBRARIES
}
)
TARGET_LINK_LIBRARIES
(
_lightgbm
${
MPI_CXX_LIBRARIES
}
)
endif
(
USE_MPI
)
if
(
WIN32
)
TARGET_LINK_LIBRARIES
(
lightgbm Ws2_32
)
TARGET_LINK_LIBRARIES
(
_lightgbm Ws2_32
)
TARGET_LINK_LIBRARIES
(
lightgbm IPHLPAPI
)
TARGET_LINK_LIBRARIES
(
_lightgbm IPHLPAPI
)
endif
(
WIN32
)
install
(
TARGETS lightgbm _lightgbm
RUNTIME DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/bin
LIBRARY DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/lib
)
install
(
DIRECTORY
${
LightGBM_HEADER_DIR
}
/LightGBM DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/include
)
windows/LightGBM.vcxproj
View file @
70c31c07
...
@@ -94,6 +94,7 @@
...
@@ -94,6 +94,7 @@
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<WholeProgramOptimization>
false
</WholeProgramOptimization>
<WholeProgramOptimization>
false
</WholeProgramOptimization>
<Optimization>
Disabled
</Optimization>
<Optimization>
Disabled
</Optimization>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
</ClCompile>
</ClCompile>
<Link>
<Link>
<AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>
...
@@ -114,6 +115,7 @@
...
@@ -114,6 +115,7 @@
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<WholeProgramOptimization>
false
</WholeProgramOptimization>
<WholeProgramOptimization>
false
</WholeProgramOptimization>
<Optimization>
Disabled
</Optimization>
<Optimization>
Disabled
</Optimization>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
</ClCompile>
</ClCompile>
<Link>
<Link>
<AdditionalDependencies>
<AdditionalDependencies>
...
@@ -134,7 +136,7 @@
...
@@ -134,7 +136,7 @@
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<OmitFramePointers>
true
</OmitFramePointers>
<OmitFramePointers>
true
</OmitFramePointers>
<RuntimeLibrary>
MultiThreaded
DLL
</RuntimeLibrary>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
</ClCompile>
</ClCompile>
<Link>
<Link>
<AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>
...
@@ -157,7 +159,7 @@
...
@@ -157,7 +159,7 @@
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<RuntimeLibrary>
MultiThreaded
DLL
</RuntimeLibrary>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<OmitFramePointers>
true
</OmitFramePointers>
<OmitFramePointers>
true
</OmitFramePointers>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
</ClCompile>
</ClCompile>
...
@@ -176,7 +178,7 @@
...
@@ -176,7 +178,7 @@
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<EnableFiberSafeOptimizations>
false
</EnableFiberSafeOptimizations>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<RuntimeLibrary>
MultiThreaded
DLL
</RuntimeLibrary>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<OmitFramePointers>
true
</OmitFramePointers>
<OmitFramePointers>
true
</OmitFramePointers>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
</ClCompile>
</ClCompile>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment