Skip to content

Commit

Permalink
Version 2.0 release
Browse files Browse the repository at this point in the history
Co-authored-by: John F. Carr <jfc@mit.edu>
Co-authored-by: Teodoro Fields Collin <teoc@lanka.csail.mit.edu>
Co-authored-by: TB Schardl <neboat@mit.edu>
  • Loading branch information
3 people committed Jul 20, 2022
1 parent 832aeeb commit 73b06fb
Show file tree
Hide file tree
Showing 69 changed files with 3,372 additions and 14,441 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Language: Cpp
IndentWidth: 4
ColumnLimit: 80
UseTab: Never
BreakBeforeBraces: Attach
47 changes: 43 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR CHEETAH_STANDALONE_BUI
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(PACKAGE_NAME Cheetah)
set(PACKAGE_VERSION 12.0.0)
set(PACKAGE_VERSION 14.0.6)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "bugs@opencilk.org")
set(PACKAGE_BUGREPORT "https://github.com/OpenCilk/cheetah/issues/")
endif()

# Require out of source build.
Expand Down Expand Up @@ -58,6 +58,8 @@ option(CHEETAH_ENABLE_SHARED "Build cheetah as a shared library." ON)
option(CHEETAH_ENABLE_STATIC "Build cheetah as a static library." ON)
option(CHEETAH_ENABLE_ASAN "Build cheetah with ASan support." ON)

option(CHEETAH_EMULATE_TLS "Build Cheetah with emulated TLS. Necessary for some JITs." OFF)

set(CHEETAH_ABI_VERSION "1" CACHE STRING "ABI version of cheetah. Defaults to 1.")

if (NOT CHEETAH_ENABLE_SHARED AND NOT CHEETAH_ENABLE_STATIC)
Expand Down Expand Up @@ -109,6 +111,9 @@ if (CHEETAH_STANDALONE_BUILD)
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
set(LLVM_LIT_OUTPUT_DIR "${CHEETAH_EXEC_OUTPUT_DIR}")

# Define llvm-link path
set(LLVM_LINK_PATH "${LLVM_TOOLS_BINARY_DIR}/llvm-link")
endif()

construct_cheetah_default_triple()
Expand All @@ -119,8 +124,13 @@ if ("${CHEETAH_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$")
endif()

set(CHEETAH_C_FLAGS "")
set(CHEETAH_CXX_FLAGS "")
set(CHEETAH_COMPILE_FLAGS "")
if (CHEETAH_EMULATE_TLS)
set(CHEETAH_CXX_FLAGS "-femulated-tls")
set(CHEETAH_COMPILE_FLAGS "-femulated-tls")
else()
set(CHEETAH_CXX_FLAGS "")
set(CHEETAH_COMPILE_FLAGS "")
endif()
set(CHEETAH_COMPILE_DEFS "")
set(CHEETAH_LINK_FLAGS "")
set(CHEETAH_COMMON_LIBS "")
Expand Down Expand Up @@ -187,3 +197,32 @@ if (CHEETAH_INCLUDE_TESTS)
# add_subdirectory(handcomp_test)
# add_subdirectory(bench)
endif()

#===============================================================================
# Setup CMAKE CONFIG PACKAGE
#===============================================================================
make_directory(${CHEETAH_CMAKE_BUILDDIR})
set(CHEETHA_LIBRARY_HOST "/lib/${LLVM_HOST_TARGET}")

if(CHEETAH_INSTALL_LIBRARY)
set(CHEETAH_LIBRARY_DIR "")
if (LLVM_TREE_AVAILABLE)
set(CHEETAH_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/${CHEETAH_LIBRARY_INSTALL_DIR}")
else()
set(CHEETAH_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CilkThreadsConfig.cmake.in
${CHEETAH_CMAKE_BUILDDIR}/CilkThreadsConfig.cmake
NO_SOURCE_PERMISSIONS
@ONLY)
else()
set(CHEETAH_LIBRARY_DIR ${CHEETAH_LIBRARY_OUTPUT_DIR})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CilkThreadsConfig.cmake.in
${CHEETAH_CMAKE_BUILDDIR}/CilkThreadsConfig.cmake
NO_SOURCE_PERMISSIONS
@ONLY)
endif()

install(FILES ${CHEETAH_CMAKE_BUILDDIR}/CilkThreadsConfig.cmake DESTINATION ${CHEETAH_CMAKE_INSTALLDIR})
5 changes: 5 additions & 0 deletions cmake/CilkThreadsConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_library(CilkThreads::Threads INTERFACE IMPORTED)
set_property(TARGET CilkThreads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-lopencilk -lopencilk-personality-cpp -L@CHEETAH_LIBRARY_DIR@@CHEETHA_LIBRARY_HOST@")
set_property(TARGET CilkThreads::Threads
PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:SHELL:-Xcompiler -lopencilk -lopencilk-personality-cpp -L@CHEETAH_LIBRARY_DIR@@CHEETHA_LIBRARY_HOST@>"
"$<$<NOT:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>>:-lopencilk -lopencilk-personality-cpp -L@CHEETAH_LIBRARY_DIR@@CHEETHA_LIBRARY_HOST@>")
4 changes: 2 additions & 2 deletions cmake/Modules/AddCheetah.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ function(add_cheetah_bitcode name)
set(output_file_${libname} lib${output_name_${libname}}.bc)
add_custom_command(
OUTPUT ${output_dir_${libname}}/${output_file_${libname}}
COMMAND cp $<TARGET_OBJECTS:${libname}_compile> ${output_dir_${libname}}/${output_file_${libname}}
COMMAND ${LLVM_LINK_PATH} -o ${output_dir_${libname}}/${output_file_${libname}} $<TARGET_OBJECTS:${libname}_compile>
DEPENDS ${libname}_compile $<TARGET_OBJECTS:${libname}_compile>
COMMENT "Building bitcode ${output_file_${libname}}"
VERBATIM)
VERBATIM COMMAND_EXPAND_LISTS)
add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${output_file_${libname}})
install(FILES ${output_dir_${libname}}/${output_file_${libname}}
DESTINATION ${install_dir_${libname}}
Expand Down
4 changes: 3 additions & 1 deletion cmake/Modules/CheetahUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ macro(load_llvm_config)
endif()
if (LLVM_CONFIG_PATH)
execute_process(
COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root" "--includedir"
COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root" "--includedir" "--host-target"
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE CONFIG_OUTPUT)
if (HAD_ERROR)
Expand All @@ -231,12 +231,14 @@ macro(load_llvm_config)
list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
list(GET CONFIG_OUTPUT 3 MAIN_SRC_DIR)
list(GET CONFIG_OUTPUT 4 INCLUDE_DIR)
list(GET CONFIG_OUTPUT 5 HOST_TARGET)

set(LLVM_BINARY_DIR ${BINARY_DIR} CACHE PATH "Path to LLVM build tree")
set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Paths to LLVM headers")
set(LLVM_HOST_TARGET ${HOST_TARGET} CACHE PATH "Host target from LLVM")

# Detect if we have the LLVMXRay and TestingSupport library installed and
# available from llvm-config.
Expand Down
6 changes: 6 additions & 0 deletions cmake/base-config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
include(CheckIncludeFile)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
include(CMakePushCheckState)

check_include_file(unwind.h HAVE_UNWIND_H)

Expand Down Expand Up @@ -44,6 +45,9 @@ if (LLVM_TREE_AVAILABLE)
set(CHEETAH_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
set(CHEETAH_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
set(CHEETAH_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
set(CHEETAH_CMAKE_BUILDDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/cmake/clang)
set(CHEETAH_CMAKE_INSTALLDIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)

option(CHEETAH_INCLUDE_TESTS "Generate and build cheetah unit tests."
${LLVM_INCLUDE_TESTS})
option(CHEETAH_ENABLE_WERROR "Fail and stop if warning is triggered"
Expand Down Expand Up @@ -71,6 +75,8 @@ else()
"Path where built cheetah executables should be stored.")
set(CHEETAH_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH
"Path where built cheetah libraries should be installed.")
set(CHEETAH_CMAKE_BUILDDIR ${CMAKE_CURRENT_BINARY_DIR}/cmake)
set(CHEETAH_CMAKE_INSTALLDIR ${CMAKE_INSTALL_PREFIX}/cmake)
option(CHEETAH_INCLUDE_TESTS "Generate and build cheetah unit tests." OFF)
option(CHEETAH_ENABLE_WERROR "Fail and stop if warning is triggered" OFF)
# Use a host compiler to compile/link tests.
Expand Down
1 change: 1 addition & 0 deletions cmake/config-ix.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include(CheckLibraryExists)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CMakePushCheckState)

function(check_linker_flag flag out_var)
cmake_push_check_state()
Expand Down
1 change: 1 addition & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RTS_DIR=../runtime
RTS_LIB=libopencilk
RTS_C_PERSONALITY_LIB=libopencilk-personality-c
RTS_CXX_PERSONALITY_LIB=libopencilk-personality-cpp
RTS_PEDIGREE_LIB=libopencilk-pedigrees

# All runtime libraries and associated files will be placed in
# `/oath/to/cheetah/lib/<target-triple>`, so that the compiler can easily find
Expand Down
19 changes: 2 additions & 17 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,8 @@ set(cilk_header_files
cilk/cilk_api.h
cilk/cilk_stub.h
cilk/holder.h
cilk/hyperobject_base.h
cilk/metaprogramming.h
cilk/reducer.h
cilk/reducer_file.h
cilk/reducer_list.h
cilk/reducer_max.h
cilk/reducer_min.h
cilk/reducer_min_max.h
cilk/reducer_opadd.h
cilk/reducer_opand.h
cilk/reducer_opmul.h
cilk/reducer_opor.h
cilk/reducer_opxor.h
cilk/reducer_ostream.h
cilk/reducer_string.h
cilk/reducer_vector.h
)
cilk/opadd_reducer.h
cilk/ostream_reducer.h)

set(output_dir ${CHEETAH_OUTPUT_DIR}/include)
set(out_files)
Expand Down
2 changes: 2 additions & 0 deletions include/cilk/cilk.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
#define cilk_for _Cilk_for
#define cilk_scope _Cilk_scope

#define cilk_reducer _Hyperobject

#endif /* _CILK_H */
18 changes: 15 additions & 3 deletions include/cilk/cilk_api.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef _CILK_API_H
#define _CILK_API_H

#include <stddef.h> /* size_t */

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -11,18 +14,27 @@ extern unsigned __cilkrts_get_nworkers(void);
extern unsigned __cilkrts_get_worker_number(void) __attribute__((deprecated));
extern int __cilkrts_running_on_workers(void);

#if defined(__cilk_pedigrees__) || defined(ENABLE_CILKRTS_PEDIGREE)
#include <inttypes.h>
typedef struct __cilkrts_pedigree {
uint64_t rank;
struct __cilkrts_pedigree *parent;
} __cilkrts_pedigree;
extern __cilkrts_pedigree __cilkrts_get_pedigree(void);
extern void __cilkrts_bump_worker_rank(void);
extern void __cilkrts_dprand_set_seed(uint64_t seed);
extern void __cilkrts_init_dprng(void);
extern uint64_t __cilkrts_get_dprand(void);
#endif // defined(__cilk_pedigrees__) || defined(ENABLE_CILKRTS_PEDIGREE)

#undef VISIBILITY
typedef void (*__cilk_identity_fn)(void *);
typedef void (*__cilk_reduce_fn)(void *, void *);

extern void *__cilkrts_reducer_lookup(void *key);
extern void __cilkrts_reducer_register(void *key, size_t size,
__cilk_identity_fn id,
__cilk_reduce_fn reduce)
__attribute__((deprecated));
extern void __cilkrts_reducer_unregister(void *key)
__attribute__((deprecated));

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 73b06fb

Please sign in to comment.