>> I just noticed your email in my FindCUDA filter from the CMake list. I'm not sure why it didn't show up sooner.<br><br>No worries. I let this thread die for a while while I worked on other things. I was back recently trying to fix this issue as I now want to compare the cpu/gpu recons separately. I appreciate the help.<br>
<br>--snip --<br>2. Have you tried to disable this flag? <br>Yes I have and it turns out I must in order for me to get my .cu file to be compiled with correct -DDefines. <br>
<br>I don't believe this is true. ....<br>--end snip<br><br>I tried it enable/disabling the flag again just to be sure I was seeing correct output.<br><br><br>with CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE ON (default - with my set line below commented out) and using the following:<br>
<br>-snip-<br> # see <a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:FindCUDA">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:FindCUDA</a> and<br> # <a href="http://marc.info/?l=cmake&m=127920291014527&w=2">http://marc.info/?l=cmake&m=127920291014527&w=2</a><br>
# What this ends up doing is passing all defines to a single target i.e. both GPU_RECON=yes and CPU_RECON=yes<br> # which is not what is desired.<br> set( CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF )<br><br> if(DEFINED ARG_CU_SOURCES )<br>
message("\tARG_CU_SOURCES is defined as = ${ARG_CU_SOURCES}" )<br> CUDA_ADD_LIBRARY( ${LIB_NAME} SHARED ${MATLAB_CUDA_FILES} <br> OPTIONS <br> DEBUG ${DEFINITIONS_STRING}<br>
RELEASE ${DEFINITIONS_STRING}<br> MINSIZEREL ${DEFINITIONS_STRING}<br> RELWITHDEBINFO ${DEFINITIONS_STRING}<br> )<br> else()<br> message("\tARG_CU_SOURCES is not defined" )<br>
message("\tdefining library ${LIB_NAME} with sources ${ARG_CPP_SOURCES}")<br> ADD_LIBRARY( ${LIB_NAME} SHARED ${ARG_CPP_SOURCES} )<br> endif()<br>--end snip--<br><br>i get<br><br>--snip--<br>2>C:/CUDA/bin64/nvcc.exe C:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/gpuPMatrixRecon.cu -arch sm_11 --ptxas-options=-v -maxrregcount=32 -Xcompiler /EHsc,/W3,/nologo,/Od,/Zi,/MTd -DCUDADeviceProperties_DLLExport=yes -DGPU_RECON=yes -m64 -DgpuReconPlugin_EXPORTS -ccbin "c:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin" -DNVCC -M -o C:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/dvip4-Win64/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/CMakeFiles/gpuReconPlugin_generated_gpuPMatrixRecon.cu.obj.NVCC-depend -IC:/CUDA/include -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/source/cpp/lib/3rdParty/Win/boost-cmake-1_41_0 "-IC:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/inc" -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/Windows-6.0/install/include/vtk-5.6 -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/Windows-6.0/install/include/VTKEdge "-IC:/Program Files/MATLAB/R2010a/extern/include" -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/. -IC:/CUDA/include<br>
2>gpuPMatrixRecon.cu<br>--end snip--<br><br><br>with it off (set line uncommented in) I get<br><br>--snip--<br>C:/CUDA/bin64/nvcc.exe C:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/gpuPMatrixRecon.cu -arch sm_11 --ptxas-options=-v -maxrregcount=32 -Xcompiler /EHsc,/W3,/nologo,/Od,/Zi,/MTd -DCUDADeviceProperties_DLLExport=yes -DCPU_RECON=yes -m64 -DcpuReconPlugin_EXPORTS -ccbin "c:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin" -DNVCC -c -o C:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/dvip4-Win64/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/Debug/cpuReconPlugin_generated_gpuPMatrixRecon.cu.obj -IC:/CUDA/include -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/source/cpp/lib/3rdParty/Win/boost-cmake-1_41_0 "-IC:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/common/inc" -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/Windows-6.0/install/include/vtk-5.6 -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/Windows-6.0/install/include/VTKEdge "-IC:/Program Files/MATLAB/R2010a/extern/include" -IC:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/. -IC:/CUDA/include<br>
2>gpuPMatrixRecon.cu<br>--end snip--<br><br>Which is what (I think) I desire... unless there is something else I am not aware of.<br><br>I am reporting what I am seeing. I have modified FindCUDA, but only with messages so I can see what it is doing. I have not changed the functionality of FindCUDA at all.<br>
<br>--snip--<br>So what happens when you add the same
file to more than one project in the same directory is this (more or
less).<br><br>project1<br> -- <a href="http://myfile.cu/" target="_blank">myfile.cu</a>: had rule to build project1_myfile.cu.obj from <a href="http://myfile.cu/" target="_blank">myfile.cu</a><br>
<br>project2<br> CMake Rules<br> -- cmake_build_..._myfile.rule: has rule to build project2_myfile.cu.obj from <a href="http://myfile.cu/" target="_blank">myfile.cu</a><br> -- <a href="http://myfile.cu/" target="_blank">myfile.cu</a>: has rule to build project1_myfile.cu.obj from <a href="http://myfile.cu/" target="_blank">myfile.cu</a><br>
<br>The problem you have when building in parallel is there are two
build commands for project1_myfile.cu.obj. If you compile project1 and
project2 at the same time, you can get a race condition for
project1_myfile.cu.obj. If you build them one at a time, project2 will
run the cmake....rule file that compiles project2_myfile.cu.obj then try
to compile <a href="http://myfile.cu/" target="_blank">myfile.cu</a>'s
rule, but see that it is done (from project1). At any rate, I'm not
sure if this is ultimately related to your problem or the other issue
you described were at the root of the problem.<br>--end snip--<br><br>I am not parallel building so I do not think it is a problem. As far as the race to build project1_myfile.cu.obj I do not appear to be experiencing this (as I am not parallel building). I don't think I am experiencing the linear build issue as it appears that if I select each lib which has the .cu file and select rebuild... that each lib gets rebuilt as expected. I did look for this issue based on the CMake FindCUDA documentation. This may be related to the following output goop at msvc compiler window:<br>
<br>--snip--<br>Generating temporary cmake readable file: C:/Users/bdavis5/Documents/QS/QS-NIH/source/branches/trunk/build/dvip4-Win64/source/Matlab/lib/3rdParty/Siemens/gpu/PMatrixRecon/CMakeFiles/gpuReconPlugin_generated_gpuPMatrixRecon.cu.obj.depend.tmp<br>
--end snip--<br><br>Note the prefix gpuReconPlugin and tmp possibly referring to a temporary file with the .obj sandwiched in between. It's a Cuda, CMake, obj sandwich. Mmmmm add pickles and a little mayo and it's tasty. I should coin this term and open up a Techno Deli :-)<br>
<br>--snip--<br>Incidentally, you can use the same file in different projects if they
are in different directories (i.e. CMake directory scopes) without
causing this to happen.<br>--end snip--<br><br>Yes.... and my reply to this is a restatement of above. <br><br>--snip--<br>Have I mentioned to anyone lately why I can't understand CMake's (poor)
design choice in correlating directory structure to target build
specification. It would appear to me from this (if unmodified) that I
must create a new directory in order to get CMake to build 2 dlls in the
same directory based on the same source using different compiler
defined. I have reached a state of boondogglement.<br>--end snip--<br><br>Why was this a design decision on CMake's part?<br><br>--snip--<br>Why are you specifying the same option for every type of build? Any
arguments after OPTIONS and before DEBUG, RELEASE, etc. will be applied
to all build types.<br>--end snip--<br><br>I read through the FindCUDA source and thought this was how I should specify this. Output of my messages in FindCUDA supported the use of this syntax:<br><br>--snip--<br>_sources = _cuda_wrap_sources<br>
_cmake_options = _cuda_wrap_cmake_options<br>_options = _cuda_wrap_options<br>_found_config = _DEBUG<br>_found_config = _RELEASE<br>_found_config = _MINSIZEREL<br>_found_config = _RELWITHDEBINFO<br>CUDA_WRAP_OPTION_NVCC_FLAGS = <br>
CUDA_HOST_FLAGS = set(CMAKE_HOST_FLAGS )<br>CUDA_NVCC_FLAGS = <br>CUDA_NVCC_FLAGS_CONFIG = # Build specific configuration flags<br>set(CUDA_NVCC_FLAGS_DEBUG "-arch;sm_11;--ptxas-options=-v;-maxrregcount=32;-Xcompiler;/EHsc,/W3,/nologo,/Od,/Zi,/MTd;;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes")<br>
set(CUDA_NVCC_FLAGS_RELEASE ";;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes")<br>set(CUDA_NVCC_FLAGS_MINSIZEREL ";;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes")<br>set(CUDA_NVCC_FLAGS_RELWITHDEBINFO ";;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes")<br>
CUDA_NVCC_DEFINITIONS = CUDA_NVCC_DEFINITIONS-NOTFOUND<br>nvcc_flags = -m64<br>nvcc_flags = -m64;-DgpuReconPlugin_EXPORTS<br>CUDA _options = DEBUG;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes;RELEASE;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes;MINSIZEREL;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes;RELWITHDEBINFO;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes <br>
CUDA _cmake_options = SHARED <br><br>--end snip--<br><br>note the set(CUDA_NVCC_FLAGS_.... ...). Debug was being set so I thought this was correct.<br><br><br>