Split sources into src/emu and src/rt

The public includes are now in include/ and in internal includes in
src/include/. The ovni* tools are moved to emu/ovni*.c and liked with
the emu static library.
This commit is contained in:
Rodrigo Arias 2022-12-16 11:56:43 +01:00
parent 877bbcd9de
commit 5404cc5e83
37 changed files with 124 additions and 92 deletions

View File

@ -67,6 +67,7 @@ if (NOT HAVE_CLOCK_GETTIME)
endif() endif()
endif() endif()
add_subdirectory(include)
add_subdirectory(src) add_subdirectory(src)
include(CTest) include(CTest)

6
include/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
# Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
install(FILES ovni.h DESTINATION include)

View File

@ -1,69 +1,13 @@
# Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC) # Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
add_library(ovni SHARED add_subdirectory(include)
ovni.c
parson.c
)
set_target_properties(ovni PROPERTIES add_library(parson STATIC parson.c)
VERSION 1.0.0 target_include_directories(parson PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
SOVERSION 1)
target_include_directories(ovni PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
configure_file("config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" ) configure_file("config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" )
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(ovniemu add_subdirectory(rt)
chan.c add_subdirectory(emu)
emu.c
emu_nosv.c
emu_openmp.c
emu_ovni.c
emu_tampi.c
emu_nodes.c
emu_kernel.c
emu_nanos6.c
emu_task.c
trace.c
ovni.c
parson.c
pcf.c
prv.c
)
add_executable(ovnidump
dump.c
ovni.c
trace.c
parson.c
)
add_executable(ovnisort
sort.c
ovni.c
trace.c
parson.c
)
# Use <PackageName>_ROOT variables if available, commonly used by MPI
# installations
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
find_package(MPI REQUIRED)
if(NOT MPI_USE_RUNPATH)
# Ensure we use RPATH (not RUNPATH) to link with MPI library, so we are
# protected against LD_LIBRARY_PATH overrides.
target_link_options(MPI::MPI_C INTERFACE "LINKER:--disable-new-dtags")
endif()
add_executable(ovnisync ovnisync.c)
target_link_libraries(ovnisync m MPI::MPI_C)
install(TARGETS ovni LIBRARY DESTINATION lib)
install(TARGETS ovniemu ovnidump ovnisync ovnisort RUNTIME DESTINATION bin)
install(FILES ovni.h DESTINATION include)

47
src/emu/CMakeLists.txt Normal file
View File

@ -0,0 +1,47 @@
# Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later
add_library(trace STATIC trace.c)
target_link_libraries(trace parson ovni-static)
add_library(emu STATIC
chan.c
emu.c
nosv.c
openmp.c
ovni.c
tampi.c
nodes.c
kernel.c
nanos6.c
task.c
pcf.c
prv.c
)
include_directories(
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/include"
)
add_executable(ovniemu ovniemu.c)
target_link_libraries(ovniemu emu trace)
add_executable(ovnidump ovnidump.c)
target_link_libraries(ovnidump emu trace)
add_executable(ovnisort ovnisort.c)
target_link_libraries(ovnisort emu trace)
# Use <PackageName>_ROOT variables if available, commonly used by MPI
# installations
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
find_package(MPI REQUIRED)
add_executable(ovnisync ovnisync.c)
target_link_libraries(ovnisync m MPI::MPI_C)
install(TARGETS ovniemu ovnidump ovnisync ovnisort RUNTIME DESTINATION bin)

View File

@ -448,8 +448,8 @@ emu_load_first_events(struct ovni_emu *emu)
} }
} }
static void void
emulate(struct ovni_emu *emu) emu_run(struct ovni_emu *emu)
{ {
emu->nev_processed = 0; emu->nev_processed = 0;
emu_load_first_events(emu); emu_load_first_events(emu);
@ -1001,7 +1001,7 @@ create_pcf_cpus(struct ovni_emu *emu)
} }
} }
static void void
emu_init(struct ovni_emu *emu, int argc, char *argv[]) emu_init(struct ovni_emu *emu, int argc, char *argv[])
{ {
memset(emu, 0, sizeof(*emu)); memset(emu, 0, sizeof(*emu));
@ -1184,7 +1184,7 @@ copy_configs(struct ovni_emu *emu)
} }
} }
static void void
emu_post(struct ovni_emu *emu) emu_post(struct ovni_emu *emu)
{ {
/* Write the PCF files */ /* Write the PCF files */
@ -1197,7 +1197,7 @@ emu_post(struct ovni_emu *emu)
copy_configs(emu); copy_configs(emu);
} }
static void void
emu_destroy(struct ovni_emu *emu) emu_destroy(struct ovni_emu *emu)
{ {
fix_prv_headers(emu); fix_prv_headers(emu);
@ -1248,24 +1248,3 @@ eerr(struct ovni_emu *emu, const char *fmt, ...)
emu->cur_ev->header.clock, emu->cur_ev->header.clock,
emu->cur_thread->tid); emu->cur_thread->tid);
} }
int
main(int argc, char *argv[])
{
struct ovni_emu *emu = malloc(sizeof(struct ovni_emu));
if (emu == NULL) {
perror("malloc");
return 1;
}
emu_init(emu, argc, argv);
err("emulation starts\n");
emulate(emu);
emu_post(emu);
emu_destroy(emu);
err("emulation ends\n");
free(emu);
return 0;
}

View File

@ -578,4 +578,9 @@ struct ovni_ethread *emu_get_thread(struct ovni_eproc *proc, int tid);
void emu_cpu_update_chan(struct ovni_cpu *cpu, struct ovni_chan *cpu_chan); void emu_cpu_update_chan(struct ovni_cpu *cpu, struct ovni_chan *cpu_chan);
void emu_init(struct ovni_emu *emu, int argc, char *argv[]);
void emu_run(struct ovni_emu *emu);
void emu_post(struct ovni_emu *emu);
void emu_destroy(struct ovni_emu *emu);
#endif /* OVNI_EMU_H */ #endif /* OVNI_EMU_H */

View File

@ -6,7 +6,7 @@
#include "chan.h" #include "chan.h"
#include "emu.h" #include "emu.h"
#include "emu_task.h" #include "task.h"
#include "ovni.h" #include "ovni.h"
#include "prv.h" #include "prv.h"

View File

@ -6,7 +6,7 @@
#include "chan.h" #include "chan.h"
#include "emu.h" #include "emu.h"
#include "emu_task.h" #include "task.h"
#include "ovni.h" #include "ovni.h"
#include "prv.h" #include "prv.h"

24
src/emu/ovniemu.c Normal file
View File

@ -0,0 +1,24 @@
#include "emu.h"
#include <stdlib.h>
int
main(int argc, char *argv[])
{
struct ovni_emu *emu = malloc(sizeof(struct ovni_emu));
if (emu == NULL) {
perror("malloc");
return 1;
}
emu_init(emu, argc, argv);
err("emulation starts\n");
emu_run(emu);
emu_post(emu);
emu_destroy(emu);
err("emulation ends\n");
free(emu);
return 0;
}

View File

@ -6,7 +6,7 @@
#include "chan.h" #include "chan.h"
#include "emu.h" #include "emu.h"
#include "emu_task.h" #include "task.h"
#include "ovni.h" #include "ovni.h"
#include "prv.h" #include "prv.h"

View File

@ -0,0 +1,4 @@
# Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")

View File

@ -19,4 +19,4 @@ gettid(void)
#endif /* !__GLIBC_PREREQ(2, 30) */ #endif /* !__GLIBC_PREREQ(2, 30) */
#endif /* defined(__GLIBC__) */ #endif /* defined(__GLIBC__) */
#endif// COMPAT_H #endif /* COMPAT_H */

17
src/rt/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
# Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later
include_directories("${CMAKE_SOURCE_DIR}/src/include")
add_library(ovni SHARED ovni.c)
target_link_libraries(ovni parson)
target_include_directories(ovni PUBLIC "${CMAKE_SOURCE_DIR}/include")
set_target_properties(ovni PROPERTIES
VERSION 1.0.0
SOVERSION 1)
add_library(ovni-static STATIC ovni.c)
target_link_libraries(ovni-static parson)
target_include_directories(ovni-static PUBLIC "${CMAKE_SOURCE_DIR}/include")
install(TARGETS ovni LIBRARY DESTINATION lib)

View File

@ -41,7 +41,7 @@ function(ovni_test source)
"OVNI_NPROCS=${OVNI_TEST_NPROC}") "OVNI_NPROCS=${OVNI_TEST_NPROC}")
list(APPEND OVNI_TEST_ENV list(APPEND OVNI_TEST_ENV
"OVNI_BUILD_DIR=${CMAKE_BINARY_DIR}/src") "OVNI_BUILD_DIR=${CMAKE_BINARY_DIR}/src/emu")
list(APPEND OVNI_TEST_ENV list(APPEND OVNI_TEST_ENV
"OVNI_CURRENT_DIR=${CMAKE_CURRENT_BINARY_DIR}") "OVNI_CURRENT_DIR=${CMAKE_CURRENT_BINARY_DIR}")
@ -53,6 +53,11 @@ function(ovni_test source)
list(APPEND OVNI_TEST_ENV "OVNI_DO_SORT=1") list(APPEND OVNI_TEST_ENV "OVNI_DO_SORT=1")
endif() endif()
include_directories(
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/include"
)
add_executable("${OVNI_TEST_NAME}" "${OVNI_TEST_SOURCE}") add_executable("${OVNI_TEST_NAME}" "${OVNI_TEST_SOURCE}")
target_link_libraries("${OVNI_TEST_NAME}" PRIVATE ovni) target_link_libraries("${OVNI_TEST_NAME}" PRIVATE ovni)