Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VTK-m
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sudhanshu Sane
VTK-m
Commits
e2c61e01
Commit
e2c61e01
authored
Dec 27, 2018
by
Robert Maynard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the HelloWorld example to use VTK-m runtime device adapter logic
parent
34165c8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
52 deletions
+14
-52
examples/hello_world/CMakeLists.txt
examples/hello_world/CMakeLists.txt
+5
-13
examples/hello_world/HelloWorld.cxx
examples/hello_world/HelloWorld.cxx
+9
-16
examples/hello_world/HelloWorldTBB.cxx
examples/hello_world/HelloWorldTBB.cxx
+0
-23
No files found.
examples/hello_world/CMakeLists.txt
View file @
e2c61e01
...
...
@@ -32,19 +32,11 @@ if(TARGET OpenGL::GL AND
set
(
gl_libs OpenGL::GL GLEW::GLEW GLUT::GLUT
)
add_executable
(
HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h
)
target_link_libraries
(
HelloWorld_SERIAL
PRIVATE vtkm_cont
${
gl_libs
}
)
if
(
TARGET vtkm::tbb
)
add_executable
(
HelloWorld_TBB HelloWorldTBB.cxx LoadShaders.h
)
target_link_libraries
(
HelloWorld_TBB
PRIVATE vtkm_cont
${
gl_libs
}
)
endif
()
if
(
TARGET vtkm::cuda
)
add_executable
(
HelloWorld
_CUDA
HelloWorld.cu LoadShaders.h
)
target_link_libraries
(
HelloWorld_CUDA
PRIVATE vtkm_cont
${
gl_libs
}
)
add_executable
(
HelloWorld HelloWorld.cu LoadShaders.h
)
else
()
add_executable
(
HelloWorld HelloWorld.cxx LoadShaders.h
)
endif
()
target_link_libraries
(
HelloWorld PRIVATE vtkm_cont
${
gl_libs
}
)
endif
()
examples/hello_world/HelloWorld.cxx
View file @
e2c61e01
...
...
@@ -18,12 +18,6 @@
// this software.
//============================================================================
//We first check if VTKM_DEVICE_ADAPTER is defined, so that when TBB and CUDA
//includes this file we use the device adapter that they have set.
#ifndef VTKM_DEVICE_ADAPTER
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
// Must be included before any other GL includes:
#include <GL/glew.h>
...
...
@@ -31,6 +25,7 @@
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/interop/TransferToOpenGL.h>
#include <vtkm/worklet/DispatcherMapField.h>
...
...
@@ -53,7 +48,7 @@
#include "LoadShaders.h"
template
<
typename
DeviceAdapter
,
typename
T
>
template
<
typename
T
>
struct
HelloVTKMInterop
{
vtkm
::
Vec
<
vtkm
::
Int32
,
2
>
Dims
;
...
...
@@ -64,7 +59,7 @@ struct HelloVTKMInterop
vtkm
::
interop
::
BufferState
VBOState
;
vtkm
::
interop
::
BufferState
ColorState
;
vtkm
::
cont
::
Timer
<
DeviceAdapter
>
Timer
;
vtkm
::
cont
::
Timer
<>
Timer
;
std
::
vector
<
vtkm
::
Vec
<
T
,
3
>>
InputData
;
vtkm
::
cont
::
ArrayHandle
<
vtkm
::
Vec
<
T
,
3
>>
InHandle
;
...
...
@@ -172,8 +167,8 @@ struct HelloVTKMInterop
GenerateSurfaceWorklet
worklet
(
t
);
DispatcherType
(
worklet
).
Invoke
(
this
->
InHandle
,
this
->
OutCoords
,
this
->
OutColors
);
vtkm
::
interop
::
TransferToOpenGL
(
this
->
OutCoords
,
this
->
VBOState
,
DeviceAdapter
()
);
vtkm
::
interop
::
TransferToOpenGL
(
this
->
OutColors
,
this
->
ColorState
,
DeviceAdapter
()
);
vtkm
::
interop
::
TransferToOpenGL
(
this
->
OutCoords
,
this
->
VBOState
);
vtkm
::
interop
::
TransferToOpenGL
(
this
->
OutColors
,
this
->
ColorState
);
this
->
render
();
if
(
t
>
10
)
{
...
...
@@ -184,8 +179,7 @@ struct HelloVTKMInterop
};
//global static so that glut callback can access it
using
DeviceAdapter
=
VTKM_DEFAULT_DEVICE_ADAPTER_TAG
;
HelloVTKMInterop
<
DeviceAdapter
,
vtkm
::
Float32
>*
helloWorld
=
nullptr
;
HelloVTKMInterop
<
vtkm
::
Float32
>*
helloWorld
=
nullptr
;
// Render the output using simple OpenGL
void
run
()
...
...
@@ -201,9 +195,8 @@ void idle()
int
main
(
int
argc
,
char
**
argv
)
{
using
DeviceAdapterTraits
=
vtkm
::
cont
::
DeviceAdapterTraits
<
DeviceAdapter
>
;
std
::
cout
<<
"Running Hello World example on device adapter: "
<<
DeviceAdapterTraits
::
GetName
()
<<
std
::
endl
;
vtkm
::
cont
::
Initialize
(
argc
,
argv
);
std
::
cout
<<
"Running Hello World example: "
<<
std
::
endl
;
glewExperimental
=
GL_TRUE
;
glutInit
(
&
argc
,
argv
);
...
...
@@ -221,7 +214,7 @@ int main(int argc, char** argv)
std
::
cout
<<
"glewInit failed
\n
"
;
}
HelloVTKMInterop
<
DeviceAdapter
,
vtkm
::
Float32
>
hw
(
width
,
height
);
HelloVTKMInterop
<
vtkm
::
Float32
>
hw
(
width
,
height
);
helloWorld
=
&
hw
;
glutDisplayFunc
(
run
);
...
...
examples/hello_world/HelloWorldTBB.cxx
deleted
100644 → 0
View file @
34165c8e
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_TBB
#include "HelloWorld.cxx"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment