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
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
- name: Checkpout repository
uses: actions/checkout@v4
- name: Initialize Environment
uses: ROOT-Sim/ci-actions/init@v1.5.3
uses: ROOT-Sim/ci-actions/init@030cae234d9698712812e888d0d9d13ca8e1814f
- name: Build & Test
uses: ROOT-Sim/ci-actions/cmake@v1.5.3
uses: ROOT-Sim/ci-actions/cmake@030cae234d9698712812e888d0d9d13ca8e1814f
with:
build-dir: ${{ runner.workspace }}/build
cc: ${{ matrix.compiler }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Fetch ROOT-Sim repository
uses: actions/checkout@v4
- name: Initialize Environment
uses: ROOT-Sim/ci-actions/init@v1.5.3
uses: ROOT-Sim/ci-actions/init@030cae234d9698712812e888d0d9d13ca8e1814f
- name: Build & Test
uses: ROOT-Sim/ci-actions/cmake@v1.5.3
uses: ROOT-Sim/ci-actions/cmake@030cae234d9698712812e888d0d9d13ca8e1814f
with:
build-dir: ${{ runner.workspace }}/build
cc: gcc
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
with:
languages: ${{ matrix.language }}
- name: Initialize Environment
uses: ROOT-Sim/ci-actions/init@v1.5.3
uses: ROOT-Sim/ci-actions/init@030cae234d9698712812e888d0d9d13ca8e1814f
- name: Build & Test
uses: ROOT-Sim/ci-actions/cmake@v1.5.3
uses: ROOT-Sim/ci-actions/cmake@030cae234d9698712812e888d0d9d13ca8e1814f
with:
build-dir: ${{ runner.workspace }}/build
cc: clang
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/doc_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Initialize Environment
uses: ROOT-Sim/ci-actions/init@v1.5.3
uses: ROOT-Sim/ci-actions/init@030cae234d9698712812e888d0d9d13ca8e1814f
- name: Generate Documentation
uses: ROOT-Sim/ci-actions/docs@v1.5.3
uses: ROOT-Sim/ci-actions/docs@030cae234d9698712812e888d0d9d13ca8e1814f
with:
docs-target: rscore-doc
- name: Documentation Coverage
uses: ROOT-Sim/ci-actions/docs-coverage@v1.5.3
uses: ROOT-Sim/ci-actions/docs-coverage@030cae234d9698712812e888d0d9d13ca8e1814f
with:
build-path: docs
- name: Comment PR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
- name: Checkpout repository
uses: actions/checkout@v4
- name: REUSE check
uses: ROOT-Sim/ci-actions/reuse-check@v1.5.3
uses: ROOT-Sim/ci-actions/reuse-check@030cae234d9698712812e888d0d9d13ca8e1814f
2 changes: 1 addition & 1 deletion .github/workflows/update-copyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Update copyright
uses: ROOT-Sim/ci-actions/update-copyright@v1.6
uses: ROOT-Sim/ci-actions/update-copyright@030cae234d9698712812e888d0d9d13ca8e1814f
with:
branch-to-update: develop
6 changes: 3 additions & 3 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ event. Representation of a project may be further defined and clarified by proje
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
pellegrini@diag.uniroma1.it. The project team will review and investigate all complaints, and will respond in a way that
it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the
reporter of an incident. Further details of specific enforcement policies may be posted separately.
a.pellegrini@ing.uniroma2.it. The project team will review and investigate all complaints, and will respond in a way
that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard
to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.
Expand Down
8 changes: 5 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ set(rscore_srcs
log/stats.c
lp/lp.c
lp/process.c
mm/auto_ckpt.c
mm/checkpoint/autonomic.c
mm/checkpoint/full.c
mm/checkpoint/incremental.c
mm/buddy/buddy.c
mm/buddy/ckpt.c
mm/buddy/multi.c
mm/buddy/checkpoint.c
mm/model_allocator.c
mm/msg_allocator.c
parallel/parallel.c
serial/serial.c)
Expand Down
87 changes: 77 additions & 10 deletions src/ROOT-Sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/
#pragma once

#include <limits.h>
#include <float.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -68,7 +66,12 @@ typedef void (*ProcessEvent_t)(lp_id_t me, simtime_t now, unsigned event_type, c
*/
typedef bool (*CanEnd_t)(lp_id_t me, const void *snapshot);

enum rootsim_event {LP_INIT = 65534, LP_FINI};
/// @brief Internal event types used by the simulation kernel.
///
/// These event types are automatically scheduled to the model according to the following logic:
/// - `LP_INIT`: Represents the initialization event for a logical process.
/// - `LP_FINI`: Represents the finalization event for a logical process.
enum rootsim_event { LP_INIT = 65534, LP_FINI };

/**
* @brief API to inject a new event in the simulation
Expand All @@ -88,19 +91,83 @@ extern void ScheduleNewEvent(lp_id_t receiver, simtime_t timestamp, unsigned eve

extern void SetState(void *new_state);

/**
* @brief Allocates rollbackable memory
*
* This function is part of the custom memory management system and is used to allocate
* memory dynamically. The allocated memory is not initialized. Upon a rollback, the previous
* content of the allocated memory buffer is restored to the previous (consistent) content.
*
* @param req_size The size of the memory block to allocate, in bytes.
* @return A pointer to the allocated memory block, or `NULL` if the allocation fails.
*
* @note If `req_size` is 0, the function returns `NULL`.
* @warning The returned memory _must_ be freed using `rs_free()`.
*/
extern void *rs_malloc(size_t req_size);

/**
* @brief Allocates and zero-initializes rollbackable memory
*
* This function is part of the custom memory management system and is used to allocate
* memory dynamically. The allocated memory is initialized to zero. Upon a rollback, the
* previous content of the allocated memory buffer is restored to the previous (consistent) content.
*
* @param nmemb The number of elements to allocate.
* @param size The size of each element, in bytes.
* @return A pointer to the allocated memory block, or `NULL` if the allocation fails.
*
* @note If `nmemb` or `size` is 0, the function returns `NULL`.
* @warning The returned memory _must_ be freed using `rs_free()`.
*/
extern void *rs_calloc(size_t nmemb, size_t size);

/**
* @brief Frees rollbackable memory
*
* This function is part of the custom memory management system and is used to free
* memory that was previously allocated using `rs_malloc()`, `rs_calloc()`, or `rs_realloc()`.
* Upon a rollback, the memory is restored to its previous (consistent) state. This means that
* also the address of the free'd buffer will be the same. Linked data structures can be therefore
* safely implemented in the model, as internal pointers will be valid after a rollback.
*
* @param ptr A pointer to the memory block to be freed. If `ptr` is `NULL`, no operation is performed.
*
* @warning The memory block must have been allocated using the custom memory management functions.
*/
extern void rs_free(void *ptr);

/**
* @brief Reallocates rollbackable memory
*
* This function is part of the custom memory management system and is used to resize
* a previously allocated memory block. If the reallocation is successful, the content
* of the memory block is preserved up to the minimum of the old and new sizes.
* Upon a rollback, the memory is restored to its previous (consistent) state.
*
* @param ptr A pointer to the memory block to be reallocated. If `ptr` is `NULL`, the function behaves like
* `rs_malloc()`.
* @param req_size The new size of the memory block, in bytes.
* @return A pointer to the reallocated memory block, or `NULL` if the reallocation fails.
*
* @note If `req_size` is 0, the function frees the memory block and returns `NULL`.
* @warning The memory block must have been allocated using the custom memory management functions.
*/
extern void *rs_realloc(void *ptr, size_t req_size);

/**
* @brief Logging levels used by the simulation kernel.
*
* These levels define the verbosity of log messages emitted during the simulation.
*/
enum log_level {
LOG_TRACE, //!< The logging level reserved to very low priority messages
LOG_DEBUG, //!< The logging level reserved to useful debug messages
LOG_INFO, //!< The logging level reserved to useful runtime messages
LOG_WARN, //!< The logging level reserved to unexpected, non deal breaking conditions
LOG_ERROR, //!< The logging level reserved to unexpected, problematic conditions
LOG_FATAL, //!< The logging level reserved to unexpected, fatal conditions
LOG_SILENT //!< Emit no message during the simulation
LOG_TRACE, //!< The logging level reserved for very low priority messages.
LOG_DEBUG, //!< The logging level reserved for useful debug messages.
LOG_INFO, //!< The logging level reserved for useful runtime messages.
LOG_WARN, //!< The logging level reserved for unexpected, non-deal-breaking conditions.
LOG_ERROR, //!< The logging level reserved for unexpected, problematic conditions.
LOG_FATAL, //!< The logging level reserved for unexpected, fatal conditions.
LOG_SILENT //!< Emit no messages during the simulation.
};

/// A set of configurable values used by other modules
Expand Down
4 changes: 2 additions & 2 deletions src/arch/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

void io_local_time_get(char res[IO_TIME_BUFFER_LEN])
{
time_t t = time(NULL);
struct tm *loc_t = localtime(&t);
const time_t t = time(NULL);
const struct tm *loc_t = localtime(&t);
strftime(res, IO_TIME_BUFFER_LEN, "%H:%M:%S", loc_t);
}

Expand Down
6 changes: 3 additions & 3 deletions src/arch/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ enum thread_affinity_error thread_affinity_self_set(unsigned core)
CPU_ZERO(&cpuset);
CPU_SET(i, &cpuset);

pthread_t self = pthread_self();
const pthread_t self = pthread_self();
switch(pthread_setaffinity_np(self, sizeof(cpuset), &cpuset)) {
case 0:
return THREAD_AFFINITY_SUCCESS;
Expand Down Expand Up @@ -128,12 +128,12 @@ unsigned thread_cores_count(void)

#endif

int thread_start(thr_id_t *thr_p, thr_run_fnc t_fnc, void *t_fnc_arg)
int thread_start(thr_id_t *thr_p, const thr_run_fnc t_fnc, void *t_fnc_arg)
{
return -(pthread_create(thr_p, NULL, t_fnc, t_fnc_arg) != 0);
}

int thread_wait(thr_id_t thr, thrd_ret_t *ret)
int thread_wait(const thr_id_t thr, thrd_ret_t *ret)
{
return -(pthread_join(thr, ret) != 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#include <core/core.h>

__thread rid_t rid;
_Thread_local rid_t rid;
nid_t n_nodes = 1;
nid_t nid;

Expand Down
5 changes: 1 addition & 4 deletions src/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#pragma once

#include <float.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>

#include <ROOT-Sim.h>

Expand Down Expand Up @@ -69,7 +66,7 @@ typedef int nid_t;
/// The total number of LPs hosted in the node
extern lp_id_t n_lps_node;
/// The identifier of the thread
extern __thread rid_t rid;
extern _Thread_local rid_t rid;

/// The total number of MPI nodes in the simulation
extern nid_t n_nodes;
Expand Down
2 changes: 1 addition & 1 deletion src/core/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool sync_thread_barrier(void)
bool l;
unsigned r;

static __thread unsigned phase;
static _Thread_local unsigned phase;
static atomic_uint cs[2]; // FIXME: this makes this barrier stateful with respect to the threads used
atomic_uint *c = cs + (phase & 1U);

Expand Down
18 changes: 9 additions & 9 deletions src/datatypes/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* @param self the heap
* @return the highest priority element, cast to const
*/
#define heap_min(self) (*(__typeof(*array_items(self)) *const)array_items(self))
#define heap_min(self) (*(__typeof__(*array_items(self)) *const)array_items(self))

/**
* @brief Insert an element into the heap
Expand All @@ -74,7 +74,7 @@
#define heap_insert(self, cmp_f, elem) \
__extension__({ \
array_reserve(self, 1); \
__typeof(array_count(self)) i = array_count(self)++; \
__typeof__(array_count(self)) i = array_count(self)++; \
__typeof__(array_items(self)) items = array_items(self); \
while(i && cmp_f(elem, items[(i - 1U) / 2U])) { \
items[i] = items[(i - 1U) / 2U]; \
Expand All @@ -97,10 +97,10 @@
#define heap_insert_n(self, cmp_f, ins, n) \
__extension__({ \
array_reserve(self, n); \
__typeof(array_count(self)) j = n; \
__typeof__(array_count(self)) j = n; \
__typeof__(array_items(self)) items = array_items(self); \
while(j--) { \
__typeof(array_count(self)) i = array_count(self)++; \
__typeof__(array_count(self)) i = array_count(self)++; \
while(i && cmp_f((ins)[j], items[(i - 1U) / 2U])) { \
items[i] = items[(i - 1U) / 2U]; \
i = (i - 1U) / 2U; \
Expand All @@ -120,11 +120,11 @@
#define heap_extract(self, cmp_f) \
__extension__({ \
__typeof__(array_items(self)) items = array_items(self); \
__typeof(*array_items(self)) ret = array_items(self)[0]; \
__typeof(*array_items(self)) last = array_pop(self); \
__typeof(array_count(self)) cnt = array_count(self); \
__typeof(array_count(self)) i = 1U; \
__typeof(array_count(self)) j = 0U; \
__typeof__(*array_items(self)) ret = array_items(self)[0]; \
__typeof__(*array_items(self)) last = array_pop(self); \
__typeof__(array_count(self)) cnt = array_count(self); \
__typeof__(array_count(self)) i = 1U; \
__typeof__(array_count(self)) j = 0U; \
while(i < cnt) { \
i += i + 1 < cnt && cmp_f(items[i + 1U], items[i]); \
if(!cmp_f(items[i], last)) \
Expand Down
Loading
Loading