Skip to content

Commit 3bdd6f4

Browse files
authored
[cbuild-run] Implement multi-core support
1 parent 7f69181 commit 3bdd6f4

File tree

5 files changed

+70
-27
lines changed

5 files changed

+70
-27
lines changed

tools/projmgr/include/ProjMgrRunDebug.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct AlgorithmType {
1919
unsigned long long ramStart = 0;
2020
unsigned long long ramSize = 0;
2121
bool bDefault = false;
22+
std::string pname;
2223
};
2324

2425
/**
@@ -27,6 +28,7 @@ struct AlgorithmType {
2728
struct FilesType {
2829
std::string file;
2930
std::string type;
31+
std::string pname;
3032
};
3133

3234
/**
@@ -38,7 +40,7 @@ struct DebugSequencesBlockType {
3840
std::string control_if;
3941
std::string control_while;
4042
std::string timeout;
41-
bool atomic;
43+
bool atomic = false;
4244
std::vector<DebugSequencesBlockType> blocks;
4345
};
4446

@@ -49,6 +51,7 @@ struct DebugSequencesType {
4951
std::string name;
5052
std::string info;
5153
std::vector<DebugSequencesBlockType> blocks;
54+
std::string pname;
5255
};
5356

5457
/**
@@ -99,6 +102,8 @@ class ProjMgrRunDebug {
99102
protected:
100103
RunDebugType m_runDebug;
101104
void GetDebugSequenceBlock(const RteItem* item, DebugSequencesBlockType& block);
105+
void PushBackUniquely(std::vector<std::pair<const RteItem*, std::vector<std::string>>>& vec,
106+
const RteItem* item, const std::string pname);
102107
};
103108

104109
#endif // PROJMGRRUNDEBUG_H

tools/projmgr/include/ProjMgrYamlParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static constexpr const char* YAML_PACKS = "packs";
151151
static constexpr const char* YAML_PACKS_MISSING = "packs-missing";
152152
static constexpr const char* YAML_PACKS_UNUSED = "packs-unused";
153153
static constexpr const char* YAML_PATH = "path";
154+
static constexpr const char* YAML_PNAME = "pname";
154155
static constexpr const char* YAML_PROCESSOR = "processor";
155156
static constexpr const char* YAML_PROGRAMMING = "programming";
156157
static constexpr const char* YAML_PROJECT = "project";

tools/projmgr/schemas/common.schema.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,8 @@
19531953
"size": { "type": "number", "description": "Memory size." },
19541954
"ram-start":{ "type": "number", "description": "RAM Memory start address." },
19551955
"ram-size": { "type": "number", "description": "RAM Memory size." },
1956-
"default": { "type": "boolean", "description": "Default memory." }
1956+
"default": { "type": "boolean", "description": "Default memory." },
1957+
"pname": { "type": "string", "description": "Processor name." }
19571958
},
19581959
"additionalProperties": false
19591960
},
@@ -1965,8 +1966,9 @@
19651966
"RunFileType": {
19661967
"type": "object",
19671968
"properties": {
1968-
"file": { "type": "string", "description": "File path." },
1969-
"type": { "type": "string", "description": "File type." }
1969+
"file": { "type": "string", "description": "File path." },
1970+
"type": { "type": "string", "description": "File type." },
1971+
"pname": { "type": "string", "description": "Processor name." }
19701972
},
19711973
"additionalProperties": false
19721974
},
@@ -1981,7 +1983,8 @@
19811983
"properties": {
19821984
"name": { "type": "string", "description": "Name of the sequence." },
19831985
"info": { "type": "string", "description": "Descriptive text to display for example for error diagnostics." },
1984-
"blocks": { "$ref": "#/definitions/DebugBlocksType" }
1986+
"blocks": { "$ref": "#/definitions/DebugBlocksType" },
1987+
"pname": { "type": "string", "description": "Executes sequence only for connection to processor; Default is executed for all connections." }
19851988
},
19861989
"additionalProperties": false,
19871990
"required": ["name"]

tools/projmgr/src/ProjMgrCbuildRun.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void ProjMgrCbuildRun::SetProgrammingNode(YAML::Node node, const std::vector<Alg
5656
if (item.bDefault) {
5757
algorithmNode[YAML_DEFAULT] = true;
5858
}
59+
SetNodeValue(algorithmNode[YAML_PNAME], item.pname);
5960
node.push_back(algorithmNode);
6061
}
6162
}
@@ -65,6 +66,7 @@ void ProjMgrCbuildRun::SetFilesNode(YAML::Node node, const std::vector<FilesType
6566
YAML::Node fileNode;
6667
SetNodeValue(fileNode[YAML_FILE], FormatPath(item.file, m_directory));
6768
SetNodeValue(fileNode[YAML_TYPE], item.type);
69+
SetNodeValue(fileNode[YAML_PNAME], item.pname);
6870
node.push_back(fileNode);
6971
}
7072
}
@@ -75,6 +77,7 @@ void ProjMgrCbuildRun::SetDebugSequencesNode(YAML::Node node, const std::vector<
7577
SetNodeValue(sequenceNode[YAML_NAME], sequence.name);
7678
SetNodeValue(sequenceNode[YAML_INFO], sequence.info);
7779
SetDebugSequencesBlockNode(sequenceNode[YAML_BLOCKS], sequence.blocks);
80+
SetNodeValue(sequenceNode[YAML_PNAME], sequence.pname);
7881
node.push_back(sequenceNode);
7982
}
8083
}

tools/projmgr/src/ProjMgrRunDebug.cpp

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,72 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
2929
m_runDebug.targetType = context->type.target;
3030
m_runDebug.compiler = context->compiler;
3131
if (!context->device.empty()) {
32-
m_runDebug.device = context->deviceItem.vendor + "::" + context->deviceItem.name +
33-
(context->deviceItem.pname.empty() ? "" : ":" + context->deviceItem.pname);
32+
m_runDebug.device = context->deviceItem.vendor + "::" + context->deviceItem.name;
3433
}
3534
if (!context->board.empty()) {
3635
m_runDebug.board = context->boardItem.vendor + "::" + context->boardItem.name +
3736
(context->boardItem.revision.empty() ? "" : ":" + context->boardItem.revision);
3837
}
3938

4039
// programming algorithms
41-
Collection<RteItem*> algorithms;
40+
vector<pair<const RteItem*, vector<string>>> algorithms;
4241
// debug infos
43-
Collection<RteItem*> debugs;
42+
vector<pair<const RteItem*, vector<string>>> debugs;
4443
// debug sequences
45-
Collection<RteItem*> debugSequences;
44+
vector<pair<const RteItem*, vector<string>>> debugSequences;
45+
46+
// processor names
47+
map<string, ContextItem*> pnames;
48+
for (const auto& context : contexts) {
49+
pnames.emplace(context->deviceItem.pname, context);
50+
}
4651

4752
// device collections
48-
if (context->devicePack) {
49-
m_runDebug.devicePack = context->devicePack->GetPackageID(true);
50-
const auto& deviceAlgorithms = context->rteDevice->GetEffectiveProperties("algorithm", context->deviceItem.pname);
51-
for (const auto& deviceAlgorithm : deviceAlgorithms) {
52-
algorithms.push_back(deviceAlgorithm);
53-
}
54-
const auto& deviceDebugs = context->rteDevice->GetEffectiveProperties("debug", context->deviceItem.pname);
55-
for (const auto& deviceDebug : deviceDebugs) {
56-
debugs.push_back(deviceDebug);
57-
}
58-
const auto& deviceDebugSequences = context->rteDevice->GetEffectiveProperties("sequence", context->deviceItem.pname);
59-
for (const auto& deviceDebugSequence : deviceDebugSequences) {
60-
debugSequences.push_back(deviceDebugSequence);
53+
for (const auto& [pname, context] : pnames) {
54+
if (context->devicePack) {
55+
m_runDebug.devicePack = context->devicePack->GetPackageID(true);
56+
const auto& deviceAlgorithms = context->rteDevice->GetEffectiveProperties("algorithm", pname);
57+
for (const auto& deviceAlgorithm : deviceAlgorithms) {
58+
PushBackUniquely(algorithms, deviceAlgorithm, pname);
59+
}
60+
const auto& deviceDebugs = context->rteDevice->GetEffectiveProperties("debug", pname);
61+
for (const auto& deviceDebug : deviceDebugs) {
62+
PushBackUniquely(debugs, deviceDebug, pname);
63+
}
64+
const auto& deviceDebugSequences = context->rteDevice->GetEffectiveProperties("sequence", pname);
65+
for (const auto& deviceDebugSequence : deviceDebugSequences) {
66+
PushBackUniquely(debugSequences, deviceDebugSequence, pname);
67+
}
6168
}
6269
}
6370

6471
// board collections
6572
if (context->boardPack) {
6673
m_runDebug.boardPack = context->boardPack->GetPackageID(true);
67-
context->rteBoard->GetChildrenByTag("algorithm", algorithms);
74+
Collection<RteItem*> boardAlgorithms;
75+
context->rteBoard->GetChildrenByTag("algorithm", boardAlgorithms);
76+
for (const auto& boardAlgorithm : boardAlgorithms) {
77+
PushBackUniquely(algorithms, boardAlgorithm, boardAlgorithm->GetAttribute("Pname"));
78+
}
79+
}
80+
81+
// sort collections starting with specific pnames
82+
for (auto vec : { &algorithms, &debugs, &debugSequences }) {
83+
sort(vec->begin(), vec->end(), [](auto& left, auto& right) {
84+
return left.second.size() < right.second.size();
85+
});
6886
}
6987

7088
// set device/board programming algorithms
71-
for (const auto& algorithm : algorithms) {
89+
for (const auto& [algorithm, pname] : algorithms) {
7290
AlgorithmType item;
7391
item.algorithm = algorithm->GetOriginalAbsolutePath();
7492
item.start = algorithm->GetAttributeAsULL("start");
7593
item.size = algorithm->GetAttributeAsULL("size");
7694
item.ramStart = algorithm->GetAttributeAsULL("RAMstart");
7795
item.ramSize = algorithm->GetAttributeAsULL("RAMsize");
7896
item.bDefault = algorithm->GetAttributeAsBool("default");
97+
item.pname = pname.size() == 1 ? pname.front() : "";
7998
m_runDebug.algorithms.push_back(item);
8099
}
81100

@@ -89,12 +108,13 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
89108
}
90109

91110
// system descriptions
92-
for (const auto& debug : debugs) {
111+
for (const auto& [debug, pname] : debugs) {
93112
const auto& svd = debug->GetAttribute("svd");
94113
if (!svd.empty()) {
95114
FilesType item;
96115
item.file = debug->GetAbsolutePackagePath() + svd;
97116
item.type = "svd";
117+
item.pname = pname.size() == 1 ? pname.front() : "";
98118
m_runDebug.systemDescriptions.push_back(item);
99119
}
100120
}
@@ -113,7 +133,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
113133
}
114134

115135
// debug sequences
116-
for (const auto& debugSequence : debugSequences) {
136+
for (const auto& [debugSequence, pname] : debugSequences) {
117137
DebugSequencesType sequence;
118138
sequence.name = debugSequence->GetName();
119139
sequence.info = debugSequence->GetAttribute("info");
@@ -122,6 +142,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
122142
GetDebugSequenceBlock(debugSequenceBlock, block);
123143
sequence.blocks.push_back(block);
124144
}
145+
sequence.pname = pname.size() == 1 ? pname.front() : "";
125146
m_runDebug.debugSequences.push_back(sequence);
126147
}
127148

@@ -161,3 +182,13 @@ void ProjMgrRunDebug::GetDebugSequenceBlock(const RteItem* item, DebugSequencesB
161182
block.blocks.push_back(childBlock);
162183
}
163184
}
185+
186+
void ProjMgrRunDebug::PushBackUniquely(vector<pair<const RteItem*, vector<string>>>& vec, const RteItem* item, const string pname) {
187+
for (auto& [rteItem, pnames] : vec) {
188+
if (rteItem == item) {
189+
CollectionUtils::PushBackUniquely(pnames, pname);
190+
return;
191+
}
192+
}
193+
vec.push_back({ item, { pname } });
194+
}

0 commit comments

Comments
 (0)