import opencl_course source for a start
This commit is contained in:
36
build/findDirectX11.lua
Normal file
36
build/findDirectX11.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
function findDirectX11()
|
||||
local dx11path = os.getenv("DXSDK_DIR")
|
||||
if (dx11path) then
|
||||
local filepath = string.format("%s%s",dx11path,"Include/D3D11.h")
|
||||
headerdx11 = io.open(filepath, "r")
|
||||
if (headerdx11) then
|
||||
printf("Found DX11: '%s'", filepath)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initDirectX11()
|
||||
configuration {}
|
||||
|
||||
local dx11path = os.getenv("DXSDK_DIR")
|
||||
defines { "ADL_ENABLE_DX11"}
|
||||
includedirs {"$(DXSDK_DIR)/include"}
|
||||
|
||||
configuration "x32"
|
||||
libdirs {"$(DXSDK_DIR)/Lib/x86"}
|
||||
configuration "x64"
|
||||
libdirs {"$(DXSDK_DIR)/Lib/x64"}
|
||||
configuration {}
|
||||
links {"d3dcompiler",
|
||||
"dxerr",
|
||||
"dxguid",
|
||||
"d3dx9",
|
||||
"d3d9",
|
||||
"winmm",
|
||||
"comctl32",
|
||||
"d3dx11"
|
||||
}
|
||||
return true
|
||||
end
|
||||
151
build/findOpenCL.lua
Normal file
151
build/findOpenCL.lua
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
|
||||
function findOpenCL_Apple()
|
||||
if os.is("macosx") then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function findOpenCL_AMD()
|
||||
local amdopenclpath = os.getenv("AMDAPPSDKROOT")
|
||||
if (amdopenclpath) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function findOpenCL_NVIDIA()
|
||||
local nvidiaopenclpath = os.getenv("CUDA_PATH")
|
||||
if (nvidiaopenclpath) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function findOpenCL_Intel()
|
||||
if os.is("Windows") then
|
||||
local intelopenclpath = os.getenv("INTELOCLSDKROOT")
|
||||
if (intelopenclpath) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
if os.is("Linux") then
|
||||
local intelsdk = io.open("/usr/include/CL/opencl.h","r")
|
||||
if (intelsdk) then
|
||||
return true;
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initOpenCL_Apple()
|
||||
configuration{}
|
||||
includedirs {
|
||||
"/System/Library/Frameworks/OpenCL.framework"
|
||||
}
|
||||
libdirs "/System/Library/Frameworks/OpenCL.framework"
|
||||
links
|
||||
{
|
||||
"OpenCL.framework"
|
||||
}
|
||||
end
|
||||
|
||||
function initOpenCL_AMD()
|
||||
configuration {}
|
||||
local amdopenclpath = os.getenv("AMDAPPSDKROOT")
|
||||
if (amdopenclpath) then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_AMD"}
|
||||
includedirs {
|
||||
"$(AMDAPPSDKROOT)/include"
|
||||
}
|
||||
configuration "x32"
|
||||
libdirs {"$(AMDAPPSDKROOT)/lib/x86"}
|
||||
configuration "x64"
|
||||
libdirs {"$(AMDAPPSDKROOT)/lib/x86_64"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function initOpenCL_NVIDIA()
|
||||
configuration {}
|
||||
local nvidiaopenclpath = os.getenv("CUDA_PATH")
|
||||
if (nvidiaopenclpath) then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_NVIDIA"}
|
||||
includedirs {
|
||||
"$(CUDA_PATH)/include"
|
||||
}
|
||||
configuration "x32"
|
||||
libdirs {"$(CUDA_PATH)/lib/Win32"}
|
||||
configuration "x64"
|
||||
libdirs {"$(CUDA_PATH)/lib/x64"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initOpenCL_Intel()
|
||||
configuration {}
|
||||
if os.is("Windows") then
|
||||
local intelopenclpath = os.getenv("INTELOCLSDKROOT")
|
||||
if (intelopenclpath) then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
|
||||
includedirs {
|
||||
"$(INTELOCLSDKROOT)/include"
|
||||
}
|
||||
configuration "x32"
|
||||
libdirs {"$(INTELOCLSDKROOT)/lib/x86"}
|
||||
configuration "x64"
|
||||
libdirs {"$(INTELOCLSDKROOT)/lib/x64"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
return true
|
||||
end
|
||||
end
|
||||
if os.is("Linux") then
|
||||
defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
|
||||
configuration {}
|
||||
links {"OpenCL"}
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function findOpenCL (vendor )
|
||||
if vendor=="AMD" then
|
||||
return findOpenCL_AMD()
|
||||
end
|
||||
if vendor=="NVIDIA" then
|
||||
return findOpenCL_NVIDIA()
|
||||
end
|
||||
if vendor=="Intel" then
|
||||
return findOpenCL_Intel()
|
||||
end
|
||||
if vendor=="Apple" then
|
||||
return findOpenCL_Apple()
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function initOpenCL ( vendor )
|
||||
if vendor=="AMD" then
|
||||
initOpenCL_AMD()
|
||||
end
|
||||
if vendor=="NVIDIA" then
|
||||
return initOpenCL_NVIDIA()
|
||||
end
|
||||
if vendor=="Intel" then
|
||||
initOpenCL_Intel()
|
||||
end
|
||||
if vendor=="Apple" then
|
||||
return initOpenCL_Apple()
|
||||
end
|
||||
end
|
||||
|
||||
51
build/findOpenGLGlewGlut.lua
Normal file
51
build/findOpenGLGlewGlut.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
function initOpenGL()
|
||||
configuration {}
|
||||
configuration {"Windows"}
|
||||
links {"opengl32","glu32"}
|
||||
configuration {"MacOSX"}
|
||||
links { "OpenGL.framework"}
|
||||
configuration {"not Windows", "not MacOSX"}
|
||||
links {"GL"}
|
||||
configuration{}
|
||||
end
|
||||
|
||||
function initGlut()
|
||||
configuration {}
|
||||
configuration {"Windows"}
|
||||
|
||||
includedirs {
|
||||
projectRootDir .. "rendering/GlutGlewWindows"
|
||||
}
|
||||
libdirs { projectRootDir .. "rendering/GlutGlewWindows"}
|
||||
configuration {"Windows", "x32"}
|
||||
links {"glut32"}
|
||||
configuration {"Windows", "x64"}
|
||||
links {"glut64"}
|
||||
|
||||
configuration {"MacOSX"}
|
||||
links { "Glut.framework" }
|
||||
configuration {"Linux"}
|
||||
links {"glut","GLU"}
|
||||
configuration{}
|
||||
end
|
||||
|
||||
function initGlew()
|
||||
configuration {}
|
||||
if os.is("Windows") then
|
||||
configuration {"Windows"}
|
||||
defines { "GLEW_STATIC"}
|
||||
includedirs {
|
||||
projectRootDir .. "rendering/GlutGlewWindows"
|
||||
}
|
||||
libdirs { projectRootDir .. "rendering/GlutGlewWindows"}
|
||||
files { projectRootDir .. "rendering/GlutGlewWindows/glew.c"}
|
||||
end
|
||||
if os.is("Linux") then
|
||||
links{"GLEW"}
|
||||
end
|
||||
configuration{}
|
||||
end
|
||||
|
||||
|
||||
|
||||
BIN
build/premake4.exe
Normal file
BIN
build/premake4.exe
Normal file
Binary file not shown.
96
build/premake4.lua
Normal file
96
build/premake4.lua
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
solution "0MySolution"
|
||||
|
||||
-- Multithreaded compiling
|
||||
if _ACTION == "vs2010" or _ACTION=="vs2008" then
|
||||
buildoptions { "/MP" }
|
||||
end
|
||||
|
||||
act = ""
|
||||
|
||||
if _ACTION then
|
||||
act = _ACTION
|
||||
end
|
||||
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "ios",
|
||||
description = "Enable iOS target (requires xcode4)"
|
||||
}
|
||||
|
||||
|
||||
configurations {"Release", "Debug"}
|
||||
configuration "Release"
|
||||
flags { "Optimize", "EnableSSE","StaticRuntime", "NoMinimalRebuild", "FloatFast"}
|
||||
configuration "Debug"
|
||||
defines {"_DEBUG=1"}
|
||||
flags { "Symbols", "StaticRuntime" , "NoMinimalRebuild", "NoEditAndContinue" ,"FloatFast"}
|
||||
|
||||
platforms {"x32", "x64"}
|
||||
|
||||
configuration {"x32"}
|
||||
targetsuffix ("_" .. act)
|
||||
configuration "x64"
|
||||
targetsuffix ("_" .. act .. "_64" )
|
||||
configuration {"x64", "debug"}
|
||||
targetsuffix ("_" .. act .. "_x64_debug")
|
||||
configuration {"x64", "release"}
|
||||
targetsuffix ("_" .. act .. "_x64_release" )
|
||||
configuration {"x32", "debug"}
|
||||
targetsuffix ("_" .. act .. "_debug" )
|
||||
|
||||
configuration{}
|
||||
|
||||
postfix=""
|
||||
|
||||
if _ACTION == "xcode4" then
|
||||
if _OPTIONS["ios"] then
|
||||
postfix = "ios";
|
||||
xcodebuildsettings
|
||||
{
|
||||
'CODE_SIGN_IDENTITY = "iPhone Developer"',
|
||||
"SDKROOT = iphoneos",
|
||||
'ARCHS = "armv7"',
|
||||
'TARGETED_DEVICE_FAMILY = "1,2"',
|
||||
'VALID_ARCHS = "armv7"',
|
||||
}
|
||||
else
|
||||
xcodebuildsettings
|
||||
{
|
||||
'ARCHS = "$(ARCHS_STANDARD_32_BIT) $(ARCHS_STANDARD_64_BIT)"',
|
||||
'VALID_ARCHS = "x86_64 i386"',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
flags { "NoRTTI", "NoExceptions"}
|
||||
defines { "_HAS_EXCEPTIONS=0" }
|
||||
targetdir "../bin"
|
||||
location("./" .. act .. postfix)
|
||||
|
||||
|
||||
projectRootDir = os.getcwd() .. "/../"
|
||||
print("Project root directroy: " .. projectRootDir);
|
||||
|
||||
dofile ("findOpenCL.lua")
|
||||
dofile ("findDirectX11.lua")
|
||||
dofile ("findOpenGLGlewGlut.lua")
|
||||
|
||||
language "C++"
|
||||
|
||||
|
||||
|
||||
if not _OPTIONS["ios"] then
|
||||
include "../opencl/vector_add_simplified"
|
||||
include "../opencl/vector_add"
|
||||
include "../opencl/basic_initialize"
|
||||
include "../opencl/parallel_primitives/host"
|
||||
include "../opencl/parallel_primitives/test"
|
||||
include "../opencl/parallel_primitives/benchmark"
|
||||
include "../opencl/lds_bank_conflict"
|
||||
include "../opencl/reduce"
|
||||
|
||||
|
||||
end
|
||||
BIN
build/premake4_linux
Normal file
BIN
build/premake4_linux
Normal file
Binary file not shown.
BIN
build/premake4_linux64
Normal file
BIN
build/premake4_linux64
Normal file
Binary file not shown.
BIN
build/premake4_osx
Normal file
BIN
build/premake4_osx
Normal file
Binary file not shown.
13
build/stringify.bat
Normal file
13
build/stringify.bat
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../opencl/vector_add/VectorAddKernels.cl" --headerfile="../opencl/vector_add/VectorAddKernels.h" --stringname="vectorAddCL" stringify
|
||||
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/RadixSort32Kernels.cl" --headerfile="../opencl/parallel_primitives/kernels/RadixSort32KernelsCL.h" --stringname="radixSort32KernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/BoundSearchKernels.cl" --headerfile="../opencl/parallel_primitives/kernels/BoundSearchKernelsCL.h" --stringname="boundSearchKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/PrefixScanKernels.cl" --headerfile="../opencl/parallel_primitives/kernels/PrefixScanKernelsCL.h" --stringname="prefixScanKernelsCL" stringify
|
||||
premake4 --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/FillKernels.cl" --headerfile="../opencl/parallel_primitives/kernels/FillKernelsCL.h" --stringname="fillKernelsCL" stringify
|
||||
|
||||
|
||||
pause
|
||||
8
build/stringify.sh
Normal file
8
build/stringify.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
./premake4_osx --file=stringifyKernel.lua --kernelfile="../opencl/vector_add/VectorAddKernels.cl" --headerfile="../opencl/vector_add/VectorAddKernels.h" --stringname="vectorAddCL" stringify
|
||||
./premake4_osx --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/RadixSort32Kernels.cl" --headerfile="../opencl/parallel_primitives/kernels/RadixSort32KernelsCL.h" --stringname="radixSort32KernelsCL" stringify
|
||||
./premake4_osx --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/BoundSearchKernels.cl" --headerfile="../opencl/parallel_primitives/kernels/BoundSearchKernelsCL.h" --stringname="boundSearchKernelsCL" stringify
|
||||
./premake4_osx --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/PrefixScanKernels.cl" --headerfile="../opencl/parallel_primitives/kernels/PrefixScanKernelsCL.h" --stringname="prefixScanKernelsCL" stringify
|
||||
./premake4_osx --file=stringifyKernel.lua --kernelfile="../opencl/parallel_primitives/kernels/FillKernels.cl" --headerfile="../opencl/parallel_primitives/kernels/FillKernelsCL.h" --stringname="fillKernelsCL" stringify
|
||||
|
||||
78
build/stringifyKernel.lua
Normal file
78
build/stringifyKernel.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
|
||||
function stringifyKernel(filenameIn, filenameOut, kernelMethod)
|
||||
local BUFSIZE = 1024*1024 -- 1MB
|
||||
local f = io.open(filenameIn,"r");
|
||||
local fw = io.open(filenameOut,"w");
|
||||
fw:write("//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project\n")
|
||||
fw:write("static const char* " .. kernelMethod .. "= \\\n")
|
||||
local cc, lc, wc = 0, 0, 0 -- char, line, and word counts
|
||||
while true do
|
||||
local lines, rest = f:read(BUFSIZE, "*line")
|
||||
if not lines then break end
|
||||
|
||||
local i = 0
|
||||
local startpos = 0
|
||||
local slen = string.len(lines)
|
||||
local endpos = 0
|
||||
while true do
|
||||
i = string.find(lines, "\n", i+1) -- find 'next' newline
|
||||
if i == nil then
|
||||
endpos = slen
|
||||
else
|
||||
endpos = i
|
||||
end
|
||||
oneline = string.sub(lines,startpos,endpos)
|
||||
oneline = string.gsub(oneline,"\n","")
|
||||
oneline = '\"' .. oneline .. '\\n\"'
|
||||
oneline = string.gsub(oneline,"\\\\n","")
|
||||
oneline = oneline .. "\n"
|
||||
--print(oneline)
|
||||
fw:write(oneline)
|
||||
if i == nil then break end
|
||||
startpos = i+1
|
||||
end
|
||||
|
||||
if rest then lines = lines .. rest .. '\n' end
|
||||
cc = cc + string.len(lines)
|
||||
-- count words in the chunk
|
||||
local _,t = string.gsub(lines, "%S+", "")
|
||||
wc = wc + t
|
||||
-- count newlines in the chunk
|
||||
_,t = string.gsub(lines, "\n", "\n")
|
||||
lc = lc + t
|
||||
end
|
||||
--print("stringified " .. filenameIn .. " into " .. filenameOut .. " processed " .. lc .. " lines")
|
||||
print(filenameIn .. " (" .. lc .. " lines)")
|
||||
|
||||
f:close()
|
||||
fw:write(";\n")
|
||||
fw:close()
|
||||
end
|
||||
|
||||
newoption {
|
||||
trigger = "kernelfile",
|
||||
value = "kernelpath",
|
||||
description = "full path to the kernel source input file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "headerfile",
|
||||
value = "path",
|
||||
description = "full path to the header output file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "stringname",
|
||||
value = "var",
|
||||
description = "name of the kernel string variable"
|
||||
}
|
||||
|
||||
newaction {
|
||||
trigger = "stringify",
|
||||
description = "stringify kernels source code into strings",
|
||||
execute = function ()
|
||||
stringifyKernel( _OPTIONS["kernelfile"] , _OPTIONS["headerfile"], _OPTIONS["stringname"])
|
||||
|
||||
end
|
||||
}
|
||||
6
build/vs2010.bat
Normal file
6
build/vs2010.bat
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
rem premake4 --with-pe vs2010
|
||||
premake4 vs2010
|
||||
|
||||
mkdir vs2010\cache
|
||||
pause
|
||||
4
build/xcode.command
Normal file
4
build/xcode.command
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
cd `dirname $0`
|
||||
./premake4_osx xcode4
|
||||
|
||||
Reference in New Issue
Block a user