Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake for majel #2118

Merged
merged 7 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ RUN git clone https://github.com/woboq/woboq_codebrowser /woboq && \
-DCMAKE_BUILD_TYPE=Release . \
make)

# Install gtest.
#
# NOTE: This is added for quick hack of the development work of
# majel-in-paddle.
RUN git clone https://github.com/google/googletest /gtest && \
cd /gtest && \
git checkout -b release-1.8.0 && \
cmake . && make install

# Configure OpenSSH server. c.f. https://docs.docker.com/engine/examples/running_ssh_service
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
Expand Down
10 changes: 0 additions & 10 deletions majel/Makefile

This file was deleted.

8 changes: 8 additions & 0 deletions paddle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ add_subdirectory(pserver)
add_subdirectory(trainer)
add_subdirectory(scripts)

find_package(boost QUIET)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我记得design doc里说用轻量级的boost替代品,这里仍然是用的boost吗?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是boost,不是替代品。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in #2122


if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我对cmake不是很熟悉,为何这里要把当前目录给include了?repo/paddle下面貌似没有source code呀。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in #2122

add_subdirectory(majel)
endif()

if(WITH_C_API)
add_subdirectory(capi)
endif()
Expand Down
15 changes: 15 additions & 0 deletions paddle/majel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(MAJEL_CXX_FILES place.cpp)
Copy link
Contributor Author

@gangliao gangliao May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PADDLE includes both CPU and GPU versions. Majel is built with GPU only if it equipped one.

If CMake detects the host machine equipped GPUs, it will invoke cuda_add_library to generate the library, vice visa.

NOTE: The suffix of unit test files should strictly limit to *.cpp, because it doesn't contain any CUDA syntaxes and semantics.

Copy link
Collaborator

@wangkuiyi wangkuiyi May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CMake detects the host machine equipped GPUs, it will invoke cuda_add_library to generate the library, vice visa.

If we are going to port Majel to Paddle, I think we will have to enable GPU and CPU versions. Also, we'll have to be able to specify which one to build, as we do with Paddle. Also, I think we shouldn't assume that the development computer having a GPU means that the runtime environment would have GPUs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: The suffix of unit test files should strictly limit to .cpp, because it doesn't contain any CUDA syntaxes and semantics.

I agree that if a source file doesn't include CUDA code, the suffix shouldn't be .cu. But I personally prefer .cc over .cpp following Google C++ Style Guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in #2122

set(MAJEL_CUDA_FILES "")

if(CUDA_FOUND)
cuda_add_library(majel ${MAJEL_CUDA_FILES} ${MAJEL_CXX_FILES})
else()
add_library(majel ${MAJEL_CXX_FILES})
endif()

file(GLOB_RECURSE CHECK_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp" "*.h")
add_style_check_target(majel ${CHECK_FILES})

if(WITH_TESTING)
add_subdirectory(test)
endif()
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions paddle/majel/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
file(GLOB_RECURSE ALL_TEST_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp" "*.cc")

add_executable(majel_tests ${ALL_TEST_FILES})
add_dependencies(majel_tests majel ${external_project_dependencies})
target_link_libraries(majel_tests
${Boost_LIBRARIES}
${GTEST_LIBRARIES}
majel
)
add_test(majel_tests majel_tests)
File renamed without changes.
6 changes: 6 additions & 0 deletions paddle/majel/test/test_framework.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "gtest/gtest.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this file? I think we can just link -lgtest_main to have the main function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in #2122


int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}