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/Makefile.fpga b/DirectProgramming/DPC++/DenseLinearAlgebra/simple-add/Makefile.fpga index 6c4005dd18..8a37c9710e 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_emu_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_usm -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_buffers +report_usm: simple-add-usm_report.a_usm -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: $(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_usm + @#./simple-add-usm.fpga_emu_usm + @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 - $(CXX) $(CXXFLAGS) -fintelfpga -fsycl-link $^ -o $@ -Xshardware +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 \ No newline at end of file + 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 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..c77f1c19a3 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_usm.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_usm *.a $(EXE) $(USM_EXE) 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..eb816f8be9 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++.", @@ -12,30 +13,31 @@ { "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", - "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" ] } @@ -62,7 +64,7 @@ "steps": [ "nmake -f Makefile.win.fpga", "nmake -f Makefile.win.fpga run", - "nmake -f Makefile.win.fpga clean" + "nmake -f Makefile.win.fpga clean", ] } ] 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; }