Skip to content

Commit

Permalink
Merge branch 'main' into rti-DENT
Browse files Browse the repository at this point in the history
  • Loading branch information
byeonggiljun committed Aug 9, 2024
2 parents 34df67b + 7db4930 commit 6e15213
Show file tree
Hide file tree
Showing 30 changed files with 597 additions and 162 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/build-rti.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@ on:
workflow_call:

jobs:
run:
native-build:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
- name: Check out reactor-c repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build the RTI with AUTH=OFF
run: .github/scripts/build-rti.sh -DAUTH=OFF
- name: Build the RTI with AUTH=ON
run: .github/scripts/build-rti.sh -DAUTH=ON

docker-build:
runs-on: ubuntu-latest
steps:
- name: Check out reactor-c repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
file: ./core/federated/RTI/rti.Dockerfile
context: .
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/riscv64
push: false
tags: lflang/rti:latest
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

concurrency:
group: ci-${{ github.ref }}-${{ github.event_path }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
check-labels:
Expand Down Expand Up @@ -97,4 +97,4 @@ jobs:
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
scheduler: ADAPTIVE
all-platforms: ${{ !github.event.pull_request.draft || contains( github.event.pull_request.labels.*.name, 'mac') || contains( github.event.pull_request.labels.*.name, 'windows') }}
if: ${{ !github.event.pull_request.draft || contains( github.event.pull_request.labels.*.name, 'schedulers') }}
if: ${{ !github.event.pull_request.draft || contains( github.event.pull_request.labels.*.name, 'schedulers') }}
26 changes: 14 additions & 12 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include(${LF_ROOT}/core/lf_utils.cmake)
list(APPEND GENERAL_SOURCES tag.c clock.c port.c mixed_radix.c reactor_common.c lf_token.c environment.c)

# Add tracing support if requested
if (DEFINED LF_TRACE)
if(DEFINED LF_TRACE)
message(STATUS "Including sources specific to tracing.")
list(APPEND GENERAL_SOURCES tracepoint.c)
endif()
Expand All @@ -16,7 +16,7 @@ endif()
list(APPEND REACTORC_SOURCES ${GENERAL_SOURCES})

# Add sources for either threaded or single-threaded runtime
if (DEFINED FEDERATED)
if(DEFINED FEDERATED)
include(federated/CMakeLists.txt)
include(federated/network/CMakeLists.txt)
endif()
Expand All @@ -35,14 +35,14 @@ endif()

# Add sources for the local RTI if we are using scheduling enclaves
if(DEFINED LF_ENCLAVES)
include(federated/RTI/local_rti.cmake)
include(federated/RTI/local_rti.cmake)
endif()

# Include sources from subdirectories
include(utils/CMakeLists.txt)

if (DEFINED MODAL_REACTORS)
include(modal_models/CMakeLists.txt)
if(DEFINED MODAL_REACTORS)
include(modal_models/CMakeLists.txt)
endif()

# Print sources used for compilation
Expand All @@ -53,7 +53,7 @@ add_library(reactor-c)
target_sources(reactor-c PRIVATE ${REACTORC_SOURCES})
lf_enable_compiler_warnings(reactor-c)

if (DEFINED LF_TRACE)
if(DEFINED LF_TRACE)
include(${LF_ROOT}/trace/api/CMakeLists.txt)
target_link_libraries(reactor-c PUBLIC lf::trace-api)
# If the user specified an external trace plugin. Find it and link with it
Expand Down Expand Up @@ -106,18 +106,19 @@ target_include_directories(reactor-c PUBLIC ../include/core/threaded)
target_include_directories(reactor-c PUBLIC ../include/core/utils)
target_include_directories(reactor-c PUBLIC federated/RTI/)

if (APPLE)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
if(APPLE)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()

# Link with OpenSSL library
if(DEFINED FEDERATED_AUTHENTICATED)
if (APPLE)
if(APPLE)
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
endif()

find_package(OpenSSL REQUIRED)
target_link_libraries(reactor-c PUBLIC OpenSSL::SSL)
endif()
Expand All @@ -130,10 +131,11 @@ if(DEFINED FEDERATED)
endif()

# Unless specified otherwise initial event queue and reaction queue to size 10
if (NOT DEFINED INITIAL_EVENT_QUEUE_SIZE)
if(NOT DEFINED INITIAL_EVENT_QUEUE_SIZE)
set(INITIAL_EVENT_QUEUE_SIZE 10)
endif()
if (NOT DEFINED INITIAL_REACT_QUEUE_SIZE)

if(NOT DEFINED INITIAL_REACT_QUEUE_SIZE)
set(INITIAL_REACT_QUEUE_SIZE 10)
endif()

Expand Down
5 changes: 4 additions & 1 deletion core/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ static void environment_init_modes(environment_t* env, int num_modes, int num_st
* @brief Initialize the federation-specific parts of the environment struct.
*/
static void environment_init_federated(environment_t* env, int num_is_present_fields) {
#ifdef FEDERATED_DECENTRALIZED
#if defined(FEDERATED_CENTRALIZED)
env->need_to_send_LTC = false;
(void)num_is_present_fields;
#elif defined(FEDERATED_DECENTRALIZED)
if (num_is_present_fields > 0) {
env->_lf_intended_tag_fields = (tag_t**)calloc(num_is_present_fields, sizeof(tag_t*));
LF_ASSERT_NON_NULL(env->_lf_intended_tag_fields);
Expand Down
3 changes: 3 additions & 0 deletions core/federated/RTI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CMakeFiles
Makefile
cmake_install.cmake
17 changes: 13 additions & 4 deletions core/federated/RTI/rti.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Docker file for building the image of the rti
FROM alpine:latest
ARG BASEIMAGE=alpine:latest
FROM ${BASEIMAGE} as builder

Check warning on line 2 in core/federated/RTI/rti.Dockerfile

View workflow job for this annotation

GitHub Actions / build-rti / docker-build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
COPY . /lingua-franca
WORKDIR /lingua-franca/core/federated/RTI
RUN set -ex && apk add --no-cache gcc musl-dev cmake make && \
Expand All @@ -9,5 +9,14 @@ RUN set -ex && apk add --no-cache gcc musl-dev cmake make && \
make && \
make install

# Use ENTRYPOINT not CMD so that command-line arguments go through
ENTRYPOINT ["RTI"]
WORKDIR /lingua-franca

# application stage
FROM ${BASEIMAGE} as app

Check warning on line 15 in core/federated/RTI/rti.Dockerfile

View workflow job for this annotation

GitHub Actions / build-rti / docker-build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
LABEL maintainer="lf-lang"
LABEL source="https://github.com/lf-lang/reactor-c/tree/main/core/federated/RTI"
COPY --from=builder /usr/local/bin/RTI /usr/local/bin/RTI

WORKDIR /lingua-franca

ENTRYPOINT ["/usr/local/bin/RTI"]
2 changes: 1 addition & 1 deletion core/federated/RTI/rti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void _logical_tag_complete(scheduling_node_t* enclave, tag_t completed) {

enclave->completed = completed;

LF_PRINT_LOG("RTI received from federate/enclave %d the latest tag complete (LTC) " PRINTF_TAG ".", enclave->id,
LF_PRINT_LOG("RTI received from federate/enclave %d the latest tag confirmed (LTC) " PRINTF_TAG ".", enclave->id,
enclave->completed.time - start_time, enclave->completed.microstep);

// Check downstream scheduling_nodes to see whether they should now be granted a TAG.
Expand Down
2 changes: 1 addition & 1 deletion core/federated/RTI/rti_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void notify_provisional_tag_advance_grant(scheduling_node_t* e, tag_t tag);
* If M is equal to the NET of the federate, then return PTAG(M).
*
* This should be called whenever an immediately upstream federate sends to
* the RTI an LTC (latest tag complete), or when a transitive upstream
* the RTI an LTC (latest tag confirmed), or when a transitive upstream
* federate sends a NET (Next Event Tag) message.
* It is also called when an upstream federate resigns from the federation.
*
Expand Down
9 changes: 6 additions & 3 deletions core/federated/RTI/rti_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void handle_timed_message(federate_info_t* sending_federate, unsigned char* buff
LF_MUTEX_UNLOCK(&rti_mutex);
}

void handle_latest_tag_complete(federate_info_t* fed) {
void handle_latest_tag_confirmed(federate_info_t* fed) {
unsigned char buffer[sizeof(int64_t) + sizeof(uint32_t)];
read_from_socket_fail_on_error(&fed->socket, sizeof(int64_t) + sizeof(uint32_t), buffer, NULL,
"RTI failed to read the content of the logical tag complete from federate %d.",
Expand Down Expand Up @@ -1139,8 +1139,8 @@ void* federate_info_thread_TCP(void* fed) {
case MSG_TYPE_NEXT_EVENT_TAG:
handle_next_event_tag(my_fed);
break;
case MSG_TYPE_LATEST_TAG_COMPLETE:
handle_latest_tag_complete(my_fed);
case MSG_TYPE_LATEST_TAG_CONFIRMED:
handle_latest_tag_confirmed(my_fed);
break;
case MSG_TYPE_STOP_REQUEST:
handle_stop_request_message(my_fed); // FIXME: Reviewed until here.
Expand Down Expand Up @@ -1227,6 +1227,9 @@ static int32_t receive_and_check_fed_id_message(int* socket_id, struct sockaddr_
// If the connection is a peer-to-peer connection between two
// federates, reject the connection with the WRONG_SERVER error.
send_reject(socket_id, WRONG_SERVER);
} else if (buffer[0] == MSG_TYPE_FED_NONCE) {
send_reject(socket_id, RTI_NOT_EXECUTED_WITH_AUTH);
lf_print_error("RTI not executed with HMAC authentication option using -a or --auth.");
} else {
send_reject(socket_id, UNEXPECTED_MESSAGE);
}
Expand Down
6 changes: 3 additions & 3 deletions core/federated/RTI/rti_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ void handle_port_absent_message(federate_info_t* sending_federate, unsigned char
void handle_timed_message(federate_info_t* sending_federate, unsigned char* buffer);

/**
* Handle a latest tag complete (LTC) message. @see
* MSG_TYPE_LATEST_TAG_COMPLETE in rti.h.
* Handle a latest tag confirmed (LTC) message. @see
* MSG_TYPE_LATEST_TAG_CONFIRMED in rti.h.
*
* This function assumes the caller does not hold the mutex.
*
* @param fed The federate that has completed a logical tag.
*/
void handle_latest_tag_complete(federate_info_t* fed);
void handle_latest_tag_confirmed(federate_info_t* fed);

/**
* Handle a next event tag (NET) message. @see MSG_TYPE_NEXT_EVENT_TAG in rti.h.
Expand Down
Loading

0 comments on commit 6e15213

Please sign in to comment.