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

[cbuild-run] Implement multi-core support #1948

Merged
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
7 changes: 6 additions & 1 deletion tools/projmgr/include/ProjMgrRunDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct AlgorithmType {
unsigned long long ramStart = 0;
unsigned long long ramSize = 0;
bool bDefault = false;
std::string pname;
};

/**
Expand All @@ -27,6 +28,7 @@ struct AlgorithmType {
struct FilesType {
std::string file;
std::string type;
std::string pname;
};

/**
Expand All @@ -38,7 +40,7 @@ struct DebugSequencesBlockType {
std::string control_if;
std::string control_while;
std::string timeout;
bool atomic;
bool atomic = false;
std::vector<DebugSequencesBlockType> blocks;
};

Expand All @@ -49,6 +51,7 @@ struct DebugSequencesType {
std::string name;
std::string info;
std::vector<DebugSequencesBlockType> blocks;
std::string pname;
};

/**
Expand Down Expand Up @@ -100,6 +103,8 @@ class ProjMgrRunDebug {
protected:
RunDebugType m_runDebug;
void GetDebugSequenceBlock(const RteItem* item, DebugSequencesBlockType& block);
void PushBackUniquely(std::vector<std::pair<const RteItem*, std::vector<std::string>>>& vec,
const RteItem* item, const std::string pname);
};

#endif // PROJMGRRUNDEBUG_H
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static constexpr const char* YAML_PACKS = "packs";
static constexpr const char* YAML_PACKS_MISSING = "packs-missing";
static constexpr const char* YAML_PACKS_UNUSED = "packs-unused";
static constexpr const char* YAML_PATH = "path";
static constexpr const char* YAML_PNAME = "pname";
static constexpr const char* YAML_PROCESSOR = "processor";
static constexpr const char* YAML_PROGRAMMING = "programming";
static constexpr const char* YAML_PROJECT = "project";
Expand Down
11 changes: 7 additions & 4 deletions tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,8 @@
"size": { "type": "number", "description": "Memory size." },
"ram-start":{ "type": "number", "description": "RAM Memory start address." },
"ram-size": { "type": "number", "description": "RAM Memory size." },
"default": { "type": "boolean", "description": "Default memory." }
"default": { "type": "boolean", "description": "Default memory." },
"pname": { "type": "string", "description": "Processor name." }
},
"additionalProperties": false
},
Expand All @@ -1965,8 +1966,9 @@
"RunFileType": {
"type": "object",
"properties": {
"file": { "type": "string", "description": "File path." },
"type": { "type": "string", "description": "File type." }
"file": { "type": "string", "description": "File path." },
"type": { "type": "string", "description": "File type." },
"pname": { "type": "string", "description": "Processor name." }
},
"additionalProperties": false
},
Expand All @@ -1981,7 +1983,8 @@
"properties": {
"name": { "type": "string", "description": "Name of the sequence." },
"info": { "type": "string", "description": "Descriptive text to display for example for error diagnostics." },
"blocks": { "$ref": "#/definitions/DebugBlocksType" }
"blocks": { "$ref": "#/definitions/DebugBlocksType" },
"pname": { "type": "string", "description": "Executes sequence only for connection to processor; Default is executed for all connections." }
},
"additionalProperties": false,
"required": ["name"]
Expand Down
3 changes: 3 additions & 0 deletions tools/projmgr/src/ProjMgrCbuildRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void ProjMgrCbuildRun::SetProgrammingNode(YAML::Node node, const std::vector<Alg
if (item.bDefault) {
algorithmNode[YAML_DEFAULT] = true;
}
SetNodeValue(algorithmNode[YAML_PNAME], item.pname);
node.push_back(algorithmNode);
}
}
Expand All @@ -65,6 +66,7 @@ void ProjMgrCbuildRun::SetFilesNode(YAML::Node node, const std::vector<FilesType
YAML::Node fileNode;
SetNodeValue(fileNode[YAML_FILE], FormatPath(item.file, m_directory));
SetNodeValue(fileNode[YAML_TYPE], item.type);
SetNodeValue(fileNode[YAML_PNAME], item.pname);
node.push_back(fileNode);
}
}
Expand All @@ -75,6 +77,7 @@ void ProjMgrCbuildRun::SetDebugSequencesNode(YAML::Node node, const std::vector<
SetNodeValue(sequenceNode[YAML_NAME], sequence.name);
SetNodeValue(sequenceNode[YAML_INFO], sequence.info);
SetDebugSequencesBlockNode(sequenceNode[YAML_BLOCKS], sequence.blocks);
SetNodeValue(sequenceNode[YAML_PNAME], sequence.pname);
node.push_back(sequenceNode);
}
}
Expand Down
107 changes: 69 additions & 38 deletions tools/projmgr/src/ProjMgrRunDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,64 +24,83 @@ ProjMgrRunDebug::~ProjMgrRunDebug(void) {
bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {

// get target settings
const auto& context = contexts.front();
m_runDebug.solutionName = context->csolution->name;
m_runDebug.solution = context->csolution->path;
m_runDebug.targetType = context->type.target;
m_runDebug.compiler = context->compiler;
if (!context->device.empty()) {
m_runDebug.device = context->deviceItem.vendor + "::" + context->deviceItem.name +
(context->deviceItem.pname.empty() ? "" : ":" + context->deviceItem.pname);
const auto& context0 = contexts.front();
m_runDebug.solutionName = context0->csolution->name;
m_runDebug.solution = context0->csolution->path;
m_runDebug.targetType = context0->type.target;
m_runDebug.compiler = context0->compiler;
if (!context0->device.empty()) {
m_runDebug.device = context0->deviceItem.vendor + "::" + context0->deviceItem.name;
}
if (!context->board.empty()) {
m_runDebug.board = context->boardItem.vendor + "::" + context->boardItem.name +
(context->boardItem.revision.empty() ? "" : ":" + context->boardItem.revision);
if (!context0->board.empty()) {
m_runDebug.board = context0->boardItem.vendor + "::" + context0->boardItem.name +
(context0->boardItem.revision.empty() ? "" : ":" + context0->boardItem.revision);
}

// programming algorithms
Collection<RteItem*> algorithms;
vector<pair<const RteItem*, vector<string>>> algorithms;
// debug infos
Collection<RteItem*> debugs;
vector<pair<const RteItem*, vector<string>>> debugs;
// debug sequences
Collection<RteItem*> debugSequences;
vector<pair<const RteItem*, vector<string>>> debugSequences;

// processor names
map<string, ContextItem*> pnames;
for (const auto& context : contexts) {
pnames.emplace(context->deviceItem.pname, context);
}

// device collections
if (context->devicePack) {
m_runDebug.devicePack = context->devicePack->GetPackageID(true);
const auto& deviceAlgorithms = context->rteDevice->GetEffectiveProperties("algorithm", context->deviceItem.pname);
for (const auto& deviceAlgorithm : deviceAlgorithms) {
algorithms.push_back(deviceAlgorithm);
}
const auto& deviceDebugs = context->rteDevice->GetEffectiveProperties("debug", context->deviceItem.pname);
for (const auto& deviceDebug : deviceDebugs) {
debugs.push_back(deviceDebug);
}
const auto& deviceDebugSequences = context->rteDevice->GetEffectiveProperties("sequence", context->deviceItem.pname);
for (const auto& deviceDebugSequence : deviceDebugSequences) {
debugSequences.push_back(deviceDebugSequence);
for (const auto& [pname, context] : pnames) {
if (context->devicePack) {
m_runDebug.devicePack = context->devicePack->GetPackageID(true);
const auto& deviceAlgorithms = context->rteDevice->GetEffectiveProperties("algorithm", pname);
for (const auto& deviceAlgorithm : deviceAlgorithms) {
PushBackUniquely(algorithms, deviceAlgorithm, pname);
}
const auto& deviceDebugs = context->rteDevice->GetEffectiveProperties("debug", pname);
for (const auto& deviceDebug : deviceDebugs) {
PushBackUniquely(debugs, deviceDebug, pname);
}
const auto& deviceDebugSequences = context->rteDevice->GetEffectiveProperties("sequence", pname);
for (const auto& deviceDebugSequence : deviceDebugSequences) {
PushBackUniquely(debugSequences, deviceDebugSequence, pname);
}
}
}

// board collections
if (context->boardPack) {
m_runDebug.boardPack = context->boardPack->GetPackageID(true);
context->rteBoard->GetChildrenByTag("algorithm", algorithms);
if (context0->boardPack) {
m_runDebug.boardPack = context0->boardPack->GetPackageID(true);
Collection<RteItem*> boardAlgorithms;
context0->rteBoard->GetChildrenByTag("algorithm", boardAlgorithms);
for (const auto& boardAlgorithm : boardAlgorithms) {
PushBackUniquely(algorithms, boardAlgorithm, boardAlgorithm->GetAttribute("Pname"));
}
}

// sort collections starting with specific pnames
for (auto vec : { &algorithms, &debugs, &debugSequences }) {
sort(vec->begin(), vec->end(), [](auto& left, auto& right) {
return left.second.size() < right.second.size();
});
}

// set device/board programming algorithms
for (const auto& algorithm : algorithms) {
for (const auto& [algorithm, pname] : algorithms) {
AlgorithmType item;
item.algorithm = algorithm->GetOriginalAbsolutePath();
item.start = algorithm->GetAttributeAsULL("start");
item.size = algorithm->GetAttributeAsULL("size");
item.ramStart = algorithm->GetAttributeAsULL("RAMstart");
item.ramSize = algorithm->GetAttributeAsULL("RAMsize");
item.bDefault = algorithm->GetAttributeAsBool("default");
item.pname = pname.size() == 1 ? pname.front() : "";
m_runDebug.algorithms.push_back(item);
}

// additional programming algorithms
for (const auto& memory : context->memory) {
for (const auto& memory : context0->memory) {
AlgorithmType item;
item.algorithm = memory.algorithm;
item.start = RteUtils::StringToULL(memory.start);
Expand All @@ -90,31 +109,32 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
}

// system descriptions
for (const auto& debug : debugs) {
for (const auto& [debug, pname] : debugs) {
const auto& svd = debug->GetAttribute("svd");
if (!svd.empty()) {
FilesType item;
item.file = debug->GetAbsolutePackagePath() + svd;
item.type = "svd";
item.pname = pname.size() == 1 ? pname.front() : "";
m_runDebug.systemDescriptions.push_back(item);
}
}

// outputs
for (const auto& c : contexts) {
auto output = c->outputTypes;
for (const auto& context : contexts) {
auto output = context->outputTypes;
if (output.elf.on) {
RteFsUtils::NormalizePath(output.elf.filename, c->directories.cprj + '/' + c->directories.outdir);
RteFsUtils::NormalizePath(output.elf.filename, context->directories.cprj + '/' + context->directories.outdir);
m_runDebug.outputs.push_back({ output.elf.filename, RteConstants::OUTPUT_TYPE_ELF });
}
if (output.hex.on) {
RteFsUtils::NormalizePath(output.hex.filename, c->directories.cprj + '/' + c->directories.outdir);
RteFsUtils::NormalizePath(output.hex.filename, context->directories.cprj + '/' + context->directories.outdir);
m_runDebug.outputs.push_back({ output.hex.filename, RteConstants::OUTPUT_TYPE_HEX });
}
}

// debug sequences
for (const auto& debugSequence : debugSequences) {
for (const auto& [debugSequence, pname] : debugSequences) {
DebugSequencesType sequence;
sequence.name = debugSequence->GetName();
sequence.info = debugSequence->GetAttribute("info");
Expand All @@ -123,6 +143,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
GetDebugSequenceBlock(debugSequenceBlock, block);
sequence.blocks.push_back(block);
}
sequence.pname = pname.size() == 1 ? pname.front() : "";
m_runDebug.debugSequences.push_back(sequence);
}

Expand Down Expand Up @@ -162,3 +183,13 @@ void ProjMgrRunDebug::GetDebugSequenceBlock(const RteItem* item, DebugSequencesB
block.blocks.push_back(childBlock);
}
}

void ProjMgrRunDebug::PushBackUniquely(vector<pair<const RteItem*, vector<string>>>& vec, const RteItem* item, const string pname) {
for (auto& [rteItem, pnames] : vec) {
if (rteItem == item) {
CollectionUtils::PushBackUniquely(pnames, pname);
return;
}
}
vec.push_back({ item, { pname } });
}
Loading