Skip to content
This repository has been archived by the owner on Dec 21, 2018. It is now read-only.

[WIP] Binary Operators #94

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
b92f977
Binary Operators
Aug 8, 2018
40577cb
Binary Operations
Aug 17, 2018
916b695
Binary Operations
Aug 20, 2018
cf20eef
Binary Operations
Aug 21, 2018
144aa49
Binary Operations
Aug 21, 2018
8b228bb
Binary Operations
Aug 21, 2018
3717b4f
Binary Operations
Aug 22, 2018
a24d15f
Binary Operations
Aug 22, 2018
2e384e6
Binary Operations
Aug 23, 2018
a11dc77
Binary Operations
Aug 23, 2018
0097521
Binary Operations
Aug 23, 2018
88d3c45
Binary Operations
Aug 24, 2018
280f52a
Binary Operations
Aug 24, 2018
fc9efab
Binary Operations
Aug 24, 2018
c397a7e
Binary Operations
Aug 24, 2018
1ac172d
Merge branch 'master' into binary-operators-draft
ironbit Aug 28, 2018
335485e
Binary Operations
Aug 28, 2018
d112885
Merge branch 'binary-operators-draft' of github.com:BlazingDB/libgdf …
Aug 28, 2018
6145569
Binary Operations
Aug 30, 2018
d311a81
Binary Operations
Aug 30, 2018
74c0b68
Binary Operations
Aug 31, 2018
d0e4dfe
Binary Operations
Aug 31, 2018
891e2d9
Binary Operations
Sep 1, 2018
3a18c62
Binary Operations
Sep 3, 2018
ba15ada
Binary Operations
Sep 3, 2018
191e549
Binary Operations
Sep 3, 2018
6061920
Binary Operations
Sep 4, 2018
5048f24
Binary Operations
Sep 4, 2018
35f64e5
Added libgdf static library target as optional (disabled by default).
Sep 4, 2018
6667ade
Binary Operations
Sep 4, 2018
34579a4
Changed the name of the static library (libgdf.a).
Sep 4, 2018
55633c9
Minor fixes for LIBGDF_STATIC_LIB and update README.md
aucahuasi Sep 5, 2018
3c359c0
Link gdf against cuda and nvrtc libs
aucahuasi Sep 5, 2018
e427005
Binary Operations
Sep 5, 2018
e00479b
Add cuda runtime libs
aucahuasi Sep 5, 2018
42d24f4
Merge branch 'binary-operators-draft' of https://github.com/BlazingDB…
aucahuasi Sep 5, 2018
ccc3bc9
Merge branch 'master' into binary-operators-draft
Sep 5, 2018
52a7aa4
Updated branch 'binary-operators-draft'
Sep 5, 2018
f08a771
Binary Operations
Sep 5, 2018
5313068
Binary Operations
Sep 6, 2018
b46cd2a
Binary Operations
Sep 6, 2018
b1f5ae2
Binary Operations
Sep 6, 2018
82e99c8
Binary Operations
Sep 6, 2018
6509c76
Binary Operations
Sep 6, 2018
c093441
test solution
aucahuasi Sep 7, 2018
214236c
upgrade py package
aucahuasi Sep 7, 2018
1a9d550
Binary Operations
Sep 18, 2018
29e81ea
Merge branch 'master' into binary-operators-draft
Sep 18, 2018
65d207e
Merge branch 'master' into binary-operators-draft
Sep 19, 2018
f3e7768
Merge branch 'binary-operators-draft' of github.com:BlazingDB/libgdf …
Sep 19, 2018
12a4f5c
Binary Operations
Sep 19, 2018
6073b03
Merge branch 'master' into binary-operators-draft
Sep 19, 2018
47b0905
Binary Operations
Sep 24, 2018
9ba4b73
Binary Operations
Sep 25, 2018
6f6d804
Binary Operations
Sep 25, 2018
96012d9
Binary Operations
Sep 25, 2018
5773a58
Binary Operations
Sep 27, 2018
55c5fd2
Merge branch 'master' into binary-operators-draft
Sep 27, 2018
10dff5d
Binary Operations
Sep 28, 2018
729cbfa
Merge branch 'master' into binary-operators-draft
Sep 28, 2018
a3cbde8
Binary Operations
Sep 29, 2018
59b5ba6
Merge branch 'master' into binary-operators-draft
Sep 29, 2018
36241ec
Merge branch 'master' into binary-operators-draft
Oct 11, 2018
1c521a1
Binary Operations
Oct 17, 2018
b6f5cce
Binary Operations
Oct 17, 2018
a166c7c
Binary Operations
Oct 17, 2018
3a74ff8
new order by api
Oct 22, 2018
f7c3d4f
[binary-operators-draft]: udpate get_column_byte_width to support uns…
aocsa Oct 24, 2018
cc75849
[binary-operator-draft] update gpu_apply_stencil to work with least-s…
aocsa Oct 30, 2018
2c356d0
fixed some issues with binary ops not being able to output if the spa…
Nov 1, 2018
d0a76c1
made a small fix to the sorting code so it gets the size properly, it…
Nov 2, 2018
dfa27b8
removed some couts
Nov 2, 2018
e47aebe
removed some couts
Nov 2, 2018
9722f0e
TODO use a fixed compute capability
aucahuasi Nov 6, 2018
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "thirdparty/moderngpu"]
path = thirdparty/moderngpu
url = https://github.com/moderngpu/moderngpu.git
[submodule "thirdparty/jitify"]
path = thirdparty/jitify
url = https://github.com/NVIDIA/jitify.git
59 changes: 56 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(CMAKE_CXX_STANDARD 11)
message(STATUS "Using C++ standard: c++${CMAKE_CXX_STANDARD}")

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Configuration/")
message(STATUS "CMAKE_MODULE_PATH:" "${CMAKE_MODULE_PATH}")

IF(CMAKE_COMPILER_IS_GNUCXX)
Expand Down Expand Up @@ -66,6 +67,9 @@ if(CUDA_FOUND)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-Werror cross-execution-space-call;-Xcompiler -Wall,-Werror)

message(STATUS "CUDA_NVCC_FLAGS: ${CUDA_NVCC_FLAGS}")

include(ConfigCuda RESULT_VARIABLE result)
message(STATUS "ConfigCuda: ${result}")
else()
message(FATAL_ERROR "CUDA not found, please check your settings.")
endif()
Expand All @@ -84,13 +88,17 @@ else()
endif()

include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cub"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/jitify"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/moderngpu/src"
"${CUDA_INCLUDE_DIRS}"
"${ARROW_INCLUDEDIR}"
)

link_directories(${CUDA_LIBRARY_DIR} ${CUDA_LIBRARY_STUBS_DIR})

IF(CUDA_VERSION_MAJOR GREATER 7)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode;arch=compute_60,code=sm_60)
ENDIF(CUDA_VERSION_MAJOR GREATER 7)
Expand Down Expand Up @@ -120,7 +128,18 @@ if(HT_LEGACY_ALLOCATOR)
endif()


cuda_add_library(gdf SHARED
## Benchmark
include(ConfigBenchmark RESULT_VARIABLE result)
message(STATUS "ConfigBenchmark: ${result}")


## Binary Operations
add_subdirectory(src/binary)
get_directory_property(binary_operation_source_files DIRECTORY src/binary DEFINITION source_files)


## Variable 'libgdf_source_files' with all source files.
set(libgdf_source_files
src/binaryops.cu
src/bitmaskops.cu
src/column.cpp
Expand All @@ -142,13 +161,44 @@ cuda_add_library(gdf SHARED
src/unaryops.cu
#src/windowedops.cu
src/quantiles.cu
${binary_operation_source_files}
)


cuda_add_library(gdf SHARED ${libgdf_source_files})


## Position Independent Code for shared library
set_target_properties(gdf PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(gdf PROPERTIES CUDA_SEPARABLE_COMPILATION ON)


## Build static library
## By default is disabled.
## Add -DLIBGDF_STATIC_LIB=ON as cmake parameter to create the static library.
option(LIBGDF_STATIC_LIB "Build static library for libgdf" OFF)
if(LIBGDF_STATIC_LIB)
message(STATUS "libgdf static library enabled")
cuda_add_library(gdf_static STATIC ${libgdf_source_files})
set_target_properties(gdf_static PROPERTIES OUTPUT_NAME gdf)
else()
message(STATUS "libgdf static library disabled")
endif()


if (ARROW_NUMERIC_VERSION EQUAL 900)
# arrow-0.9 requires boost_regex
target_link_libraries(gdf arrow boost_regex)
target_link_libraries(gdf arrow boost_regex ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB})

if(LIBGDF_STATIC_LIB)
target_link_libraries(gdf_static arrow boost_regex ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB})
endif()
else()
target_link_libraries(gdf arrow)
target_link_libraries(gdf arrow ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB})

if(LIBGDF_STATIC_LIB)
target_link_libraries(gdf_static arrow ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB})
endif()
endif()

# Command to symlink files into the build directory
Expand Down Expand Up @@ -181,6 +231,9 @@ add_custom_command(TARGET pytest POST_BUILD
# The install target
install(TARGETS gdf LIBRARY DESTINATION lib)
install(DIRECTORY include/gdf DESTINATION include)
if(LIBGDF_STATIC_LIB)
install(TARGETS gdf_static ARCHIVE DESTINATION lib)
endif()

# Configure the C++ tests
find_package(GTest QUIET)
Expand Down
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ not necessary.

You can install Boost C++ 1.58 from sources as well: https://www.boost.org/doc/libs/1_58_0/more/getting_started/unix-variants.html

To run the python tests it is recommended to setup a conda environment for
To run the python tests it is recommended to setup a conda environment for
the dependencies.

```bash
Expand Down Expand Up @@ -114,6 +114,12 @@ $ cmake -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ..
To build the C/C++ code, run `make`. This should produce a shared library
named `libgdf.so` or `libgdf.dylib`.

To build the static library for libgdf just run cmake with:
```bash
$ cmake -DLIBGDF_STATIC_LIB=ON -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ..
```
Note: By default the option LIBGDF_STATIC_LIB is disabled (default value OFF).

If you run into compile errors about missing header files:

```bash
Expand All @@ -138,3 +144,36 @@ conda environment activated), run below to exceute test:
```bash
$ make pytest # this auto trigger target "copy_python"
```

### Benchmark

It is used [Google Benchmark](https://github.com/google/benchmark) for this purpose.
Refer to that repository in order to get more information related to its functionality.

In order to enable the benchmark functionality, which by default is disabled,
it is required to add the option BENCHMARK in the command line when 'cmake' is executed.
It is also recommended to use release build type.

```bash
$ cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK=ON path/to/libgdf
```

When the build process is completed, the benchmark binary files will be located in the 'bench' folder.
In order to get the different input arguments for a benchmark binary file,
add the argument '--help' in the command line when the file is executed.

The benchmark is applied to the following features:
* Binary Operations (NVRTC - Jitify).

###### Binary Operations

Recommended input arguments when this benchmark is executed.
```bash
$ BinaryOperationsBench --benchmark_counters_tabular=true
```

### Benchmark - Troubleshoot

When a message related to CPU scaling (`***WARNING*** CPU scaling is enabled`) appeared,
refer to the section [Disable CPU frequency scaling](https://github.com/google/benchmark#disable-cpu-frequency-scaling)
in the Google Benchmark documentation.
28 changes: 28 additions & 0 deletions cmake/Configuration/ConfigBenchmark.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#=============================================================================
# Copyright 2018-2019 BlazingDB, Inc.
# Copyright 2018 Christian Noboa Mardini <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

## Build Benchmark
## By default is disabled.
## Add -DBENCHMARK:BOOL=ON as cmake parameter to create the benchmark.

option(BENCHMARK "Benchmark" OFF)

if(BENCHMARK)
message(STATUS "Benchmark is enabled")
include(GoogleBenchmark)
add_subdirectory(src/bench)
endif()
38 changes: 38 additions & 0 deletions cmake/Configuration/ConfigCuda.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#=============================================================================
# Copyright 2018-2019 BlazingDB, Inc.
# Copyright 2018 Christian Noboa Mardini <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

set(CUDA_LIBRARY_DIR ${CUDA_TOOLKIT_ROOT_DIR})
set(CUDA_LIBRARY_STUBS_DIR ${CUDA_TOOLKIT_ROOT_DIR})

## Based on NVRTC (Runtime Compilation) - CUDA Toolkit Documentation - v9.2.148
## 2.2. Installation
if(CMAKE_HOST_APPLE)
set(CUDA_LIBRARY_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib)
set(CUDA_LIBRARY_STUBS_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib/stubs)
elseif(CMAKE_HOST_UNIX)
set(CUDA_LIBRARY_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib64)
set(CUDA_LIBRARY_STUBS_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs)
elseif(CMAKE_HOST_WIN32)
set(CUDA_LIBRARY_DIR ${CUDA_TOOLKIT_ROOT_DIR}\lib\x64)
set(CUDA_LIBRARY_STUBS_DIR ${CUDA_TOOLKIT_ROOT_DIR}\lib\x64\stubs)
endif()

set(CUDA_CUDA_LIB cuda)
set(CUDA_NVRTC_LIB nvrtc)

message(STATUS "CUDA_LIBRARY_DIR: ${CUDA_LIBRARY_DIR}")
message(STATUS "CUDA_LIBRARY_STUBS_DIR: ${CUDA_LIBRARY_STUBS_DIR}")
48 changes: 48 additions & 0 deletions cmake/Modules/GoogleBenchmark.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#=============================================================================
# Copyright 2018-2019 BlazingDB, Inc.
# Copyright 2018 Christian Noboa Mardini <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

# Download and unpack google-benchmark at configure time
configure_file(${CMAKE_SOURCE_DIR}/cmake/Templates/GoogleBenchmark.CMakeLists.txt.cmake
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/download/CMakeLists.txt)

execute_process(
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/download
)

if(result)
message(FATAL_ERROR "CMake step for google benchmark failed: ${result}")
endif()


execute_process(
COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/download
)

if(result)
message(FATAL_ERROR "Build step for google benchmark failed: ${result}")
endif()


set(GOOGLE_BENCHMARK_LIB "benchmark")
set(GOOGLE_BENCHMARK_MAIN_LIB "benchmark_main")
set(GOOGLE_BENCHMARK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/install")
set(GOOGLE_BENCHMARK_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/install/include")
set(GOOGLE_BENCHMARK_LIBRARY_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/install/lib")
36 changes: 36 additions & 0 deletions cmake/Templates/GoogleBenchmark.CMakeLists.txt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#=============================================================================
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use this for CI? @mike-wendt

# Copyright 2018-2019 BlazingDB, Inc.
# Copyright 2018 Christian Noboa Mardini <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

cmake_minimum_required(VERSION 3.0)

project(google-benchmark)

include(ExternalProject)

ExternalProject_Add(
google-benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG master
SOURCE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/source"
BINARY_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/build"
INSTALL_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/install"
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
-DBENCHMARK_ENABLE_TESTING=OFF
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF
-DBENCHMARK_DOWNLOAD_DEPENDENCIES=OFF
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/thirdparty/google-benchmark/install
)
2 changes: 1 addition & 1 deletion conda_environments/dev_py35.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
- numpy=1.12.1=py35_0
- openssl=1.0.2k=2
- pip=9.0.1=py35_1
- py=1.4.33=py35_0
- py=1.5.2
- pycparser=2.17=py35_0
- pytest=3.0.7=py35_0
- python=3.5.3=1
Expand Down
Loading