forked from xnd-project/xnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5937705
Showing
166 changed files
with
115,743 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
|
||
# ============================================================================== | ||
# Clear all relevant flags | ||
# ============================================================================== | ||
|
||
macro(clear_flags) | ||
set(CMAKE_C_FLAGS_INIT "" CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_DEBUG_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_MINSIZEREL_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_RELEASE_INIT CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_CXX_FLAGS_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_DEBUG_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_RELEASE_INIT CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_CUDA_FLAGS_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_DEBUG_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_MINSIZEREL_INIT CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_RELEASE_INIT CACHE STRING "" FORCE) | ||
|
||
|
||
set(CMAKE_C_FLAGS CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_DEBUG CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_RELWITHDEBINFO CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_MINSIZEREL CACHE STRING "" FORCE) | ||
set(CMAKE_C_FLAGS_RELEASE CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_CXX_FLAGS CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_MINSIZEREL CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS_RELEASE CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_CUDA_FLAGS CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_DEBUG CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_MINSIZEREL CACHE STRING "" FORCE) | ||
set(CMAKE_CUDA_FLAGS_RELEASE CACHE STRING "" FORCE) | ||
|
||
|
||
set(CFLAGS_LIST $ENV{CFLAGS}) | ||
separate_arguments(CFLAGS_LIST) | ||
|
||
set(CXXFLAGS_LIST $ENV{CXXFLAGS}) | ||
separate_arguments(CXXFLAGS_LIST) | ||
|
||
set(CUDAFLAGS_LIST $ENV{CUDAFLAGS}) | ||
separate_arguments(CUDAFLAGS_LIST) | ||
endmacro() | ||
|
||
|
||
# ============================================================================== | ||
# Dump all relevant flags | ||
# ============================================================================== | ||
|
||
macro(dump_flags) | ||
message("CMAKE_C_FLAGS_INIT ${CMAKE_C_FLAGS_INIT}") | ||
message("CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT}") | ||
message("CMAKE_C_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}") | ||
message("CMAKE_C_FLAGS_MINSIZEREL_INIT ${CMAKE_C_FLAGS_MINSIZEREL_INIT}") | ||
message("CMAKE_C_FLAGS_RELEASE_INIT ${CMAKE_C_FLAGS_RELEASE_INIT}") | ||
|
||
message("CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT}") | ||
message("CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT}") | ||
message("CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}") | ||
message("CMAKE_CXX_FLAGS_MINSIZEREL_INIT ${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}") | ||
message("CMAKE_CXX_FLAGS_RELEASE_INIT ${CMAKE_CXX_FLAGS_RELEASE_INIT}") | ||
|
||
message("CMAKE_CUDA_FLAGS_INIT ${CMAKE_CUDA_FLAGS_INIT}") | ||
message("CMAKE_CUDA_FLAGS_DEBUG_INIT ${CMAKE_CUDA_FLAGS_DEBUG_INIT}") | ||
message("CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT}") | ||
message("CMAKE_CUDA_FLAGS_MINSIZEREL_INIT ${CMAKE_CUDA_FLAGS_MINSIZEREL_INIT}") | ||
message("CMAKE_CUDA_FLAGS_RELEASE_INIT ${CMAKE_CUDA_FLAGS_RELEASE_INIT}") | ||
|
||
message("CMAKE_C_FLAGS ${CMAKE_C_FLAGS}") | ||
message("CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}") | ||
message("CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}") | ||
message("CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}") | ||
message("CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}") | ||
|
||
message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") | ||
message("CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}") | ||
message("CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
message("CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}") | ||
message("CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}") | ||
|
||
message("CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS}") | ||
message("CMAKE_CUDA_FLAGS_DEBUG ${CMAKE_CUDA_FLAGS_DEBUG}") | ||
message("CMAKE_CUDA_FLAGS_RELWITHDEBINFO ${CMAKE_CUDA_FLAGS_RELWITHDEBINFO}") | ||
message("CMAKE_CUDA_FLAGS_MINSIZEREL ${CMAKE_CUDA_FLAGS_MINSIZEREL}") | ||
message("CMAKE_CUDA_FLAGS_RELEASE ${CMAKE_CUDA_FLAGS_RELEASE}") | ||
endmacro() | ||
|
||
|
||
# ============================================================================== | ||
# Compiler flags | ||
# ============================================================================== | ||
|
||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR | ||
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR | ||
CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR | ||
CMAKE_C_COMPILER_ID STREQUAL "CrayClang" OR | ||
CMAKE_C_COMPILER_ID STREQUAL "FujitsuClang" OR | ||
CMAKE_C_COMPILER_ID STREQUAL "IBMClang" OR | ||
CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") | ||
|
||
clear_flags() | ||
|
||
add_compile_definitions( | ||
"$<$<CONFIG:RELWITHDEBINFO>:NDEBUG>" | ||
"$<$<CONFIG:MINSIZEREL>:NDEBUG>" | ||
"$<$<CONFIG:RELEASE>:NDEBUG>" | ||
"$<$<CONFIG:>:NDEBUG>") | ||
|
||
add_compile_options( | ||
"$<$<COMPILE_LANGUAGE:C>:-Wall;-Wextra;-std=c11;-pedantic>" | ||
"$<$<COMPILE_LANGUAGE:CXX>:-Wall;-Wextra;-std=c++11;-pedantic>" | ||
|
||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:DEBUG>>:-O0;-g>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RELWITHDEBINFO>>:-O3;-g>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:MINSIZEREL>>:-Os>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RELEASE>>:-O3>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:>>:-O3>" | ||
|
||
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:DEBUG>>:-O0;-Xcicc=-O0;-Xptxas=-O0;--compiler-options=-Wall -Wextra -std=c++11 -O0 -g>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:RELWITHDEBINFO>>:--compiler-options=-Wall -Wextra -std=c++11 -O3 -g>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:MINSIZEREL>>:--compiler-options=-Wall -Wextra -std=c++11 -Os>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:RELEASE>>:--compiler-options=-Wall -Wextra -std=c++11 -O3>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:>>:--compiler-options=-Wall -Wextra -std=c++11 -O3>" | ||
|
||
"$<$<COMPILE_LANGUAGE:C>:${CFLAGS_LIST}>" | ||
"$<$<COMPILE_LANGUAGE:CXX>:${CXXFLAGS_LIST}>" | ||
"$<$<COMPILE_LANGUAGE:CUDA>:${CUDAFLAGS_LIST}>") | ||
|
||
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") | ||
|
||
clear_flags() | ||
|
||
add_compile_definitions( | ||
"$<$<CONFIG:RELWITHDEBINFO>:NDEBUG>" | ||
"$<$<CONFIG:MINSIZEREL>:NDEBUG>" | ||
"$<$<CONFIG:RELEASE>:NDEBUG>" | ||
"$<$<CONFIG:>:NDEBUG>") | ||
|
||
add_compile_options( | ||
"$<$<COMPILE_LANGUAGE:C>:/W4;/wd4200;/wd4201;/wd4204;/std:c11>" | ||
"$<$<COMPILE_LANGUAGE:CXX>:/W4;/wd4200;/wd4201;/wd4204;/std:c++14>" | ||
|
||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:DEBUG>>:/Od;/Zi;/EHsc;/fp:strict>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RELWITHDEBINFO>>:/O2;/Zi;/EHsc;/fp:strict>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:MINSIZEREL>>:/Os;/GS;/EHsc;/fp:strict>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RELEASE>>:/O2;/GS;/EHsc;/fp:strict>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:>>:/O2;/GS;/EHsc;/fp:strict>") | ||
|
||
else() | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_STANDARD_REQUIRED TRUE) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CXX_STANDARD_REQUIRED TRUE) | ||
|
||
endif() | ||
|
||
|
||
# ============================================================================== | ||
# Various | ||
# ============================================================================== | ||
|
||
# configure_file() version that supports generator expressions. | ||
function(xnd_configure_file src target) | ||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${src}" contents) | ||
string(CONFIGURE "${contents}" contents) | ||
file(GENERATE OUTPUT "${target}" CONTENT "${contents}") | ||
endfunction() | ||
|
||
|
||
# find_library() wrapper that prints the real, versioned library name. | ||
macro(xnd_find_library var root_path target) | ||
if(root_path) | ||
list(PREPEND CMAKE_FIND_ROOT_PATH ${root_path}) | ||
endif() | ||
|
||
message(STATUS "Looking for system lib${target}") | ||
|
||
find_library(${var} NAMES ${target} REQUIRED CMAKE_FIND_ROOT_PATH_BOTH) | ||
|
||
get_filename_component(tmp ${${var}} REALPATH) | ||
message(STATUS "Found ${tmp}") | ||
|
||
if(root_path) | ||
list(REMOVE_AT CMAKE_FIND_ROOT_PATH 0) | ||
endif() | ||
endmacro() | ||
|
||
macro(assert TEST COMMENT) | ||
if(NOT ${TEST}) | ||
message(FATAL_ERROR "Assertion failed: ${COMMENT}") | ||
endif() | ||
endmacro() | ||
|
||
macro(dump_options) | ||
message( | ||
" BUILD_NDTYPES: ${BUILD_NDTYPES}\n" | ||
" BUILD_XND: ${BUILD_XND}\n" | ||
" BUILD_GUMATH: ${BUILD_GUMATH}\n" | ||
" LIB_INSTALL: ${LIB_INSTALL}\n" | ||
" LIB_INSTALL_MOD_HEADERS: ${LIB_INSTALL_MOD_HEADERS}\n" | ||
" BUILD_MOD_NDTYPES: ${BUILD_MOD_NDTYPES}\n" | ||
" BUILD_MOD_XND: ${BUILD_MOD_XND}\n" | ||
" BUILD_MOD_GUMATH: ${BUILD_MOD_GUMATH}\n" | ||
" INSTALL_MOD_NDTYPES: ${INSTALL_MOD_NDTYPES}\n" | ||
" INSTALL_MOD_XND: ${INSTALL_MOD_XND}\n" | ||
" INSTALL_MOD_GUMATH: ${INSTALL_MOD_GUMATH}\n" | ||
" MOD_WITH_SYSTEM_LIB: ${MOD_WITH_SYSTEM_LIB}\n" | ||
" MOD_WITH_XNDLIB: ${MOD_WITH_XNDLIB}\n" | ||
" MOD_INSTALL: ${MOD_INSTALL}\n\n") | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
The whole build is handled by cmake, which supports a multitude of build | ||
programs. Since the Python modules are used for testing, they are built | ||
by default if Python is found. | ||
|
||
Here are a couple of common usage scenarios: | ||
|
||
Unix: in-tree development | ||
========================= | ||
|
||
For convenience, edit the ./configure cmake-wrapper script and set the build | ||
type and the Python root directory. | ||
|
||
./configure . | ||
make -j10 | ||
|
||
make ntest | ||
make xtest | ||
make npytest | ||
make xpytest | ||
make gpytest | ||
|
||
# Do NOT run this outside of the xnd directory! | ||
./distclean.sh | ||
|
||
|
||
Release install | ||
=============== | ||
|
||
The Python modules are not installed, they are just for testing. Single-Config | ||
generators default to "Release" automatically. Multi-Config generators (except | ||
for "Ninja Multi-Config") default to "Debug" and require an explicit build type. | ||
|
||
Unix: Single-Config generator (make) | ||
------------------------------------ | ||
|
||
mkdir build | ||
cd build | ||
cmake .. | ||
make -j10 | ||
|
||
# Tests: optional | ||
make ntest | ||
make xtest | ||
|
||
# Python Tests: optional | ||
make npytest | ||
make xpytest | ||
make gpytest | ||
|
||
make install | ||
|
||
|
||
Portable version | ||
---------------- | ||
|
||
This will use "make" on Unix and "msbuild" on Windows. | ||
|
||
# Windows only: | ||
vcvarsall x64 | ||
|
||
# All: | ||
mkdir build | ||
cd build | ||
cmake .. | ||
cmake --build . --config Release --target all | ||
|
||
# Tests: optional | ||
cmake --build . --config Release --target ntest | ||
cmake --build . --config Release --target xtest | ||
|
||
# Python Tests: optional | ||
cmake --build . --config Release --target npytest | ||
cmake --build . --config Release --target xpytest | ||
cmake --build . --config Release --target gpytest | ||
|
||
cmake --install . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017-2018, plures | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
xnd | ||
=== | ||
|
||
xnd comprises three libraries for scientific computing: | ||
|
||
- libndtypes provides the types required for describing typed memory blocks. | ||
It uses the datashape language for specifying types. | ||
|
||
- libxnd provides typed memory blocks for CPU and GPU memory. It uses libndtypes | ||
for describing the memory layout and accessing memory locations. | ||
|
||
- libgumath provides functions that operate on xnd memory blocks. It supports | ||
multimethods and adding new kernels at runtime. | ||
|
||
|
||
xnd ships with the following three Python modules that map to the above | ||
libraries. The Python modules are included for testing the libraries, but | ||
the libraries are not Python-specific in any way. | ||
|
||
- ndtypes | ||
|
||
- xnd | ||
|
||
- gumath | ||
|
||
|
||
The libraries and modules were written by `Stefan Krah <https://github.com/skrah>`_. | ||
|
||
Funding for these projects initially came from `Anaconda Inc. <https://www.anaconda.com/>`_ | ||
and now from `Quansight LLC <https://www.quansight.com/>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef XND_CONFIG_H | ||
#define XND_CONFIG_H | ||
|
||
#cmakedefine HAVE_CUDA ${HAVE_CUDA} | ||
|
||
#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} | ||
|
||
#cmakedefine HAVE_PTHREAD_H ${HAVE_PTHREAD_H} | ||
|
||
#cmakedefine WITH_VALGRIND ${WITH_VALGRIND} | ||
|
||
#endif /* XND_CONFIG_H */ |
Oops, something went wrong.