-
Notifications
You must be signed in to change notification settings - Fork 105
Add an extensible phase workload definition functionality. #54
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
src/rt-app_args.c
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use exit(EXIT_FAILURE) here and where appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/rt-app_args.c
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess we should check for errors?
Also please align properly with a tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/rt-app_parse_config.c
Outdated
|
|
||
| /*if (!json_object_is_type(obj, json_type_string)) | ||
| goto unknown_event; | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed comment
src/rt-app_parse_config.c
Outdated
| * 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need the tmp variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed tmp declaration
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit(EXIT_FAILURE)?
Also please don't mix declarations and code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/rt-app_parse_config.c
Outdated
| return tmp; | ||
| } | ||
|
|
||
| void initialise_external_library(rtapp_resource_t *library_struct) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply rdata maybe (as it contains more data that the one strictly associated with the library)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am having difficulties understanding what the comment refers to. Can you please rephrase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, simply a huge nitpick.. I'd s/library_struct/rdata/ :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed library_struct to rdata
src/rt-app_parse_config.c
Outdated
|
|
||
| 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/rt-app.c
Outdated
| break; | ||
| case rtapp_external_workload: | ||
| rdata->res.external_workload.workload(); | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align with tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
rtapp_function/fpBench/fp.c
Outdated
| Adapted from Press et al., "Numerical Recipes in C". | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you write this yourself or is the code taken from some other source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed fp benchmark.
| @@ -0,0 +1,14 @@ | |||
| SOURCE = $(wildcard */*.c) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to initialize this to NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed initialisation.
src/rt-app_args.c
Outdated
| int full_path_len; | ||
| int main_install_path_len; | ||
|
|
||
| static const char shared_lib_dir_name[] = "/../rtapp_function/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed static.
src/rt-app_args.c
Outdated
| /* get the rt-app base directory full name */ | ||
| char* full_path = malloc(PATH_MAX); | ||
| int index; | ||
| int return_snprintf = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/rt-app_args.c
Outdated
|
|
||
| /* get the program invocation string and extract the base directory content */ | ||
| if (!realpath(argv[0], full_path)) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved curlies on all relevant lines.
src/rt-app_args.c
Outdated
| exit(EXIT_FAILURE); | ||
| } | ||
|
|
||
| return_snprintf = snprintf(main_install_path, main_install_path_len,"%s%s", full_path, shared_lib_dir_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
| int test1() { | ||
|
|
||
| testVar++; | ||
| printf("first test %d\n", testVar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
doc/tutorial.txt
Outdated
| * 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add type (e.g. sync event).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
doc/tutorial.txt
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. Space after full stop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
doc/tutorial.txt
Outdated
| * 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/must//
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
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.