he following python script builds the simplest Cuda project discussed in the
section (
Combined use of Cuda, C++ and
boost::python
).
import ots.make.options as opt
import ots.make.generator as gen
import ots.io as io
version=opt.Version.Release
runtime=opt.Runtime.Msvc9
boost=opt.Libs.Boost_1_51
python=opt.Libs.Python26
stlport=opt.Libs.STLport
libs=[stlport,boost,python,boost.Python]
projDir=io.CDrive+'OTSProjects'+'Cuda'+'Test1'
thisDir=projDir+'ots_make'
srcDir=projDir+'Test1'
files=[
(
srcDir,
[
"kernel.cu",
"EntryPoint.cpp"
]
)
]
outputName='Test1'
outputDir=thisDir+'bin'
g=gen.MakeFile(
outputName=outputName,
outputDir=outputDir,
version=version,
runtime=runtime,
output=opt.Output.Pyd,
libs=libs,
files=files,
askBeforeDelete=False
)
g.make()
g.build()
g.copyDependencies()
The above script generates the following make file.
CPP_BIN = c:/Program Files/Microsoft Visual Studio
9.0/VC/bin
CP_OPTS = \
-DBOOST_ALL_DYN_LINK=1
\
-DBOOST_ALL_NO_LIB=1
\
-I"c:/STLport-5.2.1/stlport"
\
-I"c:/boost_1_51_0"
\
-I"c:/python26/include"
\
-c
\
/EHs
\
/GR
\
/GS
\
/MD
\
/O2
\
/Ob2
\
/W3
\
/Zc:forScope
\
/Zc:wchar_t
\
/wd4675
CUDA_BIN = c:/Program Files/NVIDIA GPU Computing
Toolkit/CUDA/v4.2/bin
CUDA_INCLUDE = c:/Program Files/NVIDIA GPU Computing
Toolkit/CUDA/v4.2/include
CUDA_LIBS = c:/Program Files/NVIDIA GPU Computing
Toolkit/CUDA/v4.2/lib/Win32
LN_LIBS = \
bPy_b151_msvc9_py26_release_stlp521.lib
\
cudart.lib
\
python26.lib
LN_OPTS = \
/DLL
\
/IMPLIB:$(OUTPUT_DIR)/$(RESULT_NAME).lib
\
/INCREMENTAL:NO
\
/LIBPATH:"$(CUDA_LIBS)"
\
/LIBPATH:"c:/OTSProjects/Boost/Python/bin/bPy_b151_msvc9_py26_release_stlp521"
\
/LIBPATH:"c:/STLport-5.2.1/build/lib/obj/vc9/shared"
\
/LIBPATH:"c:/python26/libs"
\
/LTCG
\
/MACHINE:X86
\
/MACHINE:X86
\
/MANIFEST
\
/NODEFAULTLIB:"LIBCMT.lib"
\
/NOLOGO
\
/opt:icf
\
/opt:ref
\
/out:"$(OUTPUT_DIR)/$(RESULT_NAME).pyd"
\
/subsystem:console
NVCC_OPTS = \
--compile
\
--compiler-bindir
"$(CPP_BIN)" \
--compiler-options
"/EHsc /W3 /nologo /O2 /Zi /MT" \
--include-path
"$(CUDA_INCLUDE)" \
--machine
32 \
--maxrregcount=0
\
-gencode=arch=compute_10,code=\"sm_10,compute_10\"
\
-gencode=arch=compute_20,code=\"sm_20,compute_20\"
OBJS = \
$(OBJ_DIR0)/EntryPoint.obj
\
$(OBJ_DIR0)/kernel.cu.obj
OBJ_DIR0 =
c:/OTSProjects/Cuda/Test1/ots_make/bin/objs/dir0
OUTPUT_DIR = c:/OTSProjects/Cuda/Test1/ots_make/bin
RESULT_NAME = Test1
SRC_DIR0 = c:/OTSProjects/Cuda/Test1/Test1
goal : "$(OUTPUT_DIR)/$(RESULT_NAME).pyd"
"$(OBJ_DIR0)/EntryPoint.obj" :
"$(SRC_DIR0)/EntryPoint.cpp"
cl
$? -Fo$@ $(CP_OPTS)
"$(OBJ_DIR0)/kernel.cu.obj" :
"$(SRC_DIR0)/kernel.cu"
"$(CUDA_BIN)"/nvcc.exe
$(NVCC_OPTS) --output-file $@ $?
"$(OUTPUT_DIR)/$(RESULT_NAME).pyd" : $(OBJS)
link
$(LN_OPTS) $(OBJS) $(LN_LIBS)
mt
-nologo -manifest "$(OUTPUT_DIR)/$(RESULT_NAME).pyd.manifest"
-outputresource:"$(OUTPUT_DIR)/$(RESULT_NAME).pyd;#2"
|