Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
],
"cacheVariables": {
"TYPEART_ASAN": "OFF",
"TYPEART_UBSAN": "OFF"
"TYPEART_UBSAN": "OFF",
"TYPEART_CI_RUN": "ON"
}
},
{
Expand Down
3 changes: 3 additions & 0 deletions cmake/typeartToolchainOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ mark_as_advanced(TYPEART_CONFIG_DIR_IS_SHARE)
option(TYPEART_USE_LEGACY_WRAPPER "Use the old TypeART compiler wrapper" OFF)
# mark_as_advanced(TYPEART_USE_NEW_PASSMANAGER)

option(TYPEART_INSTALL_TYPES_LIB "Install types library" OFF)
option(TYPEART_INSTALL_SYSTEM_LIB "Install system library" OFF)

# if(LLVM_VERSION_MAJOR VERSION_GREATER_EQUAL "18")
# set(TYPEART_USE_NEW_PASSMANAGER ON CACHE BOOL ON FORCE)
# endif()
Expand Down
2 changes: 1 addition & 1 deletion lib/mpi_interceptor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set_property(TARGET ${TYPEART_PREFIX}_MPITool PROPERTY C_STANDARD_REQUIRED TRUE)
typeart_target_define_file_basename(${TYPEART_PREFIX}_MPITool)

target_include_directories(${TYPEART_PREFIX}_MPITool ${warning_guard}
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/runtime>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
)
Expand Down
30 changes: 18 additions & 12 deletions lib/mpi_interceptor/InterceptorFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#ifndef TEST_MPI_INTERCEPTOR_INTERCEPTORFUNCTIONS_H_
#define TEST_MPI_INTERCEPTOR_INTERCEPTORFUNCTIONS_H_

#include "runtime/RuntimeInterface.h"
#include "RuntimeExport.h"
#include "RuntimeInterface.h"

#include <mpi.h>
#include <stdatomic.h>
Expand All @@ -22,8 +23,9 @@
#include <sys/resource.h>
#include <sys/time.h>

int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count, int const_adr);
void ta_print_loc(const void* call_adr);
TYPEART_NO_EXPORT int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count,
int const_adr);
TYPEART_NO_EXPORT void ta_print_loc(const void* call_adr);

typedef struct CallCounter {
_Atomic size_t send;
Expand All @@ -42,31 +44,34 @@ typedef struct MPISemCounter {

static MPICounter mcounter = {0, 0, 0};

void ta_check_send(const char* name, const void* called_from, const void* sendbuf, int count, MPI_Datatype dtype) {
TYPEART_NO_EXPORT void ta_check_send(const char* name, const void* called_from, const void* sendbuf, int count,
MPI_Datatype dtype) {
++counter.send;
ta_check_buffer(name, called_from, sendbuf, count, 1);
}

void ta_check_recv(const char* name, const void* called_from, void* recvbuf, int count, MPI_Datatype dtype) {
TYPEART_NO_EXPORT void ta_check_recv(const char* name, const void* called_from, void* recvbuf, int count,
MPI_Datatype dtype) {
++counter.recv;
ta_check_buffer(name, called_from, recvbuf, count, 0);
}

void ta_check_send_and_recv(const char* name, const void* called_from, const void* sendbuf, int sendcount,
MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype) {
TYPEART_NO_EXPORT void ta_check_send_and_recv(const char* name, const void* called_from, const void* sendbuf,
int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype) {
++counter.send_recv;
ta_check_send(name, called_from, sendbuf, sendcount, sendtype);
ta_check_recv(name, called_from, recvbuf, recvcount, recvtype);
}

void ta_unsupported_mpi_call(const char* name, const void* called_from) {
TYPEART_NO_EXPORT void ta_unsupported_mpi_call(const char* name, const void* called_from) {
++counter.unsupported;
fprintf(stderr, "[Error] The MPI function %s is currently not checked by TypeArt", name);
ta_print_loc(called_from);
// exit(0);
}

const char* ta_get_error_message(typeart_status status) {
TYPEART_NO_EXPORT const char* ta_get_error_message(typeart_status status) {
switch (status) {
case TYPEART_OK:
return "No errors";
Expand All @@ -85,7 +90,8 @@ const char* ta_get_error_message(typeart_status status) {
}
}

int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count, int const_adr) {
TYPEART_NO_EXPORT int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count,
int const_adr) {
if (mpi_count <= 0) {
++mcounter.null_count;
return 1;
Expand Down Expand Up @@ -119,7 +125,7 @@ int ta_check_buffer(const char* mpi_name, const void* called_from, const void* b
return 1;
}

void ta_print_loc(const void* call_adr) {
TYPEART_NO_EXPORT void ta_print_loc(const void* call_adr) {
const char* exe = getenv("TYPEART_EXE_TARGET");
if (exe == NULL || exe[0] == '\0') {
return;
Expand All @@ -138,7 +144,7 @@ void ta_print_loc(const void* call_adr) {
}
}

void ta_exit() {
TYPEART_NO_EXPORT void ta_exit() {
// Called at MPI_Finalize time
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
Expand Down
40 changes: 38 additions & 2 deletions lib/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@ set_target_properties(
)
add_library(typeart::Runtime ALIAS ${TYPEART_PREFIX}_Runtime)

include(GenerateExportHeader)
generate_export_header(${TYPEART_PREFIX}_Runtime
BASE_NAME TYPEART
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/RuntimeExport.h"
)

set_target_properties(${TYPEART_PREFIX}_Runtime PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)

if(UNIX AND NOT APPLE)
set(LINKER_MAP_CONTENTS
[=[{
global:
typeart_*;
__typeart_*;
local:
*;
};]=])

set(RUNTIME_MAP_FILE "${CMAKE_CURRENT_BINARY_DIR}/Runtime.map")
file(WRITE "${RUNTIME_MAP_FILE}" "${LINKER_MAP_CONTENTS}")

target_link_options(${TYPEART_PREFIX}_Runtime PRIVATE
"-Wl,--version-script,${RUNTIME_MAP_FILE}"
)

set_target_properties(${TYPEART_PREFIX}_Runtime PROPERTIES
LINK_DEPENDS "${RUNTIME_MAP_FILE}"
)
endif()

target_link_libraries(
${TYPEART_PREFIX}_Runtime
PRIVATE typeart::TypesStatic
Expand All @@ -59,6 +92,7 @@ target_include_directories(
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/runtime>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/typelib>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/passes/support>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
)
Expand Down Expand Up @@ -97,8 +131,10 @@ make_tidy_check(${TYPEART_PREFIX}_Runtime "${RUNTIME_LIB_SOURCES}")
set(CONFIG_NAME ${PROJECT_NAME}Runtime)
set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets)

install(FILES RuntimeInterface.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
install(FILES
RuntimeInterface.h
"${CMAKE_CURRENT_BINARY_DIR}/RuntimeExport.h"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)

install(
Expand Down
32 changes: 17 additions & 15 deletions lib/runtime/CallbackInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#ifndef TYPEART_CALLBACKINTERFACE_H
#define TYPEART_CALLBACKINTERFACE_H

#include "RuntimeExport.h"

#ifdef __cplusplus
#include <cstddef>
#else
Expand All @@ -23,28 +25,28 @@
#ifdef __cplusplus
extern "C" {
#endif
void __typeart_alloc(const void* addr, int type_id, size_t count);
TYPEART_EXPORT void __typeart_alloc(const void* addr, int type_id, size_t count);

void __typeart_alloc_global(const void* addr, int type_id, size_t count);
void __typeart_free(const void* addr);
TYPEART_EXPORT void __typeart_alloc_global(const void* addr, int type_id, size_t count);
TYPEART_EXPORT void __typeart_free(const void* addr);

void __typeart_alloc_stack(const void* addr, int type_id, size_t count);
void __typeart_leave_scope(int alloca_count);
TYPEART_EXPORT void __typeart_alloc_stack(const void* addr, int type_id, size_t count);
TYPEART_EXPORT void __typeart_leave_scope(int alloca_count);

// Called from OpenMP context
void __typeart_alloc_omp(const void* addr, int type_id, size_t count);
void __typeart_free_omp(const void* addr);
void __typeart_alloc_stack_omp(const void* addr, int type_id, size_t count);
void __typeart_leave_scope_omp(int alloca_count);
TYPEART_EXPORT void __typeart_alloc_omp(const void* addr, int type_id, size_t count);
TYPEART_EXPORT void __typeart_free_omp(const void* addr);
TYPEART_EXPORT void __typeart_alloc_stack_omp(const void* addr, int type_id, size_t count);
TYPEART_EXPORT void __typeart_leave_scope_omp(int alloca_count);

// Called for inlined type definitions mode
void __typeart_alloc_mty(const void* addr, const void* info, size_t count);
void __typeart_alloc_global_mty(const void* addr, const void* info, size_t count);
void __typeart_alloc_stack_mty(const void* addr, const void* info, size_t count);
void __typeart_register_type(const void* type);
TYPEART_EXPORT void __typeart_alloc_mty(const void* addr, const void* info, size_t count);
TYPEART_EXPORT void __typeart_alloc_global_mty(const void* addr, const void* info, size_t count);
TYPEART_EXPORT void __typeart_alloc_stack_mty(const void* addr, const void* info, size_t count);
TYPEART_EXPORT void __typeart_register_type(const void* type);

void __typeart_alloc_global_mty_omp(const void* addr, const void* info, size_t count);
void __typeart_alloc_stack_mty_omp(const void* addr, const void* info, size_t count);
TYPEART_EXPORT void __typeart_alloc_global_mty_omp(const void* addr, const void* info, size_t count);
TYPEART_EXPORT void __typeart_alloc_stack_mty_omp(const void* addr, const void* info, size_t count);
#ifdef __cplusplus
}
#endif
Expand Down
Loading