Add an extensible phase workload definition functionality.#54
Conversation
|
Got the following while compiling (gcc (GCC) 8.1.1) Please fix. |
|
fixed the warning at rt-app_parse_config.c:385 . |
|
Unfortunately this still has problems: AFAIK snprintf is actually to prefer to strncpy (e.g., https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ - Handling truncation when it occurs) |
e75c1b7 to
4150d87
Compare
|
Removed strncpy and substituted those code spinets with snprintf. Gcc 8.1 with -Wall does not issue the warnings you were referring to. Which C flags are you using in the compilation? |
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This doesn't seem to produce any sort of logs or numbers.
How is this supposed to be used? How the user get to know what happended or how the external workload performed?
There was a problem hiding this comment.
Made the example a bit more complex so as to show a potential user how to manage the functionality. The external_workload should behave as a regular event. The execution of the external workload produces debug output (when that log level is selected) in the rt-app.c
There was a problem hiding this comment.
This should probably be moved to doc/examples/tutorial/example9.json
Also please include a global section like the following
"global" : {
"calibration" : "CPU0",
"default_policy" : "SCHED_OTHER",
"pi_enabled" : false,
"lock_pages" : false,
"logdir" : "./",
"log_basename" : "rt-app9",
"ftrace" : false,
"gnuplot" : false,
}
and indent tasks as for the other examples
| if (!realpath(argv[0], full_path)) | ||
| { | ||
| log_error("failed to get rt-app base path: %s", strerror(errno)); | ||
| exit(0); |
There was a problem hiding this comment.
Please use exit(EXIT_FAILURE) here and where appropriate.
| exit(0); | ||
| } | ||
|
|
||
| snprintf(main_install_path,main_install_path_len,"%s%s", full_path, shared_lib_dir_name); |
There was a problem hiding this comment.
Guess we should check for errors?
Also please align properly with a tab.
|
|
||
| /*if (!json_object_is_type(obj, json_type_string)) | ||
| goto unknown_event; | ||
| */ |
| * Get the name of the shared library as well as | ||
| * the optional method name | ||
| */ | ||
| char *tmp = get_string_value_from(obj, "library_name", FALSE, ""); |
There was a problem hiding this comment.
Do you really need the tmp variable?
| char const* shared_library_dir_name = get_shared_library_base_path(); | ||
| if (!shared_library_dir_name) | ||
| { | ||
| log_error("failed to obtain shared library directory\n"); |
There was a problem hiding this comment.
exit(EXIT_FAILURE)?
Also please don't mix declarations and code.
| return tmp; | ||
| } | ||
|
|
||
| void initialise_external_library(rtapp_resource_t *library_struct) |
There was a problem hiding this comment.
simply rdata maybe (as it contains more data that the one strictly associated with the library)?
There was a problem hiding this comment.
I am having difficulties understanding what the comment refers to. Can you please rephrase?
There was a problem hiding this comment.
Oh, sorry, simply a huge nitpick.. I'd s/library_struct/rdata/ :-)
There was a problem hiding this comment.
changed library_struct to rdata
|
|
||
| char *full_library_name = malloc(full_library_name_length); | ||
|
|
||
| snprintf(full_library_name, full_library_name_length, "%s%s", shared_library_dir_name, library_name); |
| break; | ||
| case rtapp_external_workload: | ||
| rdata->res.external_workload.workload(); | ||
| break; |
|
|
||
| Adapted from Press et al., "Numerical Recipes in C". | ||
|
|
||
| */ |
There was a problem hiding this comment.
Did you write this yourself or is the code taken from some other source?
There was a problem hiding this comment.
This is an floating point benchmark obtained from some external source. It was uploaded with the intent of showcasing that complex code can be ran as a rt-app phase. This probably should not be kept as part of the PR.
| @@ -0,0 +1,14 @@ | |||
| SOURCE = $(wildcard */*.c) | |||
There was a problem hiding this comment.
Mmm, I'm wondering if pulling "random" code into rt-app sources is really a good idea.
I guess we are basically subscribing to maintaining all the snippets we import.. :-(
Alternatives?
There was a problem hiding this comment.
Agree, this should be mostly a mechanism to allow for random code to be used as rt-app phases. Only very select and generic code snippets should be committed to rt-app. The current workload which is part of the PR has the purpose of showcasing that the mechanism works for complex workloads, it should not be part of the PR when it hypothetically gets merged.
There was a problem hiding this comment.
Mmm OK. I wonder what's the best way to make life easy for potential users of this new feature, though. I guess having a very simple example in the repo would certainly help. And I also guess adding substantial documentation to tutorial.txt should help as well.
There was a problem hiding this comment.
created a simple workload which just prints an integer. The workload has two methods that behave differently with respect to the integer increment.
There was a problem hiding this comment.
Added documentation to doc/tutorial.txt detailing the external_workload event.
d3d2c4f to
53469a7
Compare
| {0, 0, 0, 0} | ||
| }; | ||
|
|
||
| static char* main_install_path = NULL; |
There was a problem hiding this comment.
No need to initialize this to NULL.
| int full_path_len; | ||
| int main_install_path_len; | ||
|
|
||
| static const char shared_lib_dir_name[] = "/../rtapp_function/"; |
| /* get the rt-app base directory full name */ | ||
| char* full_path = malloc(PATH_MAX); | ||
| int index; | ||
| int return_snprintf = 0; |
|
|
||
| /* get the program invocation string and extract the base directory content */ | ||
| if (!realpath(argv[0], full_path)) | ||
| { |
There was a problem hiding this comment.
Nitpick!
Not sure we enforce this everywhere, but I like better parenthesis to be aligned with if and for statements.
if (condition) {
}
for (;;) {
}
There was a problem hiding this comment.
moved curlies on all relevant lines.
| exit(EXIT_FAILURE); | ||
| } | ||
|
|
||
| return_snprintf = snprintf(main_install_path, main_install_path_len,"%s%s", full_path, shared_lib_dir_name); |
| int test1() { | ||
|
|
||
| testVar++; | ||
| printf("first test %d\n", testVar); |
There was a problem hiding this comment.
Mmm, this breaks rt-app log_* output format. :-/
Wonder if we can make that available to external workloads and actually enforce that is used?
There was a problem hiding this comment.
Are the external workloads generally expected to call printf or do any logging for that matter? Is this really required?
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This should probably be moved to doc/examples/tutorial/example9.json
Also please include a global section like the following
"global" : {
"calibration" : "CPU0",
"default_policy" : "SCHED_OTHER",
"pi_enabled" : false,
"lock_pages" : false,
"logdir" : "./",
"log_basename" : "rt-app9",
"ftrace" : false,
"gnuplot" : false,
}
and indent tasks as for the other examples
| * yield: String. Calls pthread_yield(), freeing the CPU for other tasks. This has a | ||
| special meaning for SCHED_DEADLINE tasks. String can be empty. | ||
|
|
||
| * external_workload: Executes a function declared in a shared library. The shared |
There was a problem hiding this comment.
Add type (e.g. sync event).
| special meaning for SCHED_DEADLINE tasks. String can be empty. | ||
|
|
||
| * external_workload: Executes a function declared in a shared library. The shared | ||
| libraries are stored at rtapp_function/<workload base directory>/ .For each c file |
There was a problem hiding this comment.
Nitpick. Space after full stop.
| * external_workload: Executes a function declared in a shared library. The shared | ||
| libraries are stored at rtapp_function/<workload base directory>/ .For each c file | ||
| present in the workload base directory a shared library is compiled. The external_workload | ||
| must is defined, in the rt-app taskset definition, by two fields: |
Add support for phases declared as "external_workload".
Execute the method previously loaded from the shared object of an "external_workload" phase.
New external test workload added to rtapp_function/test. The json example usage is at doc/examples/shared_object_workload.json
Allow phases to execute workloads from shared objects present in the rtapp_function/ directory.
This allows for a more straightforward integration of external workloads with rt-app, ideally it makes it a less cumbersome exercise. It would allow, for instance, NEON kernels or any other particular code to be used in rt-app more easily. The workloads can be easily contributed back to the rt-app repo and will not contribute to rt-app base src pollution since they are fairly isolated.