Skip to content

FPGA: Remove db query 9 in 2023.0 #1257

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

Merged
merged 1 commit into from
Dec 6, 2022
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
24 changes: 6 additions & 18 deletions DirectProgramming/DPC++FPGA/ReferenceDesigns/db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,12 @@ This design leverages concepts discussed in the [FPGA tutorials](/DirectProgramm

### Query Implementations

The following sections describe at a high level how queries 1, 9, 11 and 12 are implemented on the FPGA using a set of generalized database operators (found in `db_utils/`). In the block diagrams below, the blocks are oneAPI kernels, and the arrows represent `pipes` that shows the flow of data from one kernel to another.
The following sections describe at a high level how queries 1, 11 and 12 are implemented on the FPGA using a set of generalized database operators (found in `db_utils/`). In the block diagrams below, the blocks are oneAPI kernels, and the arrows represent `pipes` that shows the flow of data from one kernel to another.

#### Query 1

Query 1 is the simplest of the four queries and only uses the `Accumulator` database operator. The query streams in each row of the LINEITEM table and performs computation on each row.

#### Query 9

Query 9 is the most complicated of the four queries and utilizes all database operators (`LikeRegex`, `Accumulator`, `MapJoin`, `MergeJoin`, `DuplicateMergeJoin`, and `FifoSort`). The block diagram of the design is shown below.

![](assets/q9.png)

#### Query 11

Query 11 showcases the `MapJoin` and `FifoSort` database operators. The block diagram of the design is shown below.
Expand All @@ -98,8 +92,6 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
|`dbdata.cpp` | Contains code to parse the database input files and validate the query output
|`dbdata.hpp` | Definitions of database related data structures and parsing functions
|`query1/query1_kernel.cpp` | Contains the kernel for Query 1
|`query9/query9_kernel.cpp` | Contains the kernel for Query 9
|`query9/pipe_types.cpp` | All data types and instantiations for pipes used in query 9
|`query11/query11_kernel.cpp` | Contains the kernel for Query 11
|`query11/pipe_types.cpp` | All data types and instantiations for pipes used in query 11
|`query12/query12_kernel.cpp` | Contains the kernel for Query 12
Expand Down Expand Up @@ -141,7 +133,7 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
cd build
cmake .. -DQUERY=1
```
`-DQUERY=<QUERY_NUMBER>` can be any of the following query numbers: `1`, `9`, `11` or `12`.
`-DQUERY=<QUERY_NUMBER>` can be any of the following query numbers: `1`, `11` or `12`.

3. Compile the design. (The provided targets match the recommended development flow.)

Expand All @@ -155,14 +147,12 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
```
The report resides at `db_report.prj/reports/report.html`.

>**Note**: If you are compiling Query 9 (`-DQUERY=9`), expect a long report generation time. You can download pre-generated reports from [https://iotdk.intel.com/fpga-precompiled-binaries/latest/db.fpga.tar.gz](https://iotdk.intel.com/fpga-precompiled-binaries/latest/db.fpga.tar.gz).

3. Compile for FPGA hardware (longer compile time, targets FPGA device).

```
make fpga
```
When building for hardware, the default scale factor is **1**. To use the smaller scale factor of 0.01, add the flag `-DSF_SMALL=1` to the original `cmake` command. For example: `cmake .. -DQUERY=9 -DSF_SMALL=1`. See the [Database files](#database-files) for more information.
When building for hardware, the default scale factor is **1**. To use the smaller scale factor of 0.01, add the flag `-DSF_SMALL=1` to the original `cmake` command. For example: `cmake .. -DQUERY=11 -DSF_SMALL=1`. See the [Database files](#database-files) for more information.

(Optional) The hardware compile may take several hours to complete. You can download a pre-compiled binary (compatible with Linux* Ubuntu* 18.04) for an Intel® FPGA PAC D5005 (with Intel Stratix® 10 SX) from [https://iotdk.intel.com/fpga-precompiled-binaries/latest/db.fpga.tar.gz](https://iotdk.intel.com/fpga-precompiled-binaries/latest/db.fpga.tar.gz).

Expand All @@ -177,7 +167,7 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
cd build
cmake -G "NMake Makefiles" -DQUERY=1
```
`-DQUERY=<QUERY_NUMBER>` can be any of the following query numbers: `1`, `9`, `11` or `12`.
`-DQUERY=<QUERY_NUMBER>` can be any of the following query numbers: `1`, `11` or `12`.

3. Compile the design. (The provided targets match the recommended development flow.)

Expand All @@ -192,8 +182,6 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
```
The report resides at `db_report.prj/reports/report.html` directory.

>**Note**: If you are compiling Query 9 (`-DQUERY=9`), expect a long report generation time.

3. Compile for FPGA hardware (longer compile time, targets FPGA device):
```
nmake fpga
Expand All @@ -219,7 +207,7 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
```
./db.fpga_emu --dbroot=../data/sf0.01 --test
```
(Optional) Run the design for queries `9`, `11` and `12`.
(Optional) Run the design for queries `11` and `12`.

2. Run the design on an FPGA device.
```
Expand All @@ -232,7 +220,7 @@ Query 12 showcases the `MergeJoin` database operator. The block diagram of the d
```
db.fpga_emu.exe --dbroot=../data/sf0.01 --test
```
(Optional) Run the design for queries `9`, `11` and `12`.
(Optional) Run the design for queries `11` and `12`.

2. Run the sample on an FPGA device.
```
Expand Down
Binary file not shown.
24 changes: 0 additions & 24 deletions DirectProgramming/DPC++FPGA/ReferenceDesigns/db/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@
"./db.fpga_emu --dbroot=../data/sf0.01 --test"
]
},
{
"id": "fpga_emu_q9",
"steps": [
"icpx --version",
"mkdir build-q9",
"cd build-q9",
"cmake .. -DQUERY=9",
"make fpga_emu",
"./db.fpga_emu --dbroot=../data/sf0.01 --test"
]
},
{
"id": "fpga_emu_q11",
"steps": [
Expand Down Expand Up @@ -108,19 +97,6 @@
"db.fpga_emu.exe --dbroot=../data/sf0.01 --test"
]
},
{
"id": "fpga_emu_q9",
"steps": [
"icpx --version",
"cd ../..",
"mkdir build-q9",
"cd build-q9",
"xcopy /E ..\\ReferenceDesigns\\db\\data ..\\data\\",
"cmake -G \"NMake Makefiles\" ../ReferenceDesigns/db -DQUERY=9",
"nmake fpga_emu",
"db.fpga_emu.exe --dbroot=../data/sf0.01 --test"
]
},
{
"id": "fpga_emu_q11",
"steps": [
Expand Down
24 changes: 6 additions & 18 deletions DirectProgramming/DPC++FPGA/ReferenceDesigns/db/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ endif()
if(${QUERY} EQUAL 1)
set(DEFAULT_BOARD "intel_a10gx_pac:pac_a10")
set(DEFAULT_BOARD_STR "Intel Arria(R) 10 GX")
elseif(${QUERY} EQUAL 9)
set(DEFAULT_BOARD "intel_s10sx_pac:pac_s10")
set(DEFAULT_BOARD_STR "Intel Stratix(R) 10 SX")
elseif(${QUERY} EQUAL 11)
set(DEFAULT_BOARD "intel_s10sx_pac:pac_s10")
set(DEFAULT_BOARD_STR "Intel Stratix(R) 10 SX")
Expand Down Expand Up @@ -45,8 +42,8 @@ else()
endif()

# ensure a supported query was requested
if(NOT ${QUERY} EQUAL 1 AND NOT ${QUERY} EQUAL 9 AND NOT ${QUERY} EQUAL 11 AND NOT ${QUERY} EQUAL 12)
message(FATAL_ERROR "\tQUERY ${QUERY} not supported (supported queries are 1, 9, 11 and 12)")
if(NOT ${QUERY} EQUAL 1 AND NOT ${QUERY} EQUAL 11 AND NOT ${QUERY} EQUAL 12)
message(FATAL_ERROR "\tQUERY ${QUERY} not supported (supported queries are 1, 11 and 12)")
endif()

# Pick the default seed if the user did not specify one to CMake.
Expand All @@ -55,8 +52,6 @@ if(NOT DEFINED SEED)
if(${FPGA_DEVICE} MATCHES ".*a10.*")
if(${QUERY} EQUAL 1)
set(SEED "-Xsseed=2")
elseif(${QUERY} EQUAL 9)
set(SEED "-Xsseed=2")
elseif(${QUERY} EQUAL 11)
set(SEED "-Xsseed=4")
elseif(${QUERY} EQUAL 12)
Expand All @@ -65,8 +60,6 @@ if(NOT DEFINED SEED)
elseif(${FPGA_DEVICE} MATCHES ".*s10.*")
if(${QUERY} EQUAL 1)
set(SEED "-Xsseed=3")
elseif(${QUERY} EQUAL 9)
set(SEED "-Xsseed=2")
elseif(${QUERY} EQUAL 11)
set(SEED "-Xsseed=3")
elseif(${QUERY} EQUAL 12)
Expand All @@ -75,8 +68,6 @@ if(NOT DEFINED SEED)
elseif(${FPGA_DEVICE} MATCHES ".*agilex.*")
if(${QUERY} EQUAL 1)
set(SEED "-Xsseed=2")
elseif(${QUERY} EQUAL 9)
set(SEED "-Xsseed=2")
elseif(${QUERY} EQUAL 11)
set(SEED "-Xsseed=4")
elseif(${QUERY} EQUAL 12)
Expand All @@ -91,10 +82,10 @@ if(IGNORE_DEFAULT_SEED)
set(SEED "")
endif()

# Error out if trying to run Q9 or Q11 on Arria 10
# Error out if trying to run Q11 on Arria 10
if (${FPGA_DEVICE} MATCHES ".*a10.*")
if(${QUERY} EQUAL 9 OR ${QUERY} EQUAL 11)
message(FATAL_ERROR "Queries 9 and 11 are not supported on Arria 10 devices")
if(${QUERY} EQUAL 11)
message(FATAL_ERROR "Query 11 is not supported on Arria 10 devices")
endif()
endif()

Expand All @@ -115,17 +106,14 @@ endif()
if(${QUERY} EQUAL 1)
set(DEVICE_SOURCE query1/query1_kernel.cpp)
set(DEVICE_HEADER query1/query1_kernel.hpp)
elseif(${QUERY} EQUAL 9)
set(DEVICE_SOURCE query9/query9_kernel.cpp)
set(DEVICE_HEADER query9/query9_kernel.hpp)
elseif(${QUERY} EQUAL 11)
set(DEVICE_SOURCE query11/query11_kernel.cpp)
set(DEVICE_HEADER query11/query11_kernel.hpp)
elseif(${QUERY} EQUAL 12)
set(DEVICE_SOURCE query12/query12_kernel.cpp)
set(DEVICE_HEADER query12/query12_kernel.hpp)
else()
message(FATAL_ERROR "\tQUERY ${QUERY} not supported (supported queries are 1, 9, 11 and 12)")
message(FATAL_ERROR "\tQUERY ${QUERY} not supported (supported queries are 1, 11 and 12)")
endif()

# A SYCL ahead-of-time (AoT) compile processes the device code in two stages.
Expand Down
61 changes: 2 additions & 59 deletions DirectProgramming/DPC++FPGA/ReferenceDesigns/db/src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ using namespace sycl;
bool DoQuery1(queue& q, Database& dbinfo, std::string& db_root_dir,
std::string& args, bool test, bool print, double& kernel_latency,
double& total_latency);
#elif (QUERY == 9)
#include "query9/query9_kernel.hpp"
bool DoQuery9(queue& q, Database& dbinfo, std::string& db_root_dir,
std::string& args, bool test, bool print, double& kernel_latency,
double& total_latency);
#elif (QUERY == 11)
#include "query11/query11_kernel.hpp"
bool DoQuery11(queue& q, Database& dbinfo, std::string& db_root_dir,
Expand Down Expand Up @@ -173,9 +168,9 @@ int main(int argc, char* argv[]) {
}

// make sure the query is supported
if (!(query == 1 || query == 9 || query == 11 || query == 12)) {
if (!(query == 1 || query == 11 || query == 12)) {
std::cerr << "ERROR: unsupported query (" << query << "). "
<< "Only queries 1, 9, 11 and 12 are supported\n";
<< "Only queries 1, 11 and 12 are supported\n";
return 1;
}

Expand Down Expand Up @@ -229,13 +224,6 @@ int main(int argc, char* argv[]) {
success = DoQuery1(q, dbinfo, db_root_dir, args,
test_query, print_result,
kernel_latency[run], total_latency[run]);
#endif
} else if (query == 9) {
// query9
#if (QUERY == 9)
success = DoQuery9(q, dbinfo, db_root_dir, args,
test_query, print_result,
kernel_latency[run], total_latency[run]);
#endif
} else if (query == 11) {
// query11
Expand Down Expand Up @@ -363,51 +351,6 @@ bool DoQuery1(queue& q, Database& dbinfo, std::string& db_root_dir,
}
#endif

#if (QUERY == 9)
bool DoQuery9(queue& q, Database& dbinfo, std::string& db_root_dir,
std::string& args, bool test, bool print, double& kernel_latency,
double& total_latency) {
// the default colour regex based on the TPCH documents
std::string colour = "GREEN";

// parse the query arguments
if (!test && !args.empty()) {
std::stringstream ss(args);
std::getline(ss, colour, ',');
} else {
if (!args.empty()) {
std::cout << "Testing query 9, therefore ignoring the '--args' flag\n";
}
}

// convert the colour regex to uppercase characters (convention)
transform(colour.begin(), colour.end(), colour.begin(), ::toupper);

std::cout << "Running Q9 with colour regex: " << colour << std::endl;

// the output of the query
std::array<DBDecimal, 25 * 2020> sum_profit;

// perform the query
bool success = SubmitQuery9(q, dbinfo, colour, sum_profit, kernel_latency,
total_latency);

if (success) {
// validate the results of the query, if requested
if (test) {
success = dbinfo.ValidateQ9(db_root_dir, sum_profit);
}

// print the results of the query, if requested
if (print) {
dbinfo.PrintQ9(sum_profit);
}
}

return success;
}
#endif

#if (QUERY == 11)
bool DoQuery11(queue& q, Database& dbinfo, std::string& db_root_dir,
std::string& args, bool test, bool print, double& kernel_latency,
Expand Down
Loading