Skip to content

Commit

Permalink
Potential solution no.1 for trace bug discussed in the last schedulin…
Browse files Browse the repository at this point in the history
…g meeting.
  • Loading branch information
hokeun committed Apr 2, 2022
1 parent 7a7e3a5 commit 1827ed8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions org.lflang/src/org/lflang/TargetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class TargetConfig {
* The first string is the definition itself, and the second string is the value to attribute to that definition, if any.
* The second value could be left empty.
*/
// related to the ifdef in trace.h
public Map<String, String> compileDefinitions = new HashMap<>();

/**
Expand Down
7 changes: 7 additions & 0 deletions org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ CodeBuilder generateCMakeCode(
cMakeCode.pr(")");
cMakeCode.newLine();

// This logic doesn't make sense?
if (targetConfig.threading || targetConfig.tracing != null) {
// If threaded computation is requested, add a the threads option.
cMakeCode.pr("# Find threads and link to it");
Expand All @@ -156,9 +157,15 @@ CodeBuilder generateCMakeCode(
// If the LF program itself is threaded or if tracing is enabled, we need to define
// NUMBER_OF_WORKERS so that platform-specific C files will contain the appropriate functions
cMakeCode.pr("# Set the number of workers to enable threading");
// Where we want to add line for target_compile_definitions( ${LF_MAIN_TARGET} LINGUA_FRANCA_TRACE)
cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC NUMBER_OF_WORKERS="+targetConfig.workers+")");
cMakeCode.newLine();
}

if (targetConfig.tracing != null) {
cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} LINGUA_FRANCA_TRACE ");
cMakeCode.newLine();
}

cMakeCode.pr("# Target definitions\n");
targetConfig.compileDefinitions.forEach( (key, value) -> {
Expand Down
19 changes: 10 additions & 9 deletions org.lflang/src/org/lflang/generator/c/CPreambleGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public static String generateDefineDirectives(
GeneratorBase.timeInTargetLanguage(advanceMessageInterval));
}
}
if (tracing != null) {
code.pr(generateTracingDefineDirective(tracing.traceFileName));
}
// if (tracing != null) {
// code.pr(generateTracingDefineDirective(tracing.traceFileName));
// }
if (hasModalReactors) {
code.pr("#define MODAL_REACTORS");
}
Expand Down Expand Up @@ -108,12 +108,13 @@ private static String generateFederatedDefineDirective(CoordinationType coordina
return String.join("\n", directives);
}

private static String generateTracingDefineDirective(String traceFileName) {
if (traceFileName == null) {
return "#define LINGUA_FRANCA_TRACE";
}
return "#define LINGUA_FRANCA_TRACE " + traceFileName;
}
// Remove this
// private static String generateTracingDefineDirective(String traceFileName) {
// if (traceFileName == null) {
// return "#define LINGUA_FRANCA_TRACE";
// }
// return "#define LINGUA_FRANCA_TRACE " + traceFileName;
// }

/**
* Initialize clock synchronization (if enabled) and its related options for a given federate.
Expand Down

0 comments on commit 1827ed8

Please sign in to comment.