Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 5a472ce

Browse files
committed
Initial Commit
0 parents  commit 5a472ce

File tree

24 files changed

+16333
-0
lines changed

24 files changed

+16333
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Ignore Unix backup files
2+
*~
3+
4+
# Ignore Mac desktop services store files
5+
.DS_Store
6+
7+
# Ignore crash reports
8+
/crashinfo--*
9+
10+
!/OpenCL/Binaries
11+
/OpenCL/Binaries/**
12+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Oh-Hyun Kwon
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

OpenCL/OpenCL.uplugin

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"FileVersion" : 3,
3+
4+
"FriendlyName" : "OpenCL Plugin",
5+
"Version" : 1,
6+
"VersionName" : "1.0",
7+
"CreatedBy" : "Epic Games, Inc.",
8+
"CreatedByURL" : "http://epicgames.com",
9+
"EngineVersion" : "4.2.0",
10+
"Description" : "A simulated cable component.",
11+
"Category" : "Rendering.Components",
12+
"EnabledByDefault" : true,
13+
14+
"Modules" :
15+
[
16+
{
17+
"Name" : "OpenCL",
18+
"Type" : "Runtime"
19+
}
20+
]
21+
}

OpenCL/Resources/Icon128.png

8.47 KB
Loading

OpenCL/Source/OpenCL/OpenCL.Build.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
2+
3+
using System.IO;
4+
5+
namespace UnrealBuildTool.Rules
6+
{
7+
public class OpenCL : ModuleRules
8+
{
9+
private string ModulePath
10+
{
11+
get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
12+
}
13+
14+
private string ThirdPartyPath
15+
{
16+
get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
17+
}
18+
19+
public OpenCL(TargetInfo Target)
20+
{
21+
PublicIncludePaths.Add(
22+
"OpenCL/Public"
23+
);
24+
25+
PublicDependencyModuleNames.AddRange(
26+
new string[]
27+
{
28+
"Core",
29+
"CoreUObject",
30+
"Engine",
31+
"RenderCore",
32+
"ShaderCore",
33+
"RHI"
34+
}
35+
);
36+
37+
string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "Win64" : "Win32";
38+
string OpenCLLibrariesPath = Path.Combine(ThirdPartyPath, "OpenCL", "Lib");
39+
string NvidiaLibrariesPath = Path.Combine(OpenCLLibrariesPath, "NVIDIA", PlatformString);
40+
string InelLibrariesPath = Path.Combine(OpenCLLibrariesPath, "Intel", PlatformString);
41+
if (Target.Platform == UnrealTargetPlatform.Win64 || Target.Platform == UnrealTargetPlatform.Win32)
42+
{
43+
PublicAdditionalLibraries.Add(Path.Combine(NvidiaLibrariesPath, "OpenCL.lib"));
44+
PublicAdditionalLibraries.Add(Path.Combine(InelLibrariesPath, "OpenCL.lib"));
45+
}
46+
else if (Target.Platform == UnrealTargetPlatform.Mac)
47+
{
48+
PublicAdditionalFrameworks.Add( new UEBuildFramework( "OpenCL" ) );
49+
}
50+
}
51+
}
52+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
2+
3+
#include "OpenCLPluginPrivatePCH.h"
4+
5+
class OpenCLPlugin : public IOpenCLPlugin
6+
{
7+
/** IModuleInterface implementation */
8+
virtual void StartupModule() override;
9+
virtual void ShutdownModule() override;
10+
};
11+
12+
IMPLEMENT_MODULE( OpenCLPlugin, OpenCL )
13+
DEFINE_LOG_CATEGORY(LogOpenCL);
14+
15+
void OpenCLPlugin::StartupModule()
16+
{
17+
UE_LOG(LogOpenCL, Log, TEXT("OpenCL Info:"));
18+
19+
cl_uint i, j;
20+
char* value;
21+
size_t valueSize;
22+
cl_uint platformCount;
23+
cl_platform_id* platforms;
24+
cl_uint deviceCount;
25+
cl_device_id* devices;
26+
cl_uint maxComputeUnits;
27+
28+
// get all platforms
29+
clGetPlatformIDs(0, NULL, &platformCount);
30+
platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id) * platformCount);
31+
clGetPlatformIDs(platformCount, platforms, NULL);
32+
33+
for (i = 0; i < platformCount; i++) {
34+
clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, 0, NULL, &valueSize);
35+
value = (char*)malloc(valueSize);
36+
clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, valueSize, value, NULL);
37+
UE_LOG(LogOpenCL, Log, TEXT("Platform: %s"), ANSI_TO_TCHAR(value));
38+
free(value);
39+
40+
// get all devices
41+
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &deviceCount);
42+
devices = (cl_device_id*)malloc(sizeof(cl_device_id) * deviceCount);
43+
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, deviceCount, devices, NULL);
44+
45+
// for each device print critical attributes
46+
for (j = 0; j < deviceCount; j++) {
47+
48+
// print device name
49+
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize);
50+
value = (char*)malloc(valueSize);
51+
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL);
52+
UE_LOG(LogOpenCL, Log, TEXT(" Device: %s"), ANSI_TO_TCHAR(value));
53+
free(value);
54+
55+
// print hardware device version
56+
clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, 0, NULL, &valueSize);
57+
value = (char*)malloc(valueSize);
58+
clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, valueSize, value, NULL);
59+
UE_LOG(LogOpenCL, Log, TEXT(" Hardware version: %s"), ANSI_TO_TCHAR(value));
60+
free(value);
61+
62+
// print software driver version
63+
clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, 0, NULL, &valueSize);
64+
value = (char*)malloc(valueSize);
65+
clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, valueSize, value, NULL);
66+
UE_LOG(LogOpenCL, Log, TEXT(" Software version: %s"), ANSI_TO_TCHAR(value));
67+
free(value);
68+
69+
// print c version supported by compiler for device
70+
clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, 0, NULL, &valueSize);
71+
value = (char*)malloc(valueSize);
72+
clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, valueSize, value, NULL);
73+
UE_LOG(LogOpenCL, Log, TEXT(" OpenCL C version: %s"), ANSI_TO_TCHAR(value));
74+
free(value);
75+
76+
// print parallel compute units
77+
clGetDeviceInfo(devices[j], CL_DEVICE_MAX_COMPUTE_UNITS,
78+
sizeof(maxComputeUnits), &maxComputeUnits, NULL);
79+
UE_LOG(LogOpenCL, Log, TEXT(" Parallel compute units: %d"), maxComputeUnits);
80+
}
81+
82+
free(devices);
83+
84+
}
85+
86+
free(platforms);
87+
}
88+
89+
void OpenCLPlugin::ShutdownModule() {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "ModuleManager.h"
2+
3+
#include "OpenCL.h"
4+
#include "IOpenCLPlugin.h"

0 commit comments

Comments
 (0)