Skip to content

Commit 1fa637f

Browse files
Update simple add sample (#8)
* Update simple add sample Signed-off-by: Maria, Moushumi <[email protected]> * Update make files Signed-off-by: Maria, Moushumi <[email protected]> * Update fpga make file Signed-off-by: Maria, Moushumi <[email protected]> * Add dpc_common.hpp * Update sample.json * Fix Makefile.win * Update Makefile.win * Update sample.json * Remove dpc_common.hpp
1 parent f3c2428 commit 1fa637f

File tree

12 files changed

+382
-173
lines changed

12 files changed

+382
-173
lines changed

DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ run:
1919
./$(USM_EXE_NAME)
2020

2121
run_buffers:
22-
./$(BBUFFER_EXE_NAME)
22+
./$(BUFFER_EXE_NAME)
2323

2424
clean:
2525
rm -rf $(USM_EXE_NAME) $(BUFFER_EXE_NAME)
Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,67 @@
11
CXX := dpcpp
22
CXXFLAGS = -O2 -g -std=c++17
33

4-
SRC := src/simple-add-usm.cpp
5-
BUFFERS_SRC := src/simple-add-buffers.cpp
4+
USM_SRC := src/simple-add-usm.cpp
5+
SRC := src/simple-add-buffers.cpp
66

7-
.PHONY: fpga_emu run_emu clean
7+
.PHONY: hw hw_usm fpga_emu fpga_emu_usm run_emu run_emu_usm clean
88

9-
fpga_emu_buffers: simple-add-buffers.fpga_emu_buffers
10-
fpga_emu: simple-add-usm.fpga_emu
9+
fpga_emu: simple-add-buffers.fpga_emu
10+
fpga_emu_usm: simple-add-usm.fpga_emu_usm
1111

12-
hw_buffers: simple-add-buffers.fpga
13-
hw: simple-add-usm.fpga
12+
hw: simple-add-buffers.fpga
13+
hw_usm: simple-add-usm.fpga
1414

15-
report_buffers: simple-add-buffers_report.a_buffers
16-
report: simple-add-usm_report.a
15+
report: simple-add-buffers_report.a_buffers
16+
report_usm: simple-add-usm_report.a_usm
1717

18-
simple-add-buffers.fpga_emu_buffers: $(BUFFERS_SRC)
18+
simple-add-buffers.fpga_emu: $(SRC)
1919
$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1
20-
simple-add-usm.fpga_emu: $(SRC)
21-
$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1
20+
simple-add-usm.fpga_emu_usm: $(USM_SRC)
21+
@#$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1
22+
@echo USM is not supported for FPGAs, yet
2223

2324

24-
a_buffers.o: $(BUFFERS_SRC)
25-
$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1
26-
a.o: $(SRC)
25+
a_buffers.o: $(SRC)
2726
$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1
27+
a_usm.o: $(USM_SRC)
28+
@#$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1
29+
@echo USM is not supported for FPGAs, yet
2830

2931

3032
simple-add-buffers.fpga: a_buffers.o
3133
$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -Xshardware
32-
simple-add-usm.fpga: a.o
33-
$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -Xshardware
34+
simple-add-usm.fpga: a_usm.o
35+
@#$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -Xshardware
36+
@echo USM is not supported for FPGAs, yet
3437

35-
run_emu_buffers: simple-add-buffers.fpga_emu_buffers
36-
./simple-add-buffers.fpga_emu_buffers
37-
run_emu: simple-add-usm.fpga_emu
38-
./simple-add-usm.fpga_emu
38+
run_emu: simple-add-buffers.fpga_emu
39+
./simple-add-buffers.fpga_emu
40+
run_emu_usm: simple-add-usm.fpga_emu_usm
41+
@#./simple-add-usm.fpga_emu_usm
42+
@echo USM is not supported for FPGAs, yet
3943

4044

41-
run_hw_buffers: simple-add-buffers.fpga
45+
run_hw: simple-add-buffers.fpga
4246
./simple-add-buffers.fpga
43-
run_hw: simple-add-usm.fpga
44-
./simple-add-usm.fpga
47+
run_hw_usm: simple-add-usm.fpga
48+
@#./simple-add-usm.fpga
49+
@echo USM is not supported for FPGAs, yet
4550

4651

47-
dev_buffers.o: $(BUFFERS_SRC)
48-
$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1
49-
dev.o: $(SRC)
52+
dev_buffers.o: $(SRC)
5053
$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1
54+
dev_usm.o: $(USM_SRC)
55+
@#$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1
56+
@echo USM is not supported for FPGAs, yet
5157

5258

5359
simple-add-buffers_report.a_buffers: dev_buffers.o
5460
$(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware
55-
simple-add-usm_report.a: dev.o
56-
$(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware
61+
simple-add-usm_report.a_usm: dev_usm.o
62+
@#$(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware
63+
@echo USM is not supported for FPGAs, yet
5764

5865

5966
clean:
60-
rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_buffers simple-add-buffers.fpga simple-add-usm.fpga *.a
67+
rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_usm simple-add-buffers.fpga simple-add-usm.fpga *.a
Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
CXX = dpcpp-cl
2-
CXXFLAGS = -O2 -EHsc -Zi
3-
EXE_NAME = simple-add-usm.exe
4-
SOURCES = src/simple-add-usm.cpp
5-
6-
all: main
7-
8-
main:
9-
$(CXX) $(CXXFLAGS) -o $(EXE_NAME) $(SOURCES)
10-
11-
run:
12-
$(EXE_NAME)
13-
14-
clean:
15-
del -rf $(EXE_NAME)
1+
CXX = dpcpp-cl
2+
CXXFLAGS = -O2 -EHsc -Zi
3+
4+
EXE_NAME = simple-add-usm.exe
5+
SOURCES = src/simple-add-usm.cpp
6+
7+
BUFFERS_EXE_NAME = simple-add-buffers.exe
8+
BUFFERS_SOURCES = src/simple-add-buffers.cpp
9+
10+
all: main
11+
12+
main:
13+
$(CXX) $(CXXFLAGS) -o $(EXE_NAME) $(SOURCES)
14+
15+
build_buffers:
16+
$(CXX) $(CXXFLAGS) -o $(BUFFERS_EXE_NAME) $(BUFFERS_SOURCES)
17+
18+
run:
19+
$(EXE_NAME)
20+
21+
run_buffers:
22+
$(BUFFERS_EXE_NAME)
23+
24+
clean:
25+
del -rf $(EXE_NAME) $(BUFFERS_EXE_NAME)
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
CXX = dpcpp-cl
22
CXXFLAGS = -O2 -EHsc -Zi
3-
SOURCES = src/simple-add-usm.cpp
4-
EXE_NAME_FPGA_EMU = simple-add-usm.fpga_emu.exe
3+
LDFLAGS =
4+
5+
SRC = src/simple-add-buffers.cpp
6+
USM_SRC = src/simple-add-usm.cpp
7+
8+
EXE = simple-add-buffers.fpga_emu.exe
9+
USM_EXE = simple-add-usm.fpga_emu_usm.exe
510

611
all: fpga_emu
712

8-
fpga_emu:
9-
$(CXX) $(CXXFLAGS) -fintelfpga $(SOURCES) -o $(EXE_NAME_FPGA_EMU) -DFPGA_EMULATOR=1
13+
fpga_emu: $(SRC)
14+
$(CXX) $(CXXFLAGS) -fintelfpga $(SRC) -o $(EXE) -DFPGA_EMULATOR=1
15+
16+
fpga_emu_usm: $(SRC)
17+
@echo USM is not supported for FPGAs, yet
1018

1119
run:
12-
$(EXE_NAME_FPGA_EMU)
20+
$(EXE)
21+
22+
run_usm:
23+
@echo USM is not supported for FPGAs, yet
1324

1425
clean:
15-
del -rf $(EXE_NAME_FPGA_EMU)
26+
del /f *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_usm *.a $(EXE) $(USM_EXE)

DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ This code sample is licensed under MIT license.
2727

2828
## Building the `simple add DPC++` Program for CPU and GPU
2929

30+
## Include Files
31+
The include folder is located at %ONEAPI_ROOT%\dev-utilities\latest\include on your development system".
32+
3033
### On a Linux* System
3134
Perform the following steps:
3235
1. Build the `simple-add-dpc++` program using the following make commands (default uses USM):
@@ -123,15 +126,7 @@ Perform the following steps:
123126
2. Select the menu sequence **File** > **Open** > **Project/Solution**.
124127
3. Locate the `simple-add` folder.
125128
4. Select the `simple-add.sln` file.
126-
5. Select the configuration 'Debug-fpga' or 'Release-fpga' that have the necessary project settings already below:
127-
128-
Under the 'Project Property' dialog:
129-
130-
a. Select the **DPC++** tab.
131-
b. In the **General** subtab, the **Perform ahead of time compilation for the FPGA** setting is set to **Yes**.
132-
c. In the **Preprocessor** subtab, the **Preprocessor Definitions" setting has **FPGA_EMULATOR** added.
133-
d. Close the dialog.
134-
129+
5. Select the configuration 'Debug-fpga'
135130
6. Select **Project** > **Build** menu option to build the selected configuration.
136131
7. Select **Debug** > **Start Without Debugging** menu option to run the program.
137132

DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"guid" : "49C65CB6-F9FA-4E3C-B8BE-4A141E4E0F07",
23
"name": "Simple Add",
34
"categories": ["Toolkit/Get Started", "Toolkit/Intel® oneAPI Base Toolkit/oneAPI DPC++ Compiler/CPU, GPU and FPGA"],
45
"description": "Simple program that adds two large vectors in parallel. Provides a ‘Hello World!’ like sample to ensure your environment is setup correctly using Data Parallel C++.",
@@ -12,30 +13,31 @@
1213
{
1314
"id": "cpu_usm",
1415
"steps": [
16+
"make clean",
1517
"make all",
16-
"make run",
17-
"make clean"
18+
"make run"
1819
]
1920
},
2021
{
2122
"id": "cpu_buffers",
2223
"steps": [
24+
"make clean",
2325
"make build_buffers",
24-
"make run_buffers",
25-
"make clean"
26+
"make run_buffers"
2627
]
2728
},
2829
{
2930
"id": "fpga_emu_buffers",
3031
"steps": [
32+
"make clean -f Makefile.fpga",
3133
"make fpga_emu -f Makefile.fpga",
32-
"make run_emu -f Makefile.fpga",
33-
"make clean -f Makefile.fpga"
34+
"make run_emu -f Makefile.fpga"
3435
]
3536
},
3637
{
3738
"id": "fpga_report_buffers",
3839
"steps": [
40+
"make clean -f Makefile.fpga",
3941
"make report -f Makefile.fpga"
4042
]
4143
}
@@ -62,7 +64,7 @@
6264
"steps": [
6365
"nmake -f Makefile.win.fpga",
6466
"nmake -f Makefile.win.fpga run",
65-
"nmake -f Makefile.win.fpga clean"
67+
"nmake -f Makefile.win.fpga clean",
6668
]
6769
}
6870
]

0 commit comments

Comments
 (0)