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
31 changes: 2 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ set(GEN_STR_CATALOG
${CMAKE_CURRENT_LIST_DIR}/tools/gen_str_catalog.py
CACHE FILEPATH "Location of script to generate a string catalog")

add_library(cib_sc INTERFACE)
target_compile_features(cib_sc INTERFACE cxx_std_20)
target_link_libraries_system(cib_sc INTERFACE fmt::fmt-header-only stdx)

target_sources(
cib_sc
INTERFACE FILE_SET
sc
TYPE
HEADERS
BASE_DIRS
include
FILES
include/sc/format.hpp
include/sc/fwd.hpp
include/sc/lazy_string_format.hpp
include/sc/string_constant.hpp)

add_library(cib_match INTERFACE)
target_compile_features(cib_match INTERFACE cxx_std_20)
target_link_libraries_system(cib_match INTERFACE stdx)
Expand Down Expand Up @@ -241,7 +223,7 @@ target_sources(

add_library(cib_flow INTERFACE)
target_compile_features(cib_flow INTERFACE cxx_std_20)
target_link_libraries_system(cib_flow INTERFACE cib_log cib_nexus cib_sc stdx)
target_link_libraries_system(cib_flow INTERFACE cib_log cib_nexus stdx)

target_sources(
cib_flow
Expand All @@ -266,14 +248,7 @@ target_sources(

add_library(cib_seq INTERFACE)
target_compile_features(cib_seq INTERFACE cxx_std_20)
target_link_libraries_system(
cib_seq
INTERFACE
cib_flow
cib_log
cib_nexus
cib_sc
stdx)
target_link_libraries_system(cib_seq INTERFACE cib_flow cib_log cib_nexus stdx)

target_sources(
cib_seq
Expand Down Expand Up @@ -303,7 +278,6 @@ target_link_libraries_system(
cib_match
cib_msg
cib_nexus
cib_sc
cib_seq
concurrency
fmt::fmt-header-only
Expand Down Expand Up @@ -333,7 +307,6 @@ if(PROJECT_IS_TOP_LEVEL)
clang_tidy_interface(cib_match)
clang_tidy_interface(cib_msg)
clang_tidy_interface(cib_nexus)
clang_tidy_interface(cib_sc)
clang_tidy_interface(cib_seq)

# Enable functional and performance test suites.
Expand Down
1 change: 0 additions & 1 deletion docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ include::logging.adoc[]
include::interrupts.adoc[]
include::match.adoc[]
include::message.adoc[]
include::sc.adoc[]
include::implementation_details.adoc[]
3 changes: 0 additions & 3 deletions docs/intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ _cib_ contains several parts that work together:
- xref:interrupt.adoc#_the_interrupt_library[`interrupt`]
- xref:match.adoc#_the_match_library[`match`]
- xref:message.adoc#_the_message_library[`message`]
- xref:sc.adoc#_the_sc_string_constant_library[`sc` (string constant)]

=== Sub-library DAG

Expand All @@ -58,13 +57,11 @@ library that contains all the functionality.
----
flowchart BT
nexus(cib_nexus)
sc(cib_sc)
log(cib_log)
match(cib_match)
lookup(cib_lookup)

flow(cib_flow) --> nexus
flow --> sc
flow --> log

log_fmt(cib_log_fmt) --> log
Expand Down
53 changes: 47 additions & 6 deletions docs/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ xref:logging.adoc#_logging_environments[environment].

The first two runtime parameters receive preprocessor `\_​_FILE_​\_` and `__LINE_​_` values
respectively. The `msg` argument is a structure containing a
xref:sc.adoc#_formatting_strings[compile-time format string] and runtime
compile-time format string and runtime
arguments to be interpolated into it. It supports an `apply` function, so one
way to implement `log` is:

Expand Down Expand Up @@ -185,11 +185,52 @@ struct my_struct {
}
----

=== String data

On a constrained system, space for text can be at a premium. The `sc` library
and the MIPI Sys-T logger combine to
xref:sc.adoc#_efficient_logging_with_mipi_sys_t[solve this problem].
=== Efficient logging with MIPI Sys-T

On a constrained system, space for text can be limited-to-nonexistent. `cib`
uses `stdx::ct_format` and the
https://github.com/intel/compile-time-init-build/tree/main/include/log/catalog/mipi_encoder.hpp[MIPI
Sys-T logging config] to solve this problem.

- First, each string constant contains string character data in its type.
- The MIPI logger calls the function template specialization
https://github.com/intel/compile-time-init-build/blob/main/include/log/catalog/catalog.hpp[`catalog`]
to get the catalog ID corresponding to each string constant.

But: the `catalog` function template is just that -- only a template -- to
begin with. It is specialized as follows:

- The application is built as a library.
- Running `nm` on that library reveals missing symbols: precisely the function
specializations that are required for all the string constants.
- Those symbols are used to generate the template specializations in another
file, which itself is compiled into a library.
- String data is recovered from the symbol types and used to generate the
catalog collateral in XML and/or JSON format.
- Link-time optimization inlines the `catalog` function template
specializations, each of which is a one-line function that returns a
catalog ID.

Thus no string data exists in the executable, but the correct catalog IDs are
used in logging, and the remote log handler can reconstitute the actual strings.
The XML and JSON collateral also contains information about any runtime
arguments that need to be interpolated into the string and whose values are sent
by the MIPI Sys-T logger after the catalog ID.

==== Tooling support

The process of generating log strings from the type information revealed by
missing symbols is automated by a
https://github.com/intel/compile-time-init-build/blob/main/tools/gen_str_catalog.py[python
script] provided and by a
https://github.com/intel/compile-time-init-build/blob/main/cmake/string_catalog.cmake[CMake
wrapper function (`gen_str_catalog`)] that drives the process. See
https://github.com/intel/compile-time-init-build/blob/main/test/CMakeLists.txt[the
test] that exercises that functionality for an example.

NOTE: This process assigns IDs to both strings and
xref:logging.adoc#_modules[log modules]. `catalog` is specialized for catalog
IDs; `module` is specialized for module IDs.

=== Version logging

Expand Down
125 changes: 0 additions & 125 deletions docs/sc.adoc

This file was deleted.

10 changes: 4 additions & 6 deletions include/flow/graph_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,10 @@ struct graph_builder {

template <typename T>
constexpr static auto error_steps =
stdx::transform([](auto N) { return stdx::ct_string_from_type(N); },
T{})
.join(stdx::ct_string{""}, [](auto x, auto y) {
using namespace stdx::literals;
return x + ", "_cts + y;
});
T{}.join(stdx::cts_t<"">{}, [](auto x, auto y) {
using namespace stdx::literals;
return x + ", "_ctst + y;
});

constexpr static void check_for_missing_nodes(auto nodes,
auto mentioned_nodes) {
Expand Down
12 changes: 6 additions & 6 deletions include/flow/graphviz_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ struct graphviz_builder {
nodes_t sinks{};
for_each(
[&]<typename Node>(Node const &) {
sources.insert(Node::name_t::value);
sinks.insert(Node::name_t::value);
sources.emplace(Node::name_t::value);
sinks.emplace(Node::name_t::value);
},
nodes);
for_each(
[&]<typename Edge>(Edge const &) {
sinks.erase(Edge::source_t::name_t::value);
sources.erase(Edge::dest_t::name_t::value);
sinks.erase(std::string_view{Edge::source_t::name_t::value});
sources.erase(std::string_view{Edge::dest_t::name_t::value});
},
edges);

Expand All @@ -39,9 +39,9 @@ struct graphviz_builder {
}
for_each(
[&]<typename Edge>(Edge const &) {
output += std::string{Edge::source_t::name_t::value};
output += std::string_view{Edge::source_t::name_t::value};
output += " -> ";
output += std::string{Edge::dest_t::name_t::value};
output += std::string_view{Edge::dest_t::name_t::value};
output += '\n';
},
edges);
Expand Down
6 changes: 1 addition & 5 deletions include/flow/step.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <flow/common.hpp>
#include <flow/log.hpp>
#include <flow/subgraph_identity.hpp>
#include <sc/string_constant.hpp>

#include <stdx/compiler.hpp>
#include <stdx/ct_string.hpp>
Expand All @@ -18,10 +17,7 @@ template <stdx::ct_string Type, stdx::ct_string Name,
subgraph_identity Identity, typename Cond, typename F>
struct ct_node {
using is_subgraph = void;
using type_t =
decltype(stdx::ct_string_to_type<Type, sc::string_constant>());
using name_t =
decltype(stdx::ct_string_to_type<Name, sc::string_constant>());
using name_t = stdx::cts_t<Name>;
using func_t = F;

constexpr static auto ct_type = Type;
Expand Down
Loading
Loading