Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracing does not get enabled in all files of reactor-c #1067

Closed
edwardalee opened this issue Apr 2, 2022 · 6 comments · Fixed by #1068
Closed

Tracing does not get enabled in all files of reactor-c #1067

edwardalee opened this issue Apr 2, 2022 · 6 comments · Fixed by #1068
Assignees
Labels
bug Something isn't working c Related to C target

Comments

@edwardalee
Copy link
Collaborator

Hokeun was chasing a mysterious bug where some tracing functions were not being called even though tracing is turned on. The file trace.h has this:

#ifdef LINGUA_FRANCA_TRACE
...
void tracepoint_worker_wait_starts(int worker);
...
#else
...
#define tracepoint_worker_wait_starts(...)
...
#endif

The file scheduler_GEDF_NP.c has a pound include of the above .h file, which, when separately compiled, results in the second definition, regardless of whether tracing is turned on our not.

Tracing used to work when the generated .c file included within it the other needed .c files because it would have, near the top, the following line:

#define LINGUA_FRANCA_TRACE

But now, that #define is never seen in any separately compiled file. So we need to find some other way to do this conditional compilation. Note that it is extremely important that tracing have exactly zero overhead when turned off, which is what the above strategy accomplishes. It defines tracepoint_worker_wait_starts as an empty macro that takes an arbitrary number of arguments.

The only way I can see to fix this is to change the code generator so that it creates, in addition to a .c file, a .h file with some common name, and then every other LF core file needs to have #include for that generated .h file. Any other ideas? Any volunteers to fix this? Perhaps one you who insisted on this separate compilation strategy? :-)

@edwardalee edwardalee added bug Something isn't working c Related to C target labels Apr 2, 2022
@lhstrh
Copy link
Member

lhstrh commented Apr 2, 2022

It's not so much that Cmake breaks anything but that the code generator inserts the define in the wrong place. I believe @hokeun already has a fix.

@hokeun
Copy link
Member

hokeun commented Apr 2, 2022

@lhstrh I tried that solution after our meeting, but I found that the solution didn't solve this bug. So this bug still exists.

@Soroosh129
Copy link
Contributor

There is a mechanism to fix this in the CGenerator.
There is simply a targetConfig.compileDefinitions.put("LINGUA_FRANCA_TRACE", "") missing.

This will expose the appropriate compile definition to CMake in the generated CMakeLists.txt.

@Soroosh129
Copy link
Contributor

@lhstrh I tried that solution after our meeting, but I found that the solution didn't solve this bug. So this bug still exists.

Could you please elaborate a bit? Does this solution match my comment above?

@lhstrh
Copy link
Member

lhstrh commented Apr 2, 2022

@lhstrh I tried that solution after our meeting, but I found that the solution didn't solve this bug. So this bug still exists.

If you can push this to a branch and issue a (draft) PR, we can help.

@hokeun
Copy link
Member

hokeun commented Apr 2, 2022

Thank you, Edward, Soroush, and Marten!

There is a mechanism to fix this in the CGenerator. There is simply a targetConfig.compileDefinitions.put("LINGUA_FRANCA_TRACE", "") missing.

I worked with @edwardalee on this solution by @Soroosh129 , and it works!

Just for reference, the solution I tried after the scheduling meeting (but didn't work) is here: 1827ed8

The solution is in this PR: #1068

@lhstrh lhstrh changed the title cmake build breaks tracing Tracing does not get enabled in all files of reactor-c Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c Related to C target
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants