[vtk-developers] Hi, can I compile a code using CUDA C and VTK?

Mingcheng Chen linyufly at gmail.com
Tue Apr 30 22:40:26 EDT 2013


Thanks to every answer!

My CMakeLists.txt is the following. For VTK, I only use
vtkUnstructuredGridReader. If I use include(${VKT_USE_FILE}), "make" will
cause an nvcc fatal error: A single input file is required for a non-link
phase when an output file is specified. If I use
include_directories(${VTK_INCLUDE_DIRS}) instead, my code can compile.
However, for those rendering functions of VTK, it seems
include_directories(${VTK_INCLUDE_DIRS}) is not enough.

cmake_minimum_required(VERSION 2.8)
project(Fastvection)

find_package(VTK)
if (VTK_FOUND)
        include (${VTK_USE_FILE})
        #include_directories(${VTK_INCLUDE_DIRS})
        message("VTK found")
else()
        message(ERROR "VTK not found")
endif()

find_package(CUDA)
if (CUDA_FOUND)
        include(FindCUDA)
        set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -gencode
arch=compute_35,code=sm_35)
        message("CUDA found")
else()
        message("CUDA not found")
endif()

cuda_add_executable(fastvection
        lcsBigBlockInitializationForPositions.cu
        lcsBigBlockInitializationForVelocities.cu
        lcsBlockedTracingOfRK4.cu
        lcsCollectActiveParticlesForNewInterval.cu
        lcsCollectActiveParticlesForNewRun.cu
        lcsExclusiveScanForInt.cu
        lcsGetGroupsForBlocks.cu
        lcsGetStartOffsetInParticles.cu
        lcsInitialCellLocation.cu
        lcsRedistributeParticles.cu
        lcsTetrahedronBlockIntersection.cu
        lcs.cpp lcsGeometry.cpp lcsUnitTest.cpp lcsUtility.cpp main.cpp
)




On Tue, Apr 30, 2013 at 9:03 AM, Robert Maynard
<robert.maynard at kitware.com>wrote:

> Here is an example CMakeLists.txt that combines VTK file reading and cuda.
>
> project(Example)
>
> #you should only need a couple vtk libraries
> find_package(VTK 6.0
>   COMPONENTS
>   vtkCommonCore
>   vtkCommonDataModel
>   vtkCommonExecutionModel
>   vtkIOLegacy
>   REQUIRED)
>
> find_package(CUDA REQUIRED)
>
> #since we don't have any vtk factories this will work.
> include(${VTK_USE_FILE})
>
> #list your cuda and c++ source files
> set(sources
>   main.cpp
>   cuda_example.cu
>   )
>
> cuda_add_executable(example ${sources})
> target_link_libraries(example
>   vtkCommonCore
>   vtkCommonDataModel
>   vtkCommonExecutionModel
>   vtkIOLegacy)
>
> On Tue, Apr 30, 2013 at 9:51 AM, Joachim Pouderoux
> <joachim.pouderoux at kitware.com> wrote:
> > Mingcheng,
> >
> > I guess you will have a lot of difficulties to compile VTK with CUDA.
> > You should better isolate your cuda code (no vtk dependency/header) in a
> > cuda library that you will link together with VTK library against your
> C++
> > code.
> >
> > Joachim Pouderoux
> >
> > PhD, R&D Engineer
> > Kitware SAS
> >
> >
> >
> > 2013/4/30 Mingcheng Chen <linyufly at gmail.com>
> >>
> >> Hi Jean-Christophe,
> >>
> >> Thank you!
> >>
> >> I use VTK 6.0 and CUDA 5.0. I just need vtkUnstructuredGridReader to
> read
> >> something in main.cpp and then everything is CUDA.
> >>
> >> Thanks again!
> >>
> >> Best regards,
> >> Mingcheng Chen
> >> April 29th, 2013
> >>
> >>
> >> On Mon, Apr 29, 2013 at 6:54 PM, Jean-Christophe Fillion-Robin
> >> <jchris.fillionr at kitware.com> wrote:
> >>>
> >>> Hi Mingcheng,
> >>>
> >>> To help identify the issue, could you specify which version of VTK you
> >>> are building against. Providing a small example using either gist or
> github
> >>> would be helpful.
> >>>
> >>> Hth
> >>> Jc
> >>>
> >>>
> >>> On Mon, Apr 29, 2013 at 6:16 PM, Mingcheng Chen <linyufly at gmail.com>
> >>> wrote:
> >>>>
> >>>> Hi everyone,
> >>>>
> >>>> My code contains a main.cpp and several *.cu files. The main.cpp uses
> >>>> some VTK functions.
> >>>>
> >>>> How can I make it compiled in ubuntu? In Windows I can use Visual
> >>>> Studio.
> >>>>
> >>>> Is cmake able to do that? I failed...
> >>>>
> >>>> Thanks!
> >>>>
> >>>> Best regards,
> >>>> Mingcheng Chen
> >>>> April 29th, 2013
> >>>>
> >>>> --
> >>>> Research Assistant in Graphics Group
> >>>> University of Illinois at Urbana-Champaign
> >>>> http://mingchengchen.org
> >>>>
> >>>> _______________________________________________
> >>>> Powered by www.kitware.com
> >>>>
> >>>> Visit other Kitware open-source projects at
> >>>> http://www.kitware.com/opensource/opensource.html
> >>>>
> >>>> Follow this link to subscribe/unsubscribe:
> >>>> http://www.vtk.org/mailman/listinfo/vtk-developers
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> +1 919 869 8849
> >>
> >>
> >>
> >>
> >> --
> >> Research Assistant in Graphics Group
> >> University of Illinois at Urbana-Champaign
> >> http://mingchengchen.org
> >>
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.vtk.org/mailman/listinfo/vtk-developers
> >>
> >>
> >
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtk-developers
> >
> >
>



-- 
Research Assistant in Graphics Group
University of Illinois at Urbana-Champaign
http://mingchengchen.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20130430/4c5124e4/attachment.html>


More information about the vtk-developers mailing list