Skip to content

Commit 8818264

Browse files
committed
Move 1d_HeatTransfer sample to open source GitHub.
Signed-off-by: Loc Nguyen <[email protected]>
1 parent d3ab219 commit 8818264

File tree

9 files changed

+678
-0
lines changed

9 files changed

+678
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.1062
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "1d_HeatTransfer", "1d_HeatTransfer.vcxproj", "{D3AB428E-A631-4BA1-A526-9A05B7B8E8CE}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Release|x64 = Release|x64
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D3AB428E-A631-4BA1-A526-9A05B7B8E8CE}.Debug|x64.ActiveCfg = Debug|x64
15+
{D3AB428E-A631-4BA1-A526-9A05B7B8E8CE}.Debug|x64.Build.0 = Debug|x64
16+
{D3AB428E-A631-4BA1-A526-9A05B7B8E8CE}.Release|x64.ActiveCfg = Release|x64
17+
{D3AB428E-A631-4BA1-A526-9A05B7B8E8CE}.Release|x64.Build.0 = Release|x64
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {81F9E738-2753-4252-82FA-AE9A402B7ABD}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|x64">
5+
<Configuration>Debug</Configuration>
6+
<Platform>x64</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|x64">
9+
<Configuration>Release</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<ItemGroup>
14+
<ClCompile Include="src\1d_HeatTransfer.cpp" />
15+
</ItemGroup>
16+
<PropertyGroup Label="Globals">
17+
<VCProjectVersion>15.0</VCProjectVersion>
18+
<ProjectGuid>{d3ab428e-a631-4ba1-a526-9a05b7b8e8ce}</ProjectGuid>
19+
<Keyword>Win32Proj</Keyword>
20+
<RootNamespace>_1d_HeatTransfer</RootNamespace>
21+
<WindowsTargetPlatformVersion>$(WindowsSDKVersion.Replace("\",""))</WindowsTargetPlatformVersion>
22+
</PropertyGroup>
23+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
24+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
25+
<ConfigurationType>Application</ConfigurationType>
26+
<UseDebugLibraries>true</UseDebugLibraries>
27+
<PlatformToolset>Intel(R) oneAPI DPC++ Compiler</PlatformToolset>
28+
<CharacterSet>Unicode</CharacterSet>
29+
</PropertyGroup>
30+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
31+
<ConfigurationType>Application</ConfigurationType>
32+
<UseDebugLibraries>false</UseDebugLibraries>
33+
<PlatformToolset>Intel(R) oneAPI DPC++ Compiler</PlatformToolset>
34+
<WholeProgramOptimization>true</WholeProgramOptimization>
35+
<CharacterSet>Unicode</CharacterSet>
36+
</PropertyGroup>
37+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
38+
<ConfigurationType>Application</ConfigurationType>
39+
<UseDebugLibraries>true</UseDebugLibraries>
40+
<PlatformToolset>Intel(R) oneAPI DPC++ Compiler</PlatformToolset>
41+
<CharacterSet>Unicode</CharacterSet>
42+
</PropertyGroup>
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
44+
<ConfigurationType>Application</ConfigurationType>
45+
<UseDebugLibraries>false</UseDebugLibraries>
46+
<PlatformToolset>Intel(R) oneAPI DPC++ Compiler</PlatformToolset>
47+
<WholeProgramOptimization>true</WholeProgramOptimization>
48+
<CharacterSet>Unicode</CharacterSet>
49+
</PropertyGroup>
50+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
51+
<ImportGroup Label="ExtensionSettings">
52+
</ImportGroup>
53+
<ImportGroup Label="Shared">
54+
</ImportGroup>
55+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
56+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+
</ImportGroup>
58+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
</ImportGroup>
67+
<PropertyGroup Label="UserMacros" />
68+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
69+
<LinkIncremental>true</LinkIncremental>
70+
</PropertyGroup>
71+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
72+
<LinkIncremental>true</LinkIncremental>
73+
</PropertyGroup>
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
75+
<LinkIncremental>false</LinkIncremental>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
78+
<LinkIncremental>false</LinkIncremental>
79+
</PropertyGroup>
80+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
81+
<ClCompile>
82+
<PrecompiledHeader>Use</PrecompiledHeader>
83+
<WarningLevel>Level3</WarningLevel>
84+
<Optimization>Disabled</Optimization>
85+
<SDLCheck>true</SDLCheck>
86+
<ConformanceMode>true</ConformanceMode>
87+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
88+
</ClCompile>
89+
<Link>
90+
<SubSystem>Console</SubSystem>
91+
<GenerateDebugInformation>true</GenerateDebugInformation>
92+
</Link>
93+
</ItemDefinitionGroup>
94+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
95+
<ClCompile>
96+
<PrecompiledHeader>Use</PrecompiledHeader>
97+
<WarningLevel>Level3</WarningLevel>
98+
<Optimization>Disabled</Optimization>
99+
<SDLCheck>true</SDLCheck>
100+
<ConformanceMode>true</ConformanceMode>
101+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
102+
<AdditionalIncludeDirectories>%ONEAPI_ROOT%\dev-utilities\latest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
103+
</ClCompile>
104+
<Link>
105+
<SubSystem>Console</SubSystem>
106+
<GenerateDebugInformation>true</GenerateDebugInformation>
107+
</Link>
108+
</ItemDefinitionGroup>
109+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
110+
<ClCompile>
111+
<PrecompiledHeader>Use</PrecompiledHeader>
112+
<WarningLevel>Level3</WarningLevel>
113+
<Optimization>MaxSpeed</Optimization>
114+
<FunctionLevelLinking>true</FunctionLevelLinking>
115+
<IntrinsicFunctions>true</IntrinsicFunctions>
116+
<SDLCheck>true</SDLCheck>
117+
<ConformanceMode>true</ConformanceMode>
118+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
119+
</ClCompile>
120+
<Link>
121+
<SubSystem>Console</SubSystem>
122+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
123+
<OptimizeReferences>true</OptimizeReferences>
124+
<GenerateDebugInformation>true</GenerateDebugInformation>
125+
</Link>
126+
</ItemDefinitionGroup>
127+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
128+
<ClCompile>
129+
<PrecompiledHeader>Use</PrecompiledHeader>
130+
<WarningLevel>Level3</WarningLevel>
131+
<Optimization>MaxSpeed</Optimization>
132+
<FunctionLevelLinking>true</FunctionLevelLinking>
133+
<IntrinsicFunctions>true</IntrinsicFunctions>
134+
<SDLCheck>true</SDLCheck>
135+
<ConformanceMode>true</ConformanceMode>
136+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
137+
<AdditionalIncludeDirectories>%ONEAPI_ROOT%\dev-utilities\latest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
138+
</ClCompile>
139+
<Link>
140+
<SubSystem>Console</SubSystem>
141+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
142+
<OptimizeReferences>true</OptimizeReferences>
143+
<GenerateDebugInformation>true</GenerateDebugInformation>
144+
</Link>
145+
</ItemDefinitionGroup>
146+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
147+
<ImportGroup Label="ExtensionTargets">
148+
</ImportGroup>
149+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="src\1d_HeatTransfer.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
4+
<LocalDebuggerCommandArguments>100 1000</LocalDebuggerCommandArguments>
5+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8+
<LocalDebuggerCommandArguments>100 1000</LocalDebuggerCommandArguments>
9+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
10+
</PropertyGroup>
11+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# required cmake version
2+
cmake_minimum_required(VERSION 3.5)
3+
4+
# CMakeLists.txt for 1d_HeatTransfer project
5+
project (1d_HeatTransfer)
6+
7+
set(CMAKE_CXX_COMPILER "dpcpp")
8+
9+
# Set default build type to RelWithDebInfo if not specified
10+
if (NOT CMAKE_BUILD_TYPE)
11+
message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info")
12+
set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE
13+
STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel"
14+
FORCE)
15+
endif()
16+
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fsycl -std=c++17")
18+
19+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lOpenCL -lsycl")
20+
21+
add_executable (1d_HeatTransfer src/1d_HeatTransfer.cpp)
22+
23+
add_custom_target (run
24+
COMMAND 1d_HeatTransfer 100 1000
25+
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
26+
)
27+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2019 Intel Corporation
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# 1D-Heat-Transfer Sample
2+
3+
This code sample demonstrates the simulation of one dimensional heat transfer process using
4+
Intel Data Parallel C++. Kernels in this example are implemented as a discretized differential
5+
equation with second derivative in space and first derivative in time.
6+
7+
For comprehensive instructions regarding DPC++ Programming, go to
8+
https://software.intel.com/en-us/oneapi-programming-guide
9+
and search based on relevant terms noted in the comments.
10+
11+
| Optimized for | Description
12+
|:--- |:---
13+
| OS | Linux Ubuntu 18.04
14+
| Hardware | Skylake with GEN9 or newer
15+
| Software | Intel&reg; oneAPI DPC++ Compiler (beta); Intel C++ Compiler (beta)
16+
| What you will learn | How to simulate 1D Heat Transfer using Intel DPC++ compiler
17+
| Time to complete | 10 minutes
18+
19+
20+
## Purpose
21+
22+
1D-Heat-Transfer is a DPC++ application that simulates the heat propagation on a one-dimensional
23+
isotropic and homogeneous medium. The following equation is used in the simulation of heat propagation:
24+
25+
dU/dt = k * d2U/dx2
26+
27+
Where:
28+
dU/dt is the rate of change of temperature at a point.
29+
k is the thermal difusivity.
30+
d2U/dx2 is the second spatial derivative.
31+
32+
Or
33+
34+
U(i) = C * (U(i+1) - 2 * U(i) + U(i-1)) + U(i)
35+
36+
where constant C = k * dt / (dx * dx)
37+
38+
The code sample includes both parallel and serial calculation of heat propagation. The code sample will
39+
attempt first to execute on an available GPU and fallback to the system's CPU if a compatible GPU is
40+
not detected. The results are stored in a file.
41+
42+
43+
## Key Implementation Details
44+
45+
The basic DPC++ implementation explained in the code includes device selector, buffer, accessor, kernel, and command groups.
46+
47+
48+
## License
49+
50+
This code sample is licensed under MIT license
51+
52+
53+
## Building the `1d_HeatTransfer` Program for CPU and GPU
54+
55+
### Include Files
56+
The include folder is located at `%ONEAPI_ROOT%\dev-utilities\latest\include` on your development system".
57+
58+
### Running Samples In DevCloud
59+
If running a sample in the Intel DevCloud, remember that you must specify the compute node (CPU, GPU,
60+
FPGA) as well whether to run in batch or interactive mode. For more information see the Intel® oneAPI
61+
Base Toolkit Get Started Guide (https://devcloud.intel.com/oneapi/get-started/base-toolkit/)
62+
63+
### On a Linux* System
64+
1. Build the program using the following `cmake` commands.
65+
```
66+
$ cd 1d_HeatTransfer
67+
$ mkdir build
68+
$ cd build
69+
$ cmake ..
70+
$ make -j
71+
```
72+
73+
2. Run the program
74+
75+
```
76+
make run
77+
```
78+
79+
3. Clean the program
80+
81+
```
82+
make clean
83+
```
84+
85+
### On a Windows* System
86+
* Build the program using VS2017 or VS2019
87+
Right click on the solution file and open using either VS2017 or VS2019 IDE.
88+
Right click on the project in Solution explorer and select Rebuild.
89+
From top menu select Debug -> Start without Debugging.
90+
91+
* Build the program using MSBuild
92+
Open "x64 Native Tools Command Prompt for VS2017" or "x64 Native Tools Command Prompt for
93+
VS2019"
94+
Run - MSBuild 1d_HeatTransfer.sln /t:Rebuild /p:Configuration="Release"
95+
96+
97+
## Running the sample
98+
### Application Parameters
99+
100+
Usage: 1d_HeatTransfer <n> <i>
101+
102+
where
103+
104+
n is the number of points you want to simulate the heat transfer.
105+
106+
i is the number of timesteps in the simulation.
107+
108+
The sample offloads the computation to GPU and also performs a computation in serial in the CPU.
109+
The results from the parallel and serial computation are compared and stored in an output file named "error_diff.txt".
110+
If the results match, the application will display a “PASSED” message.
111+
112+
### Example of Output
113+
```
114+
$ ./1d_HeatTransfer 100 1000
115+
Number of points: 100
116+
Number of iterations: 1000
117+
Kernel runs on Intel(R) Gen9 HD Graphics NEO
118+
Kernel time: 0.347854 sec
119+
PASSED! There is no difference between the results computed in host and in kernel.
120+
```

0 commit comments

Comments
 (0)