User Tools

Site Tools


docs:rtlib:appresource

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:rtlib:appresource [2020/04/28 11:38]
jumanix [Resource awareness] Add GPU
docs:rtlib:appresource [2020/04/28 11:41] (current)
jumanix [Resource awareness]
Line 5: Line 5:
 To this aim, the RTLib provides the function ''​GetAssigneResources()''​. In the following example, we show a possible usage of the function. In particular, we imagine the application setting the number of threads equal to the number of CPU cores assigned by the resource manager. To this aim, the RTLib provides the function ''​GetAssigneResources()''​. In the following example, we show a possible usage of the function. In particular, we imagine the application setting the number of threads equal to the number of CPU cores assigned by the resource manager.
  
-<​code>​+<​code ​cpp>
  
 RTLIB_ExitCode_t MyApp::​onConfigure(int8_t awm_id) { RTLIB_ExitCode_t MyApp::​onConfigure(int8_t awm_id) {
  
  int cpu_quota, nr_cpu_cores,​ nr_gpus, mem;  int cpu_quota, nr_cpu_cores,​ nr_gpus, mem;
 +
  GetAssignedResources(PROC_ELEMENT,​ cpu_quota);  GetAssignedResources(PROC_ELEMENT,​ cpu_quota);
  GetAssignedResources(PROC_NR,​ nr_cpu_cores);​  GetAssignedResources(PROC_NR,​ nr_cpu_cores);​
Line 17: Line 18:
         ...         ...
  GetAssignedResources(GPU,​ nr_gpus);  GetAssignedResources(GPU,​ nr_gpus);
-        ... 
-        ​ 
         if (nr_gpus > 0) {         if (nr_gpus > 0) {
            // Cool... we have some GPUs!            // Cool... we have some GPUs!
Line 35: Line 34:
 The RTLib provides the ''​GetCPS()''​ function to return the cycles-per-second mean value, computed through and exponential mean over the last cycles. The ''​onMonitor()''​ function is, in this case, a reasonable point at which placing the function call.  The RTLib provides the ''​GetCPS()''​ function to return the cycles-per-second mean value, computed through and exponential mean over the last cycles. The ''​onMonitor()''​ function is, in this case, a reasonable point at which placing the function call. 
  
-<​code>​+<​code ​cpp>
  
 RTLIB_ExitCode_t MyApp::​onMonitor() { RTLIB_ExitCode_t MyApp::​onMonitor() {
Line 61: Line 60:
 Example: Example:
  
-<​code>​+<​code ​cpp>
  
 RTLIB_ExitCode_t MyApp::​onSetup() { RTLIB_ExitCode_t MyApp::​onSetup() {
docs/rtlib/appresource.1588066700.txt.bz2 ยท Last modified: 2020/04/28 11:38 by jumanix