Skip to content

Commit b279c76

Browse files
Bhaskar VishnuVardhan Chebroluheeran-xilinx
authored andcommitted
Updated p2p simple and p2p bandwidth design to support multiple cards (#405)
1 parent 7525d90 commit b279c76

File tree

11 files changed

+124
-173
lines changed

11 files changed

+124
-173
lines changed

host/p2p_bandwidth/Makefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ SDCARD := sd_card
5656
#Include Libraries
5757
include $(ABS_COMMON_REPO)/common/includes/opencl/opencl.mk
5858
include $(ABS_COMMON_REPO)/common/includes/xcl2/xcl2.mk
59-
CXXFLAGS += $(xcl2_CXXFLAGS)
60-
LDFLAGS += $(xcl2_LDFLAGS)
61-
HOST_SRCS += $(xcl2_SRCS)
59+
include $(ABS_COMMON_REPO)/common/includes/cmdparser/cmdparser.mk
60+
include $(ABS_COMMON_REPO)/common/includes/logger/logger.mk
61+
CXXFLAGS += $(xcl2_CXXFLAGS) $(cmdparser_CXXFLAGS) $(logger_CXXFLAGS)
62+
LDFLAGS += $(xcl2_LDFLAGS) $(cmdparser_LDFLAGS) $(logger_LDFLAGS)
63+
HOST_SRCS += $(xcl2_SRCS) $(cmdparser_SRCS) $(logger_SRCS)
6264
CXXFLAGS += $(opencl_CXXFLAGS) -Wall -O0 -g -std=c++11
6365
LDFLAGS += $(opencl_LDFLAGS)
6466

@@ -81,7 +83,7 @@ endif
8183

8284

8385
EXECUTABLE = host
84-
CMD_ARGS = $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1
86+
CMD_ARGS = $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1 -d 0
8587
EMCONFIG_DIR = $(TEMP_DIR)
8688
EMU_DIR = $(SDCARD)/data/emulation
8789

@@ -141,27 +143,27 @@ endif
141143
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
142144
ifeq ($(HOST_ARCH), x86)
143145
$(CP) $(EMCONFIG_DIR)/emconfig.json .
144-
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1
146+
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1 -d 0
145147
else
146148
$(ABS_COMMON_REPO)/common/utility/run_emulation.pl "./${LAUNCH_EMULATOR} | tee run_app.log" "./${RUN_APP_SCRIPT} $(TARGET)" "${RESULT_STRING}" "7"
147149
endif
148150
else
149151
ifeq ($(HOST_ARCH), x86)
150-
./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1
152+
./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1 -d 0
151153
endif
152154
endif
153155

154156
.PHONY: test
155157
test: $(EXECUTABLE)
156158
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
157159
ifeq ($(HOST_ARCH), x86)
158-
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1
160+
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1 -d 0
159161
else
160162
$(ABS_COMMON_REPO)/common/utility/run_emulation.pl "./${LAUNCH_EMULATOR} | tee embedded_run.log" "./${RUN_APP_SCRIPT} $(TARGET)" "${RESULT_STRING}" "7"
161163
endif
162164
else
163165
ifeq ($(HOST_ARCH), x86)
164-
./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1
166+
./$(EXECUTABLE) $(BUILD_DIR)/copy_kernel.xclbin -r /dev/nvme0n1 -d 0
165167
else
166168
$(ECHO) "Please copy the content of sd_card folder and data to an SD Card and run on the board"
167169
endif
@@ -170,7 +172,7 @@ endif
170172

171173
sd_card: gen_run_app
172174
ifneq ($(HOST_ARCH), x86)
173-
$(VPP) -t $(TARGET) --platform $(DEVICE) -p $(BUILD_DIR)/copy_kernel.xclbin --package.out_dir $(PACKAGE_OUT) --package.rootfs $(EDGE_COMMON_SW)/rootfs.ext4 --package.sd_file $(SD_IMAGE_FILE) --package.sd_file xrt.ini --package.sd_file $(RUN_APP_SCRIPT) --package.sd_file $(EXECUTABLE) --package.sd_file -r --package.sd_file /dev/nvme0n1 -o copy_kernel.xclbin
175+
$(VPP) -t $(TARGET) --platform $(DEVICE) -p $(BUILD_DIR)/copy_kernel.xclbin --package.out_dir $(PACKAGE_OUT) --package.rootfs $(EDGE_COMMON_SW)/rootfs.ext4 --package.sd_file $(SD_IMAGE_FILE) --package.sd_file xrt.ini --package.sd_file $(RUN_APP_SCRIPT) --package.sd_file $(EXECUTABLE) --package.sd_file -r --package.sd_file /dev/nvme0n1 --package.sd_file -d --package.sd_file 0 -o copy_kernel.xclbin
174176
endif
175177

176178
# Cleaning stuff

host/p2p_bandwidth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ src/host.cpp
3030
## COMMAND LINE ARGUMENTS
3131
Once the environment has been configured, the application can be executed by
3232
```
33-
./host <copy_kernel XCLBIN> -r /dev/nvme0n1
33+
./host <copy_kernel XCLBIN> -r /dev/nvme0n1 -d 0
3434
```
3535

3636
## COMMANDS FOR WINDOWS FLOW

host/p2p_bandwidth/description.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929
"runtime": [
3030
"OpenCL"
3131
],
32-
"match_ini": "false",
3332
"launch": [
3433
{
35-
"cmd_args": "BUILD/copy_kernel.xclbin -r /dev/nvme0n1",
34+
"cmd_args": "BUILD/copy_kernel.xclbin -r /dev/nvme0n1 -d 0",
3635
"name": "generic launch for all flows"
3736
}
3837
],
@@ -41,10 +40,14 @@
4140
"compiler": {
4241
"sources": [
4342
"REPO_DIR/common/includes/xcl2",
43+
"REPO_DIR/common/includes/cmdparser",
44+
"REPO_DIR/common/includes/logger",
4445
"src/host.cpp"
4546
],
4647
"includepaths": [
47-
"REPO_DIR/common/includes/xcl2"
48+
"REPO_DIR/common/includes/xcl2",
49+
"REPO_DIR/common/includes/cmdparser",
50+
"REPO_DIR/common/includes/logger"
4851
]
4952
},
5053
"linker" : {

host/p2p_bandwidth/src/host.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5151
// and XDMA (x). Conceptually, x, c and p happens consecutively. The pipeline
5252
// is designed so that c(n) and x(n) will happen in parallel with p(n+1).
5353

54+
#include "cmdlineparser.h"
5455
#include <chrono>
5556
#include <fcntl.h>
5657
#include <iomanip>
@@ -366,7 +367,7 @@ void exec_read_test() {
366367
}
367368

368369
void usage() {
369-
cout << "Options: <-r|-w> <path-to-SSD>" << endl;
370+
cout << "Options: <-r|-w> <path-to-SSD> <-d> <device id>" << endl;
370371
exit(EXIT_FAILURE);
371372
}
372373

@@ -388,7 +389,7 @@ int main(int argc, char **argv) {
388389
bool isWrite;
389390
char *filename;
390391

391-
if (argc != 4)
392+
if (argc != 6)
392393
usage();
393394
else if (strcmp(argv[2], "-r") == 0)
394395
isWrite = false;
@@ -434,6 +435,17 @@ int main(int argc, char **argv) {
434435
exit(EXIT_FAILURE);
435436
}
436437
cl_device_id device = devices.front();
438+
cl_uint dev_id = 0;
439+
440+
// Command Line Parser
441+
sda::utils::CmdLineParser parser;
442+
443+
parser.addSwitch("--device", "-d", "device id", "0");
444+
dev_id = atoi((parser.value("device")).c_str());
445+
if(dev_id <= num_devices)
446+
device = devices[dev_id];
447+
else
448+
cout << "The device_id provided using -d flag is outside the range of available devices\n";
437449

438450
context = clCreateContext(0, 1, &device, nullptr, nullptr, &err);
439451
if (err != CL_SUCCESS)

host/p2p_bandwidth/utils.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
8080
$(ECHO) 'export XILINX_VITIS=/mnt' >> run_app.sh
8181
$(ECHO) 'export XCL_EMULATION_MODE=$(TARGET)' >> run_app.sh
8282
endif
83-
$(ECHO) './$(EXECUTABLE) copy_kernel.xclbin -r nvme0n1' >> run_app.sh
83+
$(ECHO) './$(EXECUTABLE) copy_kernel.xclbin -r nvme0n1 -d 0' >> run_app.sh
8484
$(ECHO) 'return_code=$$?' >> run_app.sh
8585
$(ECHO) 'if [ $$return_code -ne 0 ]; then' >> run_app.sh
8686
$(ECHO) 'echo "ERROR: host run failed, RC=$$return_code"' >> run_app.sh

host/p2p_bandwidth/xrt.ini

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
[Debug]
22
profile=true
3-
device_profile=true
4-
5-
[Runtime]
6-
ert=false
7-

host/p2p_simple/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ ifneq ($(TARGET), hw)
7979
endif
8080

8181

82+
# Kernel linker flags
83+
LDCLFLAGS += --config ./adder.ini
8284

8385
EXECUTABLE = host
8486
CMD_ARGS = $(BUILD_DIR)/adder.xclbin /dev/nvme0n1

host/p2p_simple/adder.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kernel_frequency=290

host/p2p_simple/description.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"runtime": [
3232
"OpenCL"
3333
],
34-
"match_ini": "false",
3534
"launch": [
3635
{
3736
"cmd_args": "BUILD/adder.xclbin /dev/nvme0n1",
@@ -54,10 +53,11 @@
5453
"accelerators": [
5554
{
5655
"name": "adder",
57-
"location": "src/adder.cpp"
56+
"location": "src/adder.cpp"
5857
}
5958
],
60-
"name": "adder"
59+
"name": "adder",
60+
"ldclflags": "--config PROJECT/adder.ini"
6161
}
6262
],
6363
"contributors": [

0 commit comments

Comments
 (0)