Skip to content

Commit b428360

Browse files
committed
Merge branch 'master' into development
2 parents 56a1ac4 + adf03d4 commit b428360

File tree

2 files changed

+53
-3
lines changed
  • DirectProgramming/C++SYCL_FPGA

2 files changed

+53
-3
lines changed

DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/db/src/dbdata.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,56 @@ void Database::PrintQ9(std::array<DBDecimal, 25 * 2020>& sum_profit) {
904904

905905
}
906906

907+
//
908+
// print the results of Query 9
909+
//
910+
void Database::PrintQ9(std::array<DBDecimal, 25 * 2020>& sum_profit) {
911+
// row of Q9 output for local sorting
912+
struct Row {
913+
Row(std::string& nation, int year, DBDecimal sum_profit)
914+
: nation(nation), year(year), sum_profit(sum_profit) {}
915+
std::string nation;
916+
int year;
917+
DBDecimal sum_profit;
918+
919+
void print() {
920+
std::cout << nation << "|" << year << "|"
921+
<< (double)(sum_profit) / (100.0 * 100.0) << "\n";
922+
}
923+
};
924+
925+
// create the rows
926+
std::vector<Row> outrows;
927+
for (unsigned char nat = 0; nat < kNationTableSize; nat++) {
928+
std::string nation_name = n.key_name_map[nat];
929+
for (int y = 1992; y <= 1998; y++) {
930+
outrows.push_back(Row(nation_name, y, sum_profit[y * 25 + nat]));
931+
}
932+
}
933+
934+
// sort rows by year
935+
std::sort(outrows.begin(), outrows.end(),
936+
[](const Row& a, const Row& b) -> bool {
937+
return a.year > b.year;
938+
});
939+
940+
// sort rows by nation
941+
// stable_sort() preserves the order of the previous sort
942+
std::stable_sort(outrows.begin(), outrows.end(),
943+
[](const Row& a, const Row& b) -> bool {
944+
return a.nation < b.nation;
945+
});
946+
947+
// print the header
948+
std::cout << "nation|o_year|sum_profit\n";
949+
950+
// print the results
951+
std::cout << std::fixed << std::setprecision(2);
952+
for (int i = 0; i < outrows.size(); i++) {
953+
outrows[i].print();
954+
}
955+
}
956+
907957
//
908958
// print the results of Query 11
909959
//

DirectProgramming/C++SYCL_FPGA/Tutorials/DesignPatterns/shannonization/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ flowchart LR
3939
tier2("Tier 2: Explore the Fundamentals")
4040
tier3("Tier 3: Explore the Advanced Techniques")
4141
tier4("Tier 4: Explore the Reference Designs")
42-
42+
4343
tier1 --> tier2 --> tier3 --> tier4
44-
44+
4545
style tier1 fill:#0071c1,stroke:#0071c1,stroke-width:1px,color:#fff
4646
style tier2 fill:#0071c1,stroke:#0071c1,stroke-width:1px,color:#fff
4747
style tier3 fill:#f96,stroke:#333,stroke-width:1px,color:#fff
@@ -424,4 +424,4 @@ PASSED
424424
Code samples are licensed under the MIT license. See
425425
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.
426426

427-
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt).
427+
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt).

0 commit comments

Comments
 (0)