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

Yaml changes #518

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion rvs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ set(SOURCES
src/rvsexec.cpp
src/rvsexec_do_yaml.cpp
src/rvsoptions.cpp
src/yaml_utils.cpp
src/node_yaml.cpp
)

## define helper lib
add_library(rvshelper ${SOURCES})

target_link_libraries(rvshelper yaml)
## define target
add_executable(${RVS_TARGET} src/rvs.cpp)
target_link_libraries(${RVS_TARGET} rvshelper rvslib ${PROJECT_LINK_LIBS} )
Expand Down
24 changes: 12 additions & 12 deletions rvs/conf/gpup_single.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ actions:
device: all
module: gpup
properties:
all:
- all:
io_links-properties:
all:
- all:

# GPUP test #2
#
Expand All @@ -42,14 +42,14 @@ actions:
device: all
module: gpup
properties:
simd_count:
- simd_count:
mem_banks_count:
io_links_count:
vendor_id:
location_id:
max_engine_clk_ccompute:
io_links-properties:
version_major:
- version_major:
type:
version_major:
version_minor:
Expand Down Expand Up @@ -79,9 +79,9 @@ actions:
device: all
module: gpup
properties:
all:
- all:
io_links-properties:
all:
- all:

# GPUP test #4
#
Expand All @@ -102,9 +102,9 @@ actions:
module: gpup
deviceid:
properties:
all:
- all:
io_links-properties:
all:
- all:

# GPUP test #5
#
Expand All @@ -128,9 +128,9 @@ actions:
module: gpup
deviceid:
properties:
all:
- all:
io_links-properties:
all:
- all:

# GPUP test #6
#
Expand All @@ -154,6 +154,6 @@ actions:
module: gpup
deviceid:
properties:
mem_banks_count:
- mem_banks_count:
io_links-properties:
version_major:
- version_major:
52 changes: 52 additions & 0 deletions rvs/include/node_yaml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef NODE_YAML_H
#define NODE_YAML_H
#include <yaml.h>
#include <cstdio>
#include <string>
#include <memory>
#include <iostream>
#include <vector>
#include <map>
#include "yaml_utils.h"
enum status {
SUCCESS = 1,
FAILURE = 0
};

/* Our example parser states. */
const std::string ACTIONS{"actions"};
enum parse_state {
STATE_START, /* start state */
STATE_STREAM, /* start/end stream */
STATE_DOCUMENT, /* start/end document */
STATE_SECTION, /* top level */

STATE_ACTIONLIST, /* action list */
STATE_ACTIONVALUES, /* action key-value pairs */
STATE_ACTIONKEY, /* action key */
STATE_ACTIONNAME, /* action name value */
STATE_ACTION_VALUE, /* all values encompassed as one*/
STATE_COLLECTION,
STATE_COLLECTIONLIST,
STATE_COLLECTIONKEY,
STATE_COLLECTIONVALUE,
STATE_STOP /* end state */
};

//alias definitions
using ActionMap = std::map<std::string, std::string> ;
using ActionList = std::vector<ActionMap> ;
using Actions = std::map<std::string, ActionList> ;
using CollectionMap = std::map<std::string, std::vector<std::string>> ;
/* Our application parser state data. */
struct parser_state {
parse_state state; /* The current parse state */
ActionMap f; /* data elements. */
ActionList actionlist; /* List of action objects. */
std::string keyname; /* to retain key name from previous state */
std::string colkey; /* to retain key name from previous state */
};
bool isCollection(const std::string& property);
int consume_event(std::shared_ptr<parser_state> s, yaml_event_t *event);
int parse_config(std::shared_ptr<parser_state> state,std::string filename);
#endif
12 changes: 11 additions & 1 deletion rvs/include/rvsexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define RVS_INCLUDE_RVSEXEC_H_

#include <string>
#include "yaml-cpp/node/node.h"
#include "node_yaml.h"


namespace rvs {
Expand Down Expand Up @@ -56,13 +56,23 @@ class exec {
int do_gpu_list(void);

int do_yaml(const std::string& config_file);
int do_yaml_properties(const ActionMap& node,
const std::string& module_name, if1* pif1);
bool is_yaml_properties_collection(const std::string& module_name,
const std::string& proprty_name);
int do_yaml_properties_collection(const ActionMap& node,
const std::string& parent_name,
if1* pif1);

/*
int do_yaml_properties(const YAML::Node& node,
const std::string& module_name, if1* pif1);
bool is_yaml_properties_collection(const std::string& module_name,
const std::string& proprty_name);
int do_yaml_properties_collection(const YAML::Node& node,
const std::string& parent_name,
if1* pif1);
*/
};

} // namespace rvs
Expand Down
3 changes: 1 addition & 2 deletions rvs/include/rvsmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <string>
#include <memory>

#include "yaml-cpp/yaml.h"

#include "include/rvsmodule_if.h"

Expand Down Expand Up @@ -63,7 +62,7 @@ typedef std::pair<std::string, module*> t_mmpair;
static module* find_create_module(const char* pShortName);

//! YAML configuration
static YAML::Node config;
//static YAML::Node config;

//! short name -> rvsmodule* mapping
static std::map<std::string, module*> modulemap;
Expand Down
5 changes: 5 additions & 0 deletions rvs/include/yaml_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef YAML_UTILS_H
#define YAML_UTILS_H
std::string getModuleName(std::string input);
std::string getModule(std::string filename);
#endif
Loading