From 8a471f1ef1d3ec1a08b7465652c78f6451d5be9e Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Thu, 2 Jul 2020 11:45:46 -0700 Subject: [PATCH 1/9] Update simple add sample Signed-off-by: Maria, Moushumi --- .../DenseLinearAlgebra/simple-add/Makefile | 2 +- .../DenseLinearAlgebra/simple-add/README.md | 13 +- .../DenseLinearAlgebra/simple-add/sample.json | 1 + .../simple-add/simple-add-buffers.vcxproj | 193 ++++++++++++++++++ .../simple-add/simple-add-usm.vcxproj | 63 +++++- .../simple-add/simple-add.sln | 25 ++- .../simple-add/src/dpc_common.hpp | 63 ------ .../simple-add/src/simple-add-buffers.cpp | 25 +-- .../simple-add/src/simple-add-usm.cpp | 25 +-- 9 files changed, 295 insertions(+), 115 deletions(-) create mode 100644 DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-buffers.vcxproj delete mode 100644 DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile index 3f63267f90..b758899000 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile @@ -19,7 +19,7 @@ run: ./$(USM_EXE_NAME) run_buffers: - ./$(BBUFFER_EXE_NAME) + ./$(BUFFER_EXE_NAME) clean: rm -rf $(USM_EXE_NAME) $(BUFFER_EXE_NAME) \ No newline at end of file diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/README.md b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/README.md index 94cc2dd722..f790cc106e 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/README.md +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/README.md @@ -27,6 +27,9 @@ This code sample is licensed under MIT license. ## Building the `simple add DPC++` Program for CPU and GPU +## Include Files +The include folder is located at %ONEAPI_ROOT%\dev-utilities\latest\include on your development system". + ### On a Linux* System Perform the following steps: 1. Build the `simple-add-dpc++` program using the following make commands (default uses USM): @@ -123,15 +126,7 @@ Perform the following steps: 2. Select the menu sequence **File** > **Open** > **Project/Solution**. 3. Locate the `simple-add` folder. 4. Select the `simple-add.sln` file. -5. Select the configuration 'Debug-fpga' or 'Release-fpga' that have the necessary project settings already below: - - Under the 'Project Property' dialog: - - a. Select the **DPC++** tab. - b. In the **General** subtab, the **Perform ahead of time compilation for the FPGA** setting is set to **Yes**. - c. In the **Preprocessor** subtab, the **Preprocessor Definitions" setting has **FPGA_EMULATOR** added. - d. Close the dialog. - +5. Select the configuration 'Debug-fpga' 6. Select **Project** > **Build** menu option to build the selected configuration. 7. Select **Debug** > **Start Without Debugging** menu option to run the program. diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json index 74cadb2120..eee33576e0 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json @@ -1,4 +1,5 @@ { + "guid" : "49C65CB6-F9FA-4E3C-B8BE-4A141E4E0F07", "name": "Simple Add", "categories": ["Toolkit/Get Started", "Toolkit/Intel® oneAPI Base Toolkit/oneAPI DPC++ Compiler/CPU, GPU and FPGA"], "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++.", diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-buffers.vcxproj b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-buffers.vcxproj new file mode 100644 index 0000000000..8ad66fd8df --- /dev/null +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-buffers.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug-fpga + x64 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {5d244b6f-a460-4179-aa5a-4f3bdff79f6b} + Win32Proj + simple_add_buffers + $(WindowsSDKVersion.Replace("\","")) + + + + Application + true + Intel(R) oneAPI DPC++ Compiler + Unicode + + + Application + true + Intel(R) oneAPI DPC++ Compiler + Unicode + + + Application + false + Intel(R) oneAPI DPC++ Compiler + true + Unicode + + + Application + true + Intel(R) oneAPI DPC++ Compiler + Unicode + + + Application + true + Intel(R) oneAPI DPC++ Compiler + Unicode + + + Application + false + Intel(R) oneAPI DPC++ Compiler + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + false + + + false + + + + + + + + + + Console + true + + + + + + + + + + + Console + true + + + + + + + + + false + %(PreprocessorDefinitions) + + + Console + true + + + + + + + + + true + FPGA_EMULATOR=1;%(PreprocessorDefinitions) + + + Console + true + + + + + + + + + + + Console + true + true + true + + + + + + + + + false + %(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-usm.vcxproj b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-usm.vcxproj index ce173eb881..6997512a4a 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-usm.vcxproj +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add-usm.vcxproj @@ -1,6 +1,10 @@ + + Debug-fpga + x64 + Debug x64 @@ -15,7 +19,7 @@ {1c022788-7017-4279-8c45-fae9940cc775} Win32Proj simple_add_usm - $(WindowsSDKVersion) + $(WindowsSDKVersion.Replace("\","")) @@ -24,6 +28,12 @@ Intel(R) oneAPI DPC++ Compiler Unicode + + Application + true + Intel(R) oneAPI DPC++ Compiler + Unicode + Application false @@ -37,6 +47,12 @@ Intel(R) oneAPI DPC++ Compiler Unicode + + Application + true + Intel(R) oneAPI DPC++ Compiler + Unicode + Application false @@ -52,12 +68,18 @@ + + + + + + @@ -65,9 +87,15 @@ true + + true + true + + true + false @@ -86,13 +114,41 @@ true + + + + + + + + + Console + true + + + + + + + + + + + + Console + true + + + /std:c++17 + true + FPGA_EMULATOR=1;%(PreprocessorDefinitions) Console @@ -131,10 +187,7 @@ - - - - + \ No newline at end of file diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add.sln b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add.sln index 0a2063cb4e..4dd5579876 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add.sln +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/simple-add.sln @@ -5,28 +5,27 @@ VisualStudioVersion = 15.0.28307.1145 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple-add-usm", "simple-add-usm.vcxproj", "{1C022788-7017-4279-8C45-FAE9940CC775}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple-add-buffers", "simple-add-buffers.vcxproj", "{5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Debug-fpga|x64 = Debug-fpga|x64 - Debug-fpga|x86 = Debug-fpga|x86 Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1C022788-7017-4279-8C45-FAE9940CC775}.Debug|x64.ActiveCfg = Debug|x64 {1C022788-7017-4279-8C45-FAE9940CC775}.Debug|x64.Build.0 = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Debug|x86.ActiveCfg = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Debug|x86.Build.0 = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Debug-fpga|x64.ActiveCfg = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Debug-fpga|x64.Build.0 = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Debug-fpga|x86.ActiveCfg = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Debug-fpga|x86.Build.0 = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Release|x64.ActiveCfg = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Release|x64.Build.0 = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Release|x86.ActiveCfg = Debug|x64 - {1C022788-7017-4279-8C45-FAE9940CC775}.Release|x86.Build.0 = Debug|x64 + {1C022788-7017-4279-8C45-FAE9940CC775}.Debug-fpga|x64.ActiveCfg = Debug-fpga|x64 + {1C022788-7017-4279-8C45-FAE9940CC775}.Debug-fpga|x64.Build.0 = Debug-fpga|x64 + {1C022788-7017-4279-8C45-FAE9940CC775}.Release|x64.ActiveCfg = Release|x64 + {1C022788-7017-4279-8C45-FAE9940CC775}.Release|x64.Build.0 = Release|x64 + {5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}.Debug|x64.ActiveCfg = Debug|x64 + {5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}.Debug|x64.Build.0 = Debug|x64 + {5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}.Debug-fpga|x64.ActiveCfg = Debug-fpga|x64 + {5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}.Debug-fpga|x64.Build.0 = Debug-fpga|x64 + {5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}.Release|x64.ActiveCfg = Release|x64 + {5D244B6F-A460-4179-AA5A-4F3BDFF79F6B}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp deleted file mode 100644 index d9f9194e6a..0000000000 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp +++ /dev/null @@ -1,63 +0,0 @@ -//============================================================== -// Copyright © 2020 Intel Corporation -// -// SPDX-License-Identifier: MIT -// ============================================================= - -#ifndef _DP_HPP -#define _DP_HPP - -#pragma once - -#include -#include - -#include - -namespace dpc { -// this exception handler with catch async exceptions -static auto exception_handler = [](cl::sycl::exception_list eList) { - for (std::exception_ptr const &e : eList) { - try { - std::rethrow_exception(e); - } catch (std::exception const &e) { -#if _DEBUG - std::cout << "Failure" << std::endl; -#endif - std::terminate(); - } - } -}; - -class queue : public cl::sycl::queue { - // Enable profiling by default - cl::sycl::property_list prop_list = - cl::sycl::property_list{cl::sycl::property::queue::enable_profiling()}; - - public: - queue() - : cl::sycl::queue(cl::sycl::default_selector{}, exception_handler, prop_list) {} - queue(cl::sycl::device_selector &d) - : cl::sycl::queue(d, exception_handler, prop_list) {} - queue(cl::sycl::device_selector &d, cl::sycl::property_list &p) - : cl::sycl::queue(d, exception_handler, p) {} -}; - -using Duration = std::chrono::duration; - -class Timer { - public: - Timer() : start(std::chrono::steady_clock::now()) {} - - Duration elapsed() { - auto now = std::chrono::steady_clock::now(); - return std::chrono::duration_cast(now - start); - } - - private: - std::chrono::steady_clock::time_point start; -}; - -}; // namespace dpc - -#endif diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-buffers.cpp b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-buffers.cpp index 9fe2e8c1e6..349ffe2026 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-buffers.cpp +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-buffers.cpp @@ -28,10 +28,11 @@ #endif using namespace sycl; +using namespace std; // Array type and data size for this example. constexpr size_t array_size = 10000; -typedef std::array IntArray; +typedef array IntArray; //************************************ // Iota in DPC++ on device. @@ -85,24 +86,24 @@ int main() { for (size_t i = 0; i < sequential.size(); i++) sequential[i] = value + i; try { - queue q(d_selector, dpc::exception_handler); + queue q(d_selector, dpc_common::exception_handler); // Print out the device information used for the kernel code. - std::cout << "Running on device: " - << q.get_device().get_info() << "\n"; - std::cout << "Array size: " << parallel.size() << "\n"; + cout << "Running on device: " + << q.get_device().get_info() << "\n"; + cout << "Array size: " << parallel.size() << "\n"; // Parallel iota in DPC++. IotaParallel(q, parallel, value); - } catch (exception const &e) { - std::cout << "An exception is caught while computing on device.\n"; - std::terminate(); + } catch (std::exception const &e) { + cout << "An exception is caught while computing on device.\n"; + terminate(); } // Verify two results are equal. for (size_t i = 0; i < sequential.size(); i++) { if (parallel[i] != sequential[i]) { - std::cout << "Failed on device.\n"; + cout << "Failed on device.\n"; return -1; } } @@ -114,10 +115,10 @@ int main() { for (int i = 0; i < indices_size; i++) { int j = indices[i]; if (i == indices_size - 1) std::cout << "...\n"; - std::cout << "[" << j << "]: " << j << " + " << value << " = " - << parallel[j] << "\n"; + cout << "[" << j << "]: " << j << " + " << value << " = " + << parallel[j] << "\n"; } - std::cout << "Successfully completed on device.\n"; + cout << "Successfully completed on device.\n"; return 0; } diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-usm.cpp b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-usm.cpp index e7d19a0ff0..1f37eaa361 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-usm.cpp +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/simple-add-usm.cpp @@ -28,6 +28,7 @@ #endif using namespace sycl; +using namespace std; // Array size for this example. constexpr size_t array_size = 10000; @@ -71,12 +72,12 @@ int main() { constexpr int value = 100000; try { - queue q(d_selector, dpc::exception_handler); + queue q(d_selector, dpc_common::exception_handler); // Print out the device information used for the kernel code. - std::cout << "Running on device: " - << q.get_device().get_info() << "\n"; - std::cout << "Array size: " << array_size << "\n"; + cout << "Running on device: " + << q.get_device().get_info() << "\n"; + cout << "Array size: " << array_size << "\n"; int *sequential = malloc_shared(array_size, q); int *parallel = malloc_shared(array_size, q); @@ -85,7 +86,7 @@ int main() { if (sequential != nullptr) free(sequential, q); if (parallel != nullptr) free(parallel, q); - std::cout << "Shared memory allocation failure.\n"; + cout << "Shared memory allocation failure.\n"; return -1; } @@ -98,7 +99,7 @@ int main() { // Verify two results are equal. for (size_t i = 0; i < array_size; i++) { if (parallel[i] != sequential[i]) { - std::cout << "Failed on device.\n"; + cout << "Failed on device.\n"; return -1; } } @@ -110,17 +111,17 @@ int main() { for (int i = 0; i < indices_size; i++) { int j = indices[i]; if (i == indices_size - 1) std::cout << "...\n"; - std::cout << "[" << j << "]: " << j << " + " << value << " = " - << sequential[j] << "\n"; + cout << "[" << j << "]: " << j << " + " << value << " = " + << sequential[j] << "\n"; } free(sequential, q); free(parallel, q); - } catch (exception const &e) { - std::cout << "An exception is caught while computing on device.\n"; - std::terminate(); + } catch (std::exception const &e) { + cout << "An exception is caught while computing on device.\n"; + terminate(); } - std::cout << "Successfully completed on device.\n"; + cout << "Successfully completed on device.\n"; return 0; } From abc813c80a8a1500fb4479317b3376eea2d3b800 Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Mon, 6 Jul 2020 12:54:47 -0700 Subject: [PATCH 2/9] Update make files Signed-off-by: Maria, Moushumi --- .../simple-add/Makefile.fpga | 69 ++++++++++--------- .../simple-add/Makefile.win | 40 +++++++---- .../simple-add/Makefile.win.fpga | 23 +++++-- 3 files changed, 80 insertions(+), 52 deletions(-) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga index 6c4005dd18..71918af6f9 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga @@ -1,60 +1,67 @@ CXX := dpcpp CXXFLAGS = -O2 -g -std=c++17 -SRC := src/simple-add-usm.cpp -BUFFERS_SRC := src/simple-add-buffers.cpp +USM_SRC := src/simple-add-usm.cpp +SRC := src/simple-add-buffers.cpp -.PHONY: fpga_emu run_emu clean +.PHONY: hw hw_usm fpga_emu fpga_usm run_emu run_emu_usm clean -fpga_emu_buffers: simple-add-buffers.fpga_emu_buffers -fpga_emu: simple-add-usm.fpga_emu +fpga_emu: simple-add-buffers.fpga_emu +fpga_emu_usm: simple-add-usm.fpga_emu -hw_buffers: simple-add-buffers.fpga -hw: simple-add-usm.fpga +hw: simple-add-buffers.fpga +hw_usm: simple-add-usm.fpga -report_buffers: simple-add-buffers_report.a_buffers -report: simple-add-usm_report.a +report: simple-add-buffers_report.a +report_usm: simple-add-usm_report.a -simple-add-buffers.fpga_emu_buffers: $(BUFFERS_SRC) +simple-add-buffers.fpga_emu: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1 -simple-add-usm.fpga_emu: $(SRC) - $(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1 +simple-add-usm.fpga_emu: $(USM_SRC) + @#$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1 + @echo USM is not supported for FPGAs, yet -a_buffers.o: $(BUFFERS_SRC) - $(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 -a.o: $(SRC) +a_buffers.o: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 +a_usm.o: $(USM_SRC) + @#$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 + @echo USM is not supported for FPGAs, yet simple-add-buffers.fpga: a_buffers.o $(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -Xshardware -simple-add-usm.fpga: a.o - $(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -Xshardware +simple-add-usm.fpga: a_usm.o + @#$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -Xshardware + @echo USM is not supported for FPGAs, yet -run_emu_buffers: simple-add-buffers.fpga_emu_buffers - ./simple-add-buffers.fpga_emu_buffers -run_emu: simple-add-usm.fpga_emu - ./simple-add-usm.fpga_emu +run_emu: simple-add-buffers.fpga_emu + ./simple-add-buffers.fpga_emu +run_emu_usm: simple-add-usm.fpga_emu + @#./simple-add-usm.fpga_emu + @echo USM is not supported for FPGAs, yet -run_hw_buffers: simple-add-buffers.fpga +run_hw: simple-add-buffers.fpga ./simple-add-buffers.fpga -run_hw: simple-add-usm.fpga - ./simple-add-usm.fpga +run_hw_usm: simple-add-usm.fpga + @#./simple-add-usm.fpga + @echo USM is not supported for FPGAs, yet -dev_buffers.o: $(BUFFERS_SRC) - $(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 -dev.o: $(SRC) +dev_buffers.o: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 +dev_usm.o: $(USM_SRC) + @#$(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 + @echo USM is not supported for FPGAs, yet -simple-add-buffers_report.a_buffers: dev_buffers.o - $(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware -simple-add-usm_report.a: dev.o +simple-add-buffers_report.a: dev_buffers.o $(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware +simple-add-usm_report.a: dev_usm.o + @#$(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware + @echo USM is not supported for FPGAs, yet clean: - rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_buffers simple-add-buffers.fpga simple-add-usm.fpga *.a \ No newline at end of file + rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_buffers simple-add-buffers.fpga simple-add-usm.fpga *.a diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win index 06c741b905..d59ec56431 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win @@ -1,15 +1,25 @@ -CXX = dpcpp-cl -CXXFLAGS = -O2 -EHsc -Zi -EXE_NAME = simple-add-usm.exe -SOURCES = src/simple-add-usm.cpp - -all: main - -main: - $(CXX) $(CXXFLAGS) -o $(EXE_NAME) $(SOURCES) - -run: - $(EXE_NAME) - -clean: - del -rf $(EXE_NAME) +CXX = dpcpp-cl +CXXFLAGS = -O2 -EHsc -Zi + +EXE_NAME = simple-add-usm.exe +SOURCES = src/simple-add-usm.cpp + +BUFFERS_EXE_NAME = simple-add-buffers.exe +BUFFERS_SOURCES = src/simple-add-buffers.cpp + +all: main + +main: + $(CXX) $(CXXFLAGS) -o $(EXE_NAME) $(SOURCES) + +build_buffers: + $(CXX) $(CXXFLAGS) -o $(BUFFERS_EXE_NAME) $(BUFFERS_SOURCES) + +run: + $(EXE_NAME) + +run_buffers: + $(BUFFERS_EXE_NAME) + +clean: + del -rf $(EXE_NAME) $(BUFFERS_EXE_NAME) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga index 6a6478f83f..23f391c06b 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga @@ -1,15 +1,26 @@ CXX = dpcpp-cl CXXFLAGS = -O2 -EHsc -Zi -SOURCES = src/simple-add-usm.cpp -EXE_NAME_FPGA_EMU = simple-add-usm.fpga_emu.exe +LDFLAGS = + +SRC = src/simple-add-buffers.cpp +USM_SRC = src/simple-add-usm.cpp + +EXE = simple-add-buffers.fpga_emu.exe +USM_EXE = simple-add-usm.fpga_emu.exe all: fpga_emu -fpga_emu: - $(CXX) $(CXXFLAGS) -fintelfpga $(SOURCES) -o $(EXE_NAME_FPGA_EMU) -DFPGA_EMULATOR=1 +fpga_emu: $(SRC) + $(CXX) $(CXXFLAGS) -fintelfpga $(SRC) -o $(EXE) -DFPGA_EMULATOR=1 + +fpga_emu_usm: $(SRC) + @echo USM is not supported for FPGAs, yet run: - $(EXE_NAME_FPGA_EMU) + $(EXE) + +run_usm: + @echo USM is not supported for FPGAs, yet clean: - del -rf $(EXE_NAME_FPGA_EMU) + del /f *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_buffers *.a $(EXE) $(USM_EXE) From 39149632bbbe7abedd83a1d4cf646683df116646 Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Mon, 6 Jul 2020 14:34:08 -0700 Subject: [PATCH 3/9] Update fpga make file Signed-off-by: Maria, Moushumi --- .../simple-add/Makefile.fpga | 20 +++++++++---------- .../simple-add/Makefile.win.fpga | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga index 71918af6f9..8a37c9710e 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga @@ -4,20 +4,20 @@ CXXFLAGS = -O2 -g -std=c++17 USM_SRC := src/simple-add-usm.cpp SRC := src/simple-add-buffers.cpp -.PHONY: hw hw_usm fpga_emu fpga_usm run_emu run_emu_usm clean +.PHONY: hw hw_usm fpga_emu fpga_emu_usm run_emu run_emu_usm clean fpga_emu: simple-add-buffers.fpga_emu -fpga_emu_usm: simple-add-usm.fpga_emu +fpga_emu_usm: simple-add-usm.fpga_emu_usm hw: simple-add-buffers.fpga hw_usm: simple-add-usm.fpga -report: simple-add-buffers_report.a -report_usm: simple-add-usm_report.a +report: simple-add-buffers_report.a_buffers +report_usm: simple-add-usm_report.a_usm simple-add-buffers.fpga_emu: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1 -simple-add-usm.fpga_emu: $(USM_SRC) +simple-add-usm.fpga_emu_usm: $(USM_SRC) @#$(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1 @echo USM is not supported for FPGAs, yet @@ -37,8 +37,8 @@ simple-add-usm.fpga: a_usm.o run_emu: simple-add-buffers.fpga_emu ./simple-add-buffers.fpga_emu -run_emu_usm: simple-add-usm.fpga_emu - @#./simple-add-usm.fpga_emu +run_emu_usm: simple-add-usm.fpga_emu_usm + @#./simple-add-usm.fpga_emu_usm @echo USM is not supported for FPGAs, yet @@ -56,12 +56,12 @@ dev_usm.o: $(USM_SRC) @echo USM is not supported for FPGAs, yet -simple-add-buffers_report.a: dev_buffers.o +simple-add-buffers_report.a_buffers: dev_buffers.o $(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware -simple-add-usm_report.a: dev_usm.o +simple-add-usm_report.a_usm: dev_usm.o @#$(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware @echo USM is not supported for FPGAs, yet clean: - rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_buffers simple-add-buffers.fpga simple-add-usm.fpga *.a + rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_usm simple-add-buffers.fpga simple-add-usm.fpga *.a diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga index 23f391c06b..c77f1c19a3 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win.fpga @@ -6,7 +6,7 @@ SRC = src/simple-add-buffers.cpp USM_SRC = src/simple-add-usm.cpp EXE = simple-add-buffers.fpga_emu.exe -USM_EXE = simple-add-usm.fpga_emu.exe +USM_EXE = simple-add-usm.fpga_emu_usm.exe all: fpga_emu @@ -23,4 +23,4 @@ run_usm: @echo USM is not supported for FPGAs, yet clean: - del /f *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_buffers *.a $(EXE) $(USM_EXE) + del /f *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu_usm *.a $(EXE) $(USM_EXE) From 1ba72daf1f4ae259e64d005232797646077d5dcb Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Wed, 8 Jul 2020 11:06:18 -0700 Subject: [PATCH 4/9] Add dpc_common.hpp --- .../DenseLinearAlgebra/simple-add/sample.json | 4 +- .../simple-add/src/dpc_common.hpp | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json index eee33576e0..814a3903d4 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json @@ -30,13 +30,13 @@ "id": "fpga_emu_buffers", "steps": [ "make fpga_emu -f Makefile.fpga", - "make run_emu -f Makefile.fpga", - "make clean -f Makefile.fpga" + "make run_emu -f Makefile.fpga" ] }, { "id": "fpga_report_buffers", "steps": [ + "make clean -f Makefile.fpga", "make report -f Makefile.fpga" ] } diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp new file mode 100644 index 0000000000..c9c1621391 --- /dev/null +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp @@ -0,0 +1,52 @@ +//============================================================== +// Copyright © 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT +// ============================================================= + +#ifndef _DP_HPP +#define _DP_HPP + +#pragma once + +#include +#include + +#include + +namespace dpc_common { +// this exception handler with catch async exceptions +static auto exception_handler = [](cl::sycl::exception_list eList) { + for (std::exception_ptr const &e : eList) { + try { + std::rethrow_exception(e); + } catch (std::exception const &e) { +#if _DEBUG + std::cout << "Failure" << std::endl; +#endif + std::terminate(); + } + } +}; + +// The TimeInterval is a simple RAII class. +// Construct the timer at the point you want to start timing. +// Use the Elapsed() method to return time since construction. + +class TimeInterval { + public: + TimeInterval() : start_(std::chrono::steady_clock::now()) {} + + double Elapsed() { + auto now = std::chrono::steady_clock::now(); + return std::chrono::duration_cast(now - start_).count(); + } + + private: + using Duration = std::chrono::duration; + std::chrono::steady_clock::time_point start_; +}; + +}; // namespace dpc_common + +#endif From 01df0de6d3e11f23fea72d6660b26a614a95f5a4 Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Wed, 8 Jul 2020 11:59:46 -0700 Subject: [PATCH 5/9] Update sample.json --- .../DPC++/DenseLinearAlgebra/simple-add/sample.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json index 814a3903d4..2c33ec0bd8 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json @@ -61,9 +61,9 @@ { "id": "fpga_emu_buffers", "steps": [ + "nmake -f Makefile.win.fpga clean", "nmake -f Makefile.win.fpga", - "nmake -f Makefile.win.fpga run", - "nmake -f Makefile.win.fpga clean" + "nmake -f Makefile.win.fpga run" ] } ] From 2ba6714317ab83f3410e9107608c71bd68aff23e Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Wed, 8 Jul 2020 13:55:20 -0700 Subject: [PATCH 6/9] Fix Makefile.win --- .../DPC++/DenseLinearAlgebra/simple-add/Makefile.win | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win index d59ec56431..4ba9bba99b 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win @@ -1,10 +1,10 @@ CXX = dpcpp-cl CXXFLAGS = -O2 -EHsc -Zi -EXE_NAME = simple-add-usm.exe +EXE_NAME = simple-add-usm SOURCES = src/simple-add-usm.cpp -BUFFERS_EXE_NAME = simple-add-buffers.exe +BUFFERS_EXE_NAME = simple-add-buffers BUFFERS_SOURCES = src/simple-add-buffers.cpp all: main From a5d1e34e736b1afeb9dafbc55582d749b0f04d7d Mon Sep 17 00:00:00 2001 From: Moushumi <55515077+moushumi-maria@users.noreply.github.com> Date: Wed, 8 Jul 2020 15:43:46 -0700 Subject: [PATCH 7/9] Update Makefile.win --- .../DPC++/DenseLinearAlgebra/simple-add/Makefile.win | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win index 4ba9bba99b..d59ec56431 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.win @@ -1,10 +1,10 @@ CXX = dpcpp-cl CXXFLAGS = -O2 -EHsc -Zi -EXE_NAME = simple-add-usm +EXE_NAME = simple-add-usm.exe SOURCES = src/simple-add-usm.cpp -BUFFERS_EXE_NAME = simple-add-buffers +BUFFERS_EXE_NAME = simple-add-buffers.exe BUFFERS_SOURCES = src/simple-add-buffers.cpp all: main From 8548c6cd9363f46d06d02c123f29ba3311341a7c Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Wed, 8 Jul 2020 17:20:36 -0700 Subject: [PATCH 8/9] Update sample.json --- .../DPC++/DenseLinearAlgebra/simple-add/sample.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json index 2c33ec0bd8..eb816f8be9 100644 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json +++ b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/sample.json @@ -13,22 +13,23 @@ { "id": "cpu_usm", "steps": [ + "make clean", "make all", - "make run", - "make clean" + "make run" ] }, { "id": "cpu_buffers", "steps": [ + "make clean", "make build_buffers", - "make run_buffers", - "make clean" + "make run_buffers" ] }, { "id": "fpga_emu_buffers", "steps": [ + "make clean -f Makefile.fpga", "make fpga_emu -f Makefile.fpga", "make run_emu -f Makefile.fpga" ] @@ -61,9 +62,9 @@ { "id": "fpga_emu_buffers", "steps": [ - "nmake -f Makefile.win.fpga clean", "nmake -f Makefile.win.fpga", - "nmake -f Makefile.win.fpga run" + "nmake -f Makefile.win.fpga run", + "nmake -f Makefile.win.fpga clean", ] } ] From 0adf6af32634aafbacd9b4cce9d0fcf6fb0ac052 Mon Sep 17 00:00:00 2001 From: "Maria, Moushumi" Date: Thu, 9 Jul 2020 09:44:10 -0700 Subject: [PATCH 9/9] Remove dpc_common.hpp --- .../simple-add/src/dpc_common.hpp | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp diff --git a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp deleted file mode 100644 index c9c1621391..0000000000 --- a/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/src/dpc_common.hpp +++ /dev/null @@ -1,52 +0,0 @@ -//============================================================== -// Copyright © 2020 Intel Corporation -// -// SPDX-License-Identifier: MIT -// ============================================================= - -#ifndef _DP_HPP -#define _DP_HPP - -#pragma once - -#include -#include - -#include - -namespace dpc_common { -// this exception handler with catch async exceptions -static auto exception_handler = [](cl::sycl::exception_list eList) { - for (std::exception_ptr const &e : eList) { - try { - std::rethrow_exception(e); - } catch (std::exception const &e) { -#if _DEBUG - std::cout << "Failure" << std::endl; -#endif - std::terminate(); - } - } -}; - -// The TimeInterval is a simple RAII class. -// Construct the timer at the point you want to start timing. -// Use the Elapsed() method to return time since construction. - -class TimeInterval { - public: - TimeInterval() : start_(std::chrono::steady_clock::now()) {} - - double Elapsed() { - auto now = std::chrono::steady_clock::now(); - return std::chrono::duration_cast(now - start_).count(); - } - - private: - using Duration = std::chrono::duration; - std::chrono::steady_clock::time_point start_; -}; - -}; // namespace dpc_common - -#endif