docs:rtlib:oplist

In this tutorial we will enable application reconfiguration in our tutorial application. Fist of all, we need to create an Operating Points List from the recipe. The oplist is a summary of the AWMs parameters, which is linked to the application for quick reference. To link this file to the application, we will need to adjust the CMakeLists file.

To build an application which exploits the oplist file, you need to source the BOSPshell first.

You don't need to create the oplist file. The building system will create it for you.

The structure of an oplist file is quite simple. It contains parameters and metrics for each AWM.

/* This file has been automatically generated using */
/* the bbque-opp Operating Points parser script. */
#include <bbque/monitors/operating_point.h>
using bbque::rtlib::as::OperatingPointsList;
OperatingPointsList opList = {
  { //===== OP 000 =====
    { //=== Parameters
      {"threads", 1},
      {"param-a", 5},
      {"param-b", 1},
    },
    { //=== Metrics
      {"mspj", 8.61},
    },
  },
  { //===== OP 001 =====
    { //=== Parameters
      {"threads", 2},
      {"param-a", 5},
      {"param-b", 1},
    },
    { //=== Metrics
      {"mspj", 4.38},
    },
  },
  { //===== OP 002 =====
    { //=== Parameters
      {"threads", 3},
      {"param-a", 3},
      {"param-b", 1},
    },
    { //=== Metrics
      {"mspj", 2.66},
    },
  },
...

Let's see how to enable this feature in the CMakelists file. Essentially, you just need to add the oplist file to the sources list, and add a command to create it. Your CMakeLists file will look like this:

Added/modified lines are indicated with the #+ comment

#----- Check for the required RTLib library
find_package(BbqRTLib REQUIRED)
 
#----- Add compilation dependencies
include_directories(${BBQUE_RTLIB_INCLUDE_DIR})
 
#----- Add "bbqtutorials" target application
set(BBQTUTORIALS_SRC version BbqTutorials_exc BbqTutorials_main oplist) #+
add_executable(bbqtutorials ${BBQTUTORIALS_SRC})
 
#----- Linking dependencies
target_link_libraries(
	bbqtutorials
	${Boost_LIBRARIES}
	${BBQUE_RTLIB_LIBRARY}
)
 
# Use link path ad RPATH
set_property(TARGET bbqtutorials PROPERTY
	INSTALL_RPATH_USE_LINK_PATH TRUE)
 
#----- Install the BbqTutorials files
install (TARGETS bbqtutorials RUNTIME
	DESTINATION ${BBQTUTORIALS_PATH_BINS})
 
#----- Add opList genertion target
add_custom_command( #+
	OUTPUT  oplist.cc #+
	DEPENDS ${PROJECT_SOURCE_DIR}/recipes/BbqTutorials.recipe #+
	COMMAND bbque-oplb -v OUTF=oplist.cc ${PROJECT_SOURCE_DIR}/recipes/BbqTutorials.recipe #+
	COMMENT "Generating OPList..." #+
)

Now you just have to exploit this information in your application. At the beginning of the BbqTutorials_exc.cc file, the vector must be declared:

/* File: BbqTutorials_exc.cc */
 
#include <bbque/monitors/operating_point.h>
namespace ba = bbque::rtlib::as;
extern ba::OperatingPointsList opList;

Then the onConfigure method has to be implemented:

RTLIB_ExitCode_t BbqTutorials::onConfigure(uint8_t awm_id) {
 
	// Extracting parameters
	threads_number = opList[awm_id].parameters["threads"];
	quality_a = opList[awm_id].parameters["param-a"];
	quality_b = opList[awm_id].parameters["param-b"];
 
	// Extracting metrics
	float current_mspj = opList[awm_id].metrics["mspj"];
 
	logger->Warn("[onConfigure]: Configured with <thr, A, B>: <%d, %d, %d>",
		threads_number, quality_a, quality_b);
 
	logger->Warn("[onConfigure]: Expected remaining execution time: circa %f ms",
		current_mspj * (jobs_number - jobs_done));
 
	return RTLIB_OK;
}

Build the application, and enjoy!

[BOSPShell BOSP] \> make bbqtutorials
[BOSPShell BOSP] \> bbque-startd
[BOSPShell BOSP] \> bbqtutorials -j 50
*****                   - INFO   BbqTutorials    : .:: BbqTutorials (ver. HEAD-HASH-NOTFOUND) ::.
*****                   - INFO   BbqTutorials    : Built: Jun 24 2014 12:26:24
*****                   - INFO   BbqTutorials    : STEP 0. Initializing RTLib, application [bbqtutorials]...
18:24:01,771 - NOTICE rpc             : CGroup controller [cpuset] available at [/home/slibutti/opt/BOSP/out/mnt/cgroup]
18:24:01,771 - NOTICE rpc             : CGroup controller [cpu] available at [/home/slibutti/opt/BOSP/out/mnt/cgroup]
18:24:01,771 - NOTICE rpc             : CGroup controller [cpuacct] available at [/home/slibutti/opt/BOSP/out/mnt/cgroup]
18:24:01,771 - NOTICE rpc             : CGroup controller [memory] available at [/home/slibutti/opt/BOSP/out/mnt/cgroup]
*****                   - INFO   BbqTutorials    : STEP 1. Registering EXC using [BbqTutorials] recipe...
*****                   - INFO   BbqTutorials    : STEP 2. Starting EXC control thread...
*****                   - INFO   BbqTutorials    : STEP 3. Waiting for EXC completion...
18:24:01,985 - WARN   exc             : [onConfigure]: Configured with <thr, A, B>: <3, 3, 1>
18:24:01,985 - WARN   exc             : [onConfigure]: Expected remaining execution time: circa 150.000000 ms
18:24:02,002 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 1
18:24:02,010 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 2
18:24:02,024 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 3
18:24:02,031 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 4
18:24:02,046 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 5
18:24:02,055 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 6
18:24:02,063 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 7
18:24:02,070 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 8
18:24:02,077 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 9
18:24:02,090 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 10
18:24:02,097 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 11
18:24:02,105 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 12
18:24:02,112 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 13
18:24:02,119 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 14
18:24:02,127 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 15
18:24:02,134 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 16
18:24:02,141 - NOTICE exc             : [onMonitor]: Medium QoS (4) on cycle 17
*****                   - INFO   BbqTutorials    : STEP 4. Disabling EXC...
18:24:02,142 - NOTICE rpc             : Execution statistics:
 
 
Cumulative execution stats for 'BbqTutorials':
  TotCycles    :      16
  StartLatency :     212 [ms]
  AwmWait      :     212 [ms]
  Configure    :       0 [ms]
  Process      :     143 [ms]
 
# EXC    AWM   Uses Cycles   Total |      Min      Max |      Avg      Var
#==================================+===================+==================
BbqTutorials 002      1     16     143 |    7.271   17.120 |    9.321   10.590
#-------------------------+        +-------------------+------------------
BbqTutorials 002         onRun     143 |    7.246   16.940 |    9.257   10.588
BbqTutorials 002     onMonitor       0 |    0.024    0.181 |    0.064    0.002
#-------------------------+--------+-------------------+------------------
BbqTutorials 002   onConfigure       0 |    0.245    0.245 |    0.245    0.000
*****                   - INFO   BbqTutorials    : ===== BbqTutorials DONE! =====
docs/rtlib/oplist.txt ยท Last modified: 2015/11/17 14:19 by slibutti

Page Tools