Commit 50561cb0 authored by Ron Rahaman's avatar Ron Rahaman
Browse files

Merge commit 'f8bf021f' as '3rd_party/occa'

parents 32123c7f f8bf021f
coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
threshold: 0.1%
patch:
default:
threshold: 50%
changes: false
ignore:
- examples
- tests
# Scripts
- scripts
- include/occa/scripts
# Auto-generated files
- include/occa/core/kernelOperators.hpp
- src/core/kernelOperators.cpp
- src/tools/runFunction.cpp
# Exception is not tracked properly
- src/tools/exception.cpp
# Modes that can't be tested with CI
- include/occa/modes/cuda
- include/occa/modes/hip
- include/occa/modes/opencl
- include/occa/modes/metal
- src/modes/cuda
- src/modes/hip
- src/modes/opencl
- src/modes/metal
comment:
layout: 'reach, diff, files'
behavior: default
require_changes: false
require_base: no
require_head: yes
branches: null
<!-- Thank you for contributing!! :) -->
### Bug Report
What is the bug?
### How to Reproduce
```cpp
Code snippet
```
and/or
[Link to code](https://github.com/libocca/occa)
### Device info
Output from `occa info`
```cpp
> occa info
========+======================+==========================================
CPU(s) | Processor Name | Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
| Cores | 4
| Memory (RAM) | 4 GB
| Clock Frequency | 1.4 GHz
| SIMD Instruction Set | SSE4
| SIMD Width | 128 bits
| L1 Cache Size (d) | 32 KB
| L2 Cache Size | 256 KB
| L3 Cache Size | 3 MB
========+======================+==========================================
OpenCL | Device Name | Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
| Driver Vendor | Intel
| Platform ID | 0
| Device ID | 0
| Memory | 4 GB
|----------------------+------------------------------------------
| Device Name | HD Graphics 5000
| Driver Vendor | Intel
| Platform ID | 0
| Device ID | 1
| Memory | 1.50 GB
========+======================+==========================================
```
### Notes
Additional notes about the problem
<!-- Thank you for contributing!! :) -->
### Feature Request
Idea for the feature request
---
**Why do you want this feature?***
Mention if it makes your life easier or solves an existing issue
**(Optional) Propose a solution**
If you have an idea in mind, feel free to propose a solution
**Notes**
Additional notes
## Description
<!-- Thank you for contributing! -->
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
run:
strategy:
matrix:
include:
- name: (Ubuntu) gcc-8
os: ubuntu-18.04
CC: gcc-8
CXX: g++-8
CXXFLAGS: -Wno-maybe-uninitialized
FC: gfortran-8
GCOV: gcov-8
OCCA_COVERAGE: 1
OCCA_FORTRAN_ENABLED: 1
- name: (Ubuntu) gcc-9
os: ubuntu-18.04
CC: gcc-9
CXX: g++-9
CXXFLAGS: -Wno-maybe-uninitialized
FC: gfortran-9
GCOV: gcov-9
OCCA_COVERAGE: 1
OCCA_FORTRAN_ENABLED: 1
- name: (Ubuntu) clang-6
os: ubuntu-18.04
CC: clang-6.0
CXX: clang++-6.0
CXXFLAGS: -Wno-uninitialized
OCCA_COVERAGE: 0
- name: (Ubuntu) clang-9
os: ubuntu-18.04
CC: clang-9
CXX: clang++-9
CXXFLAGS: -Wno-uninitialized
OCCA_COVERAGE: 0
- name: (MacOS) gcc-9
os: macos-10.15
CC: gcc-9
CXX: g++-9
CXXFLAGS: -Wno-maybe-uninitialized
GCOV: gcov-9
OCCA_COVERAGE: 1
- name: (MacOS) clang
os: macos-10.15
CC: clang
CXX: clang++
CXXFLAGS: -Wno-uninitialized
OCCA_COVERAGE: 0
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
CXXFLAGS: -O3 -Wall -pedantic -Wshadow -Wsign-compare -Wuninitialized -Wtype-limits -Wignored-qualifiers -Wempty-body -Wextra -Wno-unused-parameter -Werror -Wno-strict-aliasing ${{ matrix.CXXFLAGS }}
FC: ${{ matrix.FC }}
GCOV: ${{ matrix.GCOV }}
OCCA_COVERAGE: ${{ matrix.OCCA_COVERAGE }}
OCCA_FORTRAN_ENABLED: ${{ matrix.OCCA_FORTRAN_ENABLED }}
OCCA_CXXFLAGS: -O3
FORTRAN_EXAMPLES: ${{ matrix.OCCA_FORTRAN_ENABLED }}
steps:
- uses: actions/checkout@v2
- name: Compiler info
run: make -j 16 info
- name: Compile library
run: make -j 16
- name: Compile tests
run: make -j 16 tests
- name: Run unit tests
run: ./tests/run_tests
- name: Run examples
run: ./tests/run_examples
- name: Upload code coverage
run: bash <(curl --no-buffer -s https://codecov.io/bash) -x "${GCOV}"
if: ${{ matrix.OCCA_COVERAGE }}
# Git
.gitattributes
# Build artifacts
*.obj
*.pyc
lib/
obj/
main
opt/
# CMake
build/
# Bin
bin/
!bin/occa.cpp
# Auto-generated code
.compiledDefines
include/occa/defines/compiledDefines.hpp
include/occa/scripts
# Debug
.DS_Store
*.dSYM
# Coverage
*.gcno
*.gcda
*.gcov
coverage*
# Visual Studio
editorTools/visualStudio/*
!editorTools/visualStudio/occa.sln
!editorTools/visualStudio/occa.vcxproj
!editorTools/visualStudio/occa.vcxproj.filters
cmake_minimum_required (VERSION 3.12 FATAL_ERROR)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
message(STATUS "Using CMake version ${CMAKE_VERSION}")
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0056 NEW)
# Set project
project (occa
DESCRIPTION "JIT Compilation for Multiple Architectures: C++, OpenMP, CUDA, HIP, OpenCL, Metal"
HOMEPAGE_URL "https://github.com/libocca/occa"
LANGUAGES C CXX)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(ENABLE_OPENMP "Build with OpenMP if available" ON)
option(ENABLE_CUDA "Build with CUDA if available" ON)
option(ENABLE_OPENCL "Build with OpenCL if available" ON)
option(ENABLE_HIP "Build with HIP if available" ON)
option(ENABLE_METAL "Build with Metal if available" ON)
#option(ENABLE_ONEAPI "Build with OneAPI if available" ON)
option(ENABLE_MPI "Build with MPI if available" ON)
option(ENABLE_TESTS "Build tests" OFF)
option(ENABLE_EXAMPLES "Build simple examples" OFF)
option(ENABLE_UTILITY "Build occa utility binary" ON)
option(ENABLE_FORTRAN "Enable Fortran interface" OFF)
if (ENABLE_FORTRAN)
enable_language(Fortran)
endif()
set(OCCA_USING_VS OFF)
set(OCCA_UNSAFE OFF)
# Test Apple first because UNIX==true for Apple and Linux.
if (APPLE)
set(OCCA_OS "OCCA_MACOS_OS")
elseif (UNIX)
set(OCCA_OS "OCCA_LINUX_OS")
else()
set(OCCA_OS "OCCA_WINDOWS_OS")
endif()
include(SetCompilerFlags)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
message("-- System: ${CMAKE_SYSTEM}")
message("-- Build type: ${CMAKE_BUILD_TYPE}")
message("-- C flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
message("-- CXX flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
if (ENABLE_FORTRAN)
message("-- Fortran flags: ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
endif()
set(OCCA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(OCCA_BUILD_DIR ${CMAKE_BINARY_DIR})
if (ENABLE_FORTRAN)
set (CMAKE_Fortran_MODULE_DIRECTORY ${OCCA_BUILD_DIR}/mod)
endif()
##############################
# LibOCCA Target
##############################
add_library(libocca SHARED)
# Without this, CMake will create liblibocca.so
set_target_properties(libocca PROPERTIES OUTPUT_NAME occa LIBRARY_OUTPUT_DIRECTORY ${OCCA_BUILD_DIR}/lib)
#Find needed and requested packages
find_package(Threads REQUIRED)
target_link_libraries(libocca PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
target_include_directories(libocca PUBLIC
$<BUILD_INTERFACE:${OCCA_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${OCCA_BUILD_DIR}/include>)
target_compile_definitions(libocca PRIVATE -DUSE_CMAKE)
##############################
# OpenMP
##############################
if (ENABLE_OPENMP)
find_package(OpenMP)
if (OPENMP_CXX_FOUND)
set(OCCA_OPENMP_ENABLED 1)
message("-- OpenMP include dirs: ${OpenMP_CXX_INCLUDE_DIRS}")
message("-- OpenMP libraries: ${OpenMP_CXX_LIBRARIES}")
target_include_directories(libocca PRIVATE ${OpenMP_CXX_INCLUDE_DIRS})
target_link_libraries(libocca PRIVATE ${OpenMP_CXX_LIBRARIES})
else(OPENMP_CXX_FOUND)
set(OCCA_OPENMP_ENABLED 0)
endif(OPENMP_CXX_FOUND)
endif(ENABLE_OPENMP)
##############################
# CUDA
##############################
if (ENABLE_CUDA)
find_package(CUDA)
if (CUDA_FOUND)
set(OCCA_CUDA_ENABLED 1)
#find the shared library, rather than the static that find_package returns
find_library(
CUDA_LIB
NAMES cuda
PATHS
${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib64 lib lib64/stubs lib/stubs
DOC "CUDA driver lib location"
)
message("-- CUDA include dirs: ${CUDA_INCLUDE_DIRS}")
message("-- CUDA driver library: ${CUDA_LIB}")
target_include_directories(libocca PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(libocca PRIVATE ${CUDA_LIB})
else (CUDA_FOUND)
set(OCCA_CUDA_ENABLED 0)
endif(CUDA_FOUND)
endif(ENABLE_CUDA)
##############################
# OpenCL
##############################
if (ENABLE_OPENCL)
#Look in some default places for OpenCL and set OPENCL_ROOT
# Search in user specified path first
find_path(
OPENCL_ROOT
NAMES include/CL/cl.h
PATHS
ENV OPENCL_PATH
DOC "OPENCL root location"
NO_DEFAULT_PATH
)
# Now search in default path
find_path(
OPENCL_ROOT
NAMES include/CL/cl.h
PATHS
/usr/
/opt/rocm/opencl
/usr/local/cuda
DOC "OPENCL root location"
)
#Trick cmake's default OpenCL module to look in our directory
set(ENV{AMDAPPSDKROOT} ${OPENCL_ROOT})
find_package(OpenCL)
if (OpenCL_FOUND)
set(OCCA_OPENCL_ENABLED 1)
message("-- OpenCL include dirs: ${OpenCL_INCLUDE_DIRS}")
message("-- OpenCL libraries: ${OpenCL_LIBRARIES}")
target_include_directories(libocca PRIVATE ${OpenCL_INCLUDE_DIRS})
target_link_libraries(libocca PRIVATE ${OpenCL_LIBRARIES})
else (OpenCL_FOUND)
set(OCCA_OPENCL_ENABLED 0)
endif(OpenCL_FOUND)
endif(ENABLE_OPENCL)
##############################
# HIP
##############################
if (ENABLE_HIP)
find_package(HIP)
if (HIP_FOUND)
set(OCCA_HIP_ENABLED 1)
message("-- HIP version: ${HIP_VERSION_STRING}")
message("-- HIP platform: ${HIP_PLATFORM}")
message("-- HIP include dirs: ${HIP_INCLUDE_DIRS}")
message("-- HIP libraries: ${HIP_LIBRARIES}")
target_compile_definitions(libocca PRIVATE -D${HIP_RUNTIME_DEFINE})
target_include_directories(libocca PRIVATE ${HIP_INCLUDE_DIRS})
target_link_libraries(libocca PRIVATE ${HIP_LIBRARIES})
else (HIP_FOUND)
set(OCCA_HIP_ENABLED 0)
endif(HIP_FOUND)
endif(ENABLE_HIP)
##############################
# Metal
##############################
if (ENABLE_METAL AND APPLE)
find_library(METAL_LIBRARY Metal)
find_library(CORE_SERVICES CoreServices)
find_library(APP_KIT AppKit)
if (METAL_LIBRARY AND CORE_SERVICES AND APP_KIT)
set(OCCA_METAL_ENABLED 1)
else()
set(OCCA_METAL_ENABLED 0)
endif()
endif()
##############################
# MPI
##############################
if (ENABLE_MPI)
find_package(MPI)
if (MPI_FOUND)
set(OCCA_MPI_ENABLED 1)
message("-- MPI include dirs: ${MPI_CXX_INCLUDE_DIRS}")
message("-- MPI libraries: ${MPI_CXX_LIBRARIES}")
message("-- MPI link flags: ${MPI_CXX_LINK_FLAGS}")
message("-- MPI executable: ${MPIEXEC_EXECUTABLE}")
message("-- MPI numproc flag: ${MPIEXEC_NUMPROC_FLAG}")
target_include_directories(libocca PUBLIC ${MPI_CXX_INCLUDE_DIRS})
target_link_libraries(libocca PUBLIC ${MPI_CXX_LIBRARIES})
else(MPI_FOUND)
set(OCCA_MPI_ENABLED 0)
endif(MPI_FOUND)
endif(ENABLE_MPI)
#Generate CompiledDefines from libraries we found
configure_file(scripts/compiledDefinesTemplate.hpp.in ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp)
install(FILES ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp DESTINATION include/occa/defines)
#Find source files
file(GLOB_RECURSE OCCA_SRC_cpp RELATIVE ${OCCA_SOURCE_DIR} "src/*.cpp")
list(REMOVE_ITEM OCCA_SRC_cpp src/core/kernelOperators.cpp src/tools/runFunction.cpp)
if (OCCA_OPENMP_ENABLED)
set_source_files_properties(${OCCA_SRC_cpp} PROPERTIES COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
endif()
if (ENABLE_FORTRAN)
file(GLOB_RECURSE OCCA_SRC_Fortran RELATIVE ${OCCA_SOURCE_DIR} "src/*.f90")
if (OCCA_OPENMP_ENABLED)
set_source_files_properties(${OCCA_SRC_Fortran} PROPERTIES COMPILE_FLAGS ${OpenMP_Fortran_FLAGS})
endif()
install (CODE "file(GLOB public-modules ${CMAKE_Fortran_MODULE_DIRECTORY}/*.mod)\n
file(INSTALL DESTINATION ${CMAKE_INSTALL_PREFIX}/include TYPE FILE FILES \${public-modules})")
set_target_properties(libocca PROPERTIES LINKER_LANGUAGE C)
endif()
if (OCCA_METAL_ENABLED)
file(GLOB_RECURSE OCCA_SRC_metal RELATIVE ${OCCA_SOURCE_DIR} "src/*.mm")
endif()
set(OCCA_SRC ${OCCA_SRC_cpp} ${OCCA_SRC_Fortran} ${OCCA_SRC_metal})
target_sources(libocca PRIVATE ${OCCA_SRC})
install(TARGETS libocca DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
if (ENABLE_TESTS)
include(CTest)
add_subdirectory(tests)
endif(ENABLE_TESTS)
if (ENABLE_EXAMPLES)
add_subdirectory(examples)
endif(ENABLE_EXAMPLES)
if (ENABLE_UTILITY)
add_subdirectory(bin)
endif(ENABLE_UTILITY)
The MIT License (MIT)
Copyright (c) 2014-2019 David Medina and Tim Warburton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
rmSlash = $(patsubst %/,%,$1)
OCCA_DIR := $(call rmSlash,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
PROJ_DIR := $(OCCA_DIR)
# Clear the list of suffixes
.SUFFIXES:
.SUFFIXES: .hpp .h .tpp .cpp .mm .o .so .dylib
# Cancel some implicit rules
%: %.o
%.o: %.cpp
%: %.cpp
%: %.mm
include $(OCCA_DIR)/scripts/Makefile
#---[ Working Paths ]-----------------------------
ifeq ($(usingWinux),0)
compilerFlags += $(picFlag)
fCompilerFlags += $(picFlag)
else
sharedFlag += $(picFlag)
endif
# [-L$OCCA_DIR/lib -locca] are kept for applications
# using $OCCA_DIR/scripts/Makefile
paths += -I$(srcPath)
paths := $(filter-out -L$(OCCA_DIR)/lib,$(paths))
linkerFlags := $(filter-out -locca,$(linkerFlags))
ifeq (${PREFIX},)
OCCA_BUILD_DIR := $(OCCA_DIR)
else
OCCA_BUILD_DIR := ${PREFIX}
endif
#=================================================
#---[ Flags ]-------------------------------------
# Expand and overwrite flag variables to avoid
# multiple expansions which are slow.
compilerFlags := $(compilerFlags)
flags := $(flags)
sharedFlag := $(sharedFlag)
pthreadFlag := $(pthreadFlag)
#=================================================