Skip to content

Commit

Permalink
mtensor v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhimin committed May 8, 2023
1 parent 08b32c9 commit 1b63379
Show file tree
Hide file tree
Showing 189 changed files with 1,144 additions and 13,202 deletions.
11 changes: 4 additions & 7 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
# We'll use defaults from the Google style, but with 4 columns indentation.
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 120
ColumnLimit: 100
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
IndentWidth: 4
Language: Cpp

---
Language: JavaScript
# Use 100 columns for JS.

---
Language: Proto
# Don't format .proto files.
Expand Down
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

7 changes: 0 additions & 7 deletions .gitattributes

This file was deleted.

6 changes: 0 additions & 6 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@
CMakeSettings.json

vs
build
build_android
build_linux
build_win
build_bash
build_icc
build_android_icc
build*
tmp

bin
Expand All @@ -59,4 +53,4 @@ core*

lenna.png

*.raw
*.raw
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "benchmark/vendor/benchmark"]
path = third_party/benchmark
url = https://github.com/matazure/benchmark.git
[submodule "test/vendor/googletest"]
path = third_party/googletest
url = https://github.com/matazure/googletest.git
[submodule "third_party/stb"]
path = third_party/stb
url = https://github.com/nothings/stb.git
113 changes: 11 additions & 102 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,117 +1,26 @@
cmake_minimum_required(VERSION 3.8)
#cuda need 3.8
#add_link_options need 3.13
cmake_minimum_required(VERSION 3.14)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# using Clang
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
endif()

project(Matazure.Tensor CXX)
project(MTensor CXX)

if (NOT CXX_STANDARD)
set(CXX_STANDARD 11)
endif()

set(CMAKE_CXX_STANDARD ${CXX_STANDARD})
set(CUDA_STANDARD ${CXX_STANDARD})
set(CMAKE_CXX_EXTENSIONS ON)
set(CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD})
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

option(WITH_OPENCL "With OpenCL" OFF)
if (WITH_OPENCL)
find_package(OPENCL REQUIRED)
endif()

option(WITH_CUDA "With CUDA" OFF)
if(WITH_CUDA)
if (MSVC)
#use yourself nvcc version
set(CMAKE_CUDA_COMPILER "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/bin/nvcc.exe")
endif()
include(CheckLanguage)
check_language(CUDA)

if (CMAKE_CUDA_COMPILER)
enable_language(CUDA)
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr -arch=sm_75")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -w")

if (CUDA_ARCH)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=${CUDA_ARCH}")
endif()

endif()

option(WITH_OPENMP "With OpenMP" OFF)
if(WITH_OPENMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler \"-fopenmp\"")
# need manully set link options
# add_link_options($<$<COMPILE_LANGUAGE:CUDA>:-lgomp>)
set(MTENSOR_CUDA_LINK_FLAGS "${LINK_FLAGS} -lgomp")
set(WITH_CUDA ON)
set(CMAKE_CUDA_ARCHITECTURES OFF)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr")
endif()

option(NATIVE "-march=native" OFF)
if (NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler \"-march=native\"")
endif()

option(BUILD_EXAMPLE "Build Example" ON)
option(BUILD_TEST "Build Test" ON)
option(BUILD_BENCHMARK "Build Benchmark" ON)

message("current compiler is ${CMAKE_CXX_COMPILER}")

set_property( GLOBAL PROPERTY USE_FOLDERS ON)


if (WITH_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
endif()

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

option(DOWNLOAD_SUBMODULES "git submodule update --init ." ON)

if (DOWNLOAD_SUBMODULES)
execute_process(COMMAND git submodule update --init . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include)

set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Build gtest's sample programs." FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)

add_library(mtensor INTERFACE)
target_include_directories(mtensor
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
INTERFACE $<INSTALL_INTERFACE:include>
)

if (BUILD_EXAMPLE)
add_subdirectory(sample)
endif()

if (BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()

if (BUILD_TEST)
add_subdirectory(test)
endif()

install(DIRECTORY include DESTINATION include)
add_subdirectory(samples)
Loading

0 comments on commit 1b63379

Please sign in to comment.