Skip to content

Commit 356d798

Browse files
authored
Merge pull request #1 from Deepanshu2017/master
Merge Hydra.Python from Depanshu's GSoC activities.
2 parents b4adbed + 8970205 commit 356d798

File tree

118 files changed

+39589
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+39589
-5
lines changed

CMakeLists.txt

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
### CMakeLists.txt file for the Hydra.Python project
2+
3+
cmake_minimum_required(VERSION 2.8)
4+
5+
# project name
6+
project(Hydra.Python)
7+
8+
9+
# warn user if system is not UNIX
10+
if(NOT UNIX)
11+
message(FATAL_ERROR "This is an unsupported operating system!")
12+
endif()
13+
14+
##====================================================
15+
## some colors
16+
17+
string(ASCII 27 Esc)
18+
set(ColourReset "${Esc}[m")
19+
set(ColourBold "${Esc}[1m")
20+
set(Red "${Esc}[31m")
21+
set(Green "${Esc}[32m")
22+
set(Yellow "${Esc}[33m")
23+
set(Blue "${Esc}[34m")
24+
set(Magenta "${Esc}[35m")
25+
set(Cyan "${Esc}[36m")
26+
set(White "${Esc}[37m")
27+
set(BoldRed "${Esc}[1;31m")
28+
set(BoldGreen "${Esc}[1;32m")
29+
set(BoldYellow "${Esc}[1;33m")
30+
set(BoldBlue "${Esc}[1;34m")
31+
set(BoldMagenta "${Esc}[1;35m")
32+
set(BoldCyan "${Esc}[1;36m")
33+
set(BoldWhite "${Esc}[1;37m")
34+
35+
##====================================================
36+
37+
mark_as_advanced(HydraPython_VERSION_MAJOR HydraPython_VERSION_MINOR HydraPython_VERSION_PATCH)
38+
39+
SET(HydraPython_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake")
40+
SET(CMAKE_MODULE_PATH "${HydraPython_CMAKE_DIR}" ${CMAKE_MODULE_PATH})
41+
SET(CMAKE_VERBOSE_MAKEFILE ON)
42+
43+
# options to gcc
44+
include(CheckCXXCompilerFlag)
45+
CHECK_CXX_COMPILER_FLAG("--std=c++11" COMPILER_SUPPORTS_CXX11)
46+
if(NOT COMPILER_SUPPORTS_CXX11)
47+
message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
48+
endif()
49+
50+
# options to gcc
51+
52+
set(CMAKE_CXX_FLAGS "-DTHRUST_VARIADIC_TUPLE -flto --std=c++11 -fvisibility=hidden -march=native -fPIC -O4" CACHE STRING "compile flags" FORCE)
53+
54+
# get Hydra
55+
find_package(Hydra 1.0.0 REQUIRED)
56+
include_directories(${Hydra_INCLUDE_DIR})
57+
58+
# get THRUST
59+
find_package(Thrust 1.8.3 REQUIRED)
60+
include_directories(${THRUST_INCLUDE_DIR})
61+
62+
# get CUDA
63+
find_package(CUDA 8.0)
64+
if(CUDA_FOUND)
65+
include_directories("${CUDA_INCLUDE_DIRS}")
66+
endif(CUDA_FOUND)
67+
68+
# get TBB
69+
find_package(TBB )
70+
if(TBB_FOUND)
71+
include_directories(${TBB_INCLUDE_DIRS})
72+
link_directories(${TBB_LIBRARY})
73+
endif(TBB_FOUND)
74+
75+
# get OpenMP
76+
find_package(OpenMP REQUIRED)
77+
if(OPENMP_FOUND)
78+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
79+
endif(OPENMP_FOUND)
80+
81+
# get ROOT
82+
#find_package(ROOT)
83+
#if(ROOT_FOUND)
84+
#include_directories(${ROOT_INCLUDE_DIR})
85+
#link_directories(${ROOT_LIBRARY_DIR})
86+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ROOT_AVAILABLE_")
87+
#endif(ROOT_FOUND)
88+
89+
# generate API documentation with Doxygen
90+
find_package(Doxygen)
91+
option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" NO)
92+
93+
find_package(pybind11 REQUIRED)
94+
include_directories(${pybind11_INCLUDE_DIRS})
95+
96+
set(Python_ADDITIONAL_VERSIONS 3)
97+
find_package(PythonLibs 3 REQUIRED)
98+
include_directories(${PYTHON_INCLUDE_DIRS})
99+
link_directories(${PYTHON_LIBRARIES})
100+
101+
# including directories
102+
include_directories(${PROJECT_SOURCE_DIR}/include; ${PROJECT_SOURCE_DIR})
103+
104+
if(CUDA_FOUND)
105+
106+
# set cuda flags
107+
108+
SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --cudart ; static ;--expt-relaxed-constexpr; -ftemplate-backtrace-limit=0; --expt-extended-lambda;--relocatable-device-code=false ;
109+
-Xptxas -dlcm=ca; -Xptxas --opt-level=4 )
110+
111+
SET(CUDA_SEPARABLE_COMPILATION OFF)
112+
SET(CUDA_VERBOSE_BUILD ON)
113+
114+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8)
115+
LIST(APPEND CUDA_NVCC_FLAGS " -D_MWAITXINTRIN_H_INCLUDED ")
116+
endif()
117+
118+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.4)
119+
LIST(APPEND CUDA_NVCC_FLAGS " -Xcompiler -D__CORRECT_ISO_CPP11_MATH_H_PROTO ")
120+
endif()
121+
# Detect CUDA architecture and get best NVCC flags
122+
123+
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCudaArch.cmake)
124+
125+
SELECT_NVCC_ARCH_FLAGS(NVCC_FLAGS_EXTRA)
126+
127+
LIST(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA})
128+
129+
endif(CUDA_FOUND)
130+
131+
if( OPENMP_FOUND )
132+
SET(BUILD_OPENMP_TARGETS ON)
133+
else()
134+
SET(BUILD_OPENMP_TARGETS OFF)
135+
endif(OPENMP_FOUND)
136+
137+
if( CUDA_FOUND )
138+
SET(BUILD_CUDA_TARGETS ON)
139+
else()
140+
SET(BUILD_CUDA_TARGETS OFF)
141+
endif(CUDA_FOUND)
142+
143+
if(TBB_FOUND)
144+
SET(BUILD_TBB_TARGETS ON)
145+
else()
146+
SET(BUILD_TBB_TARGETS OFF)
147+
endif(TBB_FOUND)
148+
149+
# messages
150+
MESSAGE(STATUS "${BoldGreen}================================================================ ${ColourReset}")
151+
MESSAGE(STATUS "${BoldGreen}================= SUMMARY OF THE PATHS PROJECT =============== ${ColourReset}")
152+
MESSAGE(STATUS "${BoldGreen}================================================================ ${ColourReset}")
153+
if( OPENMP_FOUND )
154+
MESSAGE(STATUS "${BoldYellow}OpenMP compiler flags: ${ColourReset}" ${OpenMP_CXX_FLAGS})
155+
MESSAGE(STATUS "${BoldYellow}Build OpenMP-based targets:${ColourReset} ${BUILD_OPENMP_TARGETS}")
156+
endif(OPENMP_FOUND)
157+
158+
if( CUDA_FOUND )
159+
MESSAGE(STATUS "${BoldYellow}CUDA include: ${ColourReset}" ${CUDA_INCLUDE_DIRS})
160+
MESSAGE(STATUS "${BoldYellow}CUDA libraries:${ColourReset} " ${CUDA_LIBRARIES} )
161+
MESSAGE(STATUS "${BoldYellow}Build CUDA/NVCC-based targets:${ColourReset} ${BUILD_CUDA_TARGETS}")
162+
endif(CUDA_FOUND)
163+
164+
if( TBB_FOUND )
165+
MESSAGE(STATUS "${BoldYellow}TBB include: ${ColourReset}" ${TBB_INCLUDE_DIRS})
166+
MESSAGE(STATUS "${BoldYellow}TBB libraries:${ColourReset} " ${TBB_LIBRARIES} )
167+
MESSAGE(STATUS "${BoldYellow}Build TBB-based targets:${ColourReset} ${BUILD_TBB_TARGETS}")
168+
endif(TBB_FOUND)
169+
170+
MESSAGE(STATUS "${BoldYellow}Hydra include path:${ColourReset} ${Hydra_INCLUDE_DIR}")
171+
MESSAGE(STATUS "${BoldYellow}Thrust include path:${ColourReset} ${THRUST_INCLUDE_DIR}")
172+
MESSAGE(STATUS "${BoldYellow}pybind11 include path:${ColourReset} ${pybind11_INCLUDE_DIRS}")
173+
MESSAGE(STATUS "${BoldYellow}Python include path:${ColourReset} ${PYTHON_INCLUDE_DIRS}")
174+
MESSAGE(STATUS "${BoldYellow}Python libraries:${ColourReset} ${PYTHON_LIBRARIES}")
175+
MESSAGE(STATUS "${BoldYellow}project source dir: ${ColourReset}" ${PROJECT_SOURCE_DIR} )
176+
MESSAGE(STATUS "${BoldYellow}project build dir: ${ColourReset}" ${PROJECT_BINARY_DIR} )
177+
MESSAGE(STATUS "${BoldYellow}nvcc cflags: ${ColourReset}" ${CUDA_NVCC_FLAGS} )
178+
MESSAGE(STATUS "${BoldYellow}gcc cflags: ${ColourReset}" ${CMAKE_CXX_FLAGS} )
179+
MESSAGE(STATUS "${BoldYellow}include directories:${ColourReset}")
180+
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
181+
foreach(dir ${dirs})
182+
message(STATUS "${Green} dir = ${ColourReset}'${dir}'")
183+
endforeach()
184+
MESSAGE(STATUS "${BoldYellow}Install diretory: ${ColourReset}" ${CMAKE_INSTALL_PREFIX} )
185+
MESSAGE(STATUS "${BoldGreen}=============================================================== ${ColourReset}")
186+
187+
188+
189+
IF(OPENMP_FOUND)
190+
191+
add_library(HydraPython SHARED src/PyBindings.cpp)
192+
set_target_properties(HydraPython PROPERTIES PREFIX ""
193+
COMPILE_FLAGS "-fopenmp -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -lgomp")
194+
target_link_libraries(HydraPython ${PYTHON_LIBRARIES})
195+
ENDIF(OPENMP_FOUND)

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Contributing to Hydra.Python
2+
============================
3+
4+
We very much welcome contributors and contributions!
5+
Contributions can be to the code itself, the documentation, or the suite of examples and tests.
6+
7+
How to contribute
8+
-----------------
9+
10+
The preferred workflow for contributions to the project is via a fork to the main repository,
11+
then cloning and editing files on a dedicated branch, and finally creating a pull request to the main repository.

LICENSE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
631631
state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634-
{one line to give the program's name and a brief idea of what it does.}
635-
Copyright (C) {year} {name of author}
634+
Hydra.Python
635+
Copyright (C) 2017 Antonio Augusto Alves Junior
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
{project} Copyright (C) {year} {fullname}
655+
Hydra.Python Copyright (C) 2017 Antonio Augusto Alves Junior
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
1-
# Hydra.Python
2-
Python bindings for Hydra
1+
Hydra.Python
2+
============
3+
4+
Python 2.7+ and 3.x bindings for the [Hydra C++ library](https://github.com/MultithreadCorner/Hydra/).
5+
6+
The bindings are produced with [pybind11](http://pybind11.readthedocs.io/). The project makes use of [CMAKE](https://cmake.org/).
7+
8+
9+
Getting started
10+
---------------
11+
12+
Work-in-progress instructions:
13+
14+
0. when cmake'ing pybind11, make sure to specify the correct major Python version. For example `cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python` to make sure Python 2 is picked up. (Or provide the path to python3)
15+
1. clone the git repository: `git clone https://gitlab.com/aalvesjr/Hydra.Python.git`
16+
2. go to the Hydra.Python directory just retrieved: `cd Hydra.Python`
17+
3. create a build directory: `mkdir build`
18+
4. go to build directory: `cd build`
19+
5. `cmake -DHYDRA_INSTALL_PATH=/path2sw/Hydra/ -DTHRUST_INSTALL_PATH=/path2sw/Hydra/ -DPYBIND11_INSTALL_PATH=/path2sw/pybind11/include/ ..`
20+
6. `make`
21+
22+
These instructions create a library .so to be imported from Python.
23+
Comprehensive documentation is to be found under the `docs/` folder. The `docs/` folder
24+
also contains the GSoC 2017 project report.

0 commit comments

Comments
 (0)