1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 // Copyright 2014 UT-Battelle, LLC.
11 // Copyright 2014 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-NA0003525 with NTESS,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20
21 #include <vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h>
22
23 namespace vtkm
24 {
25 namespace cont
26 {
27
ScheduleTask(vtkm::exec::serial::internal::TaskTiling1D & functor,vtkm::Id size)28 void DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>::ScheduleTask(
29 vtkm::exec::serial::internal::TaskTiling1D& functor,
30 vtkm::Id size)
31 {
32 const vtkm::Id MESSAGE_SIZE = 1024;
33 char errorString[MESSAGE_SIZE];
34 errorString[0] = '\0';
35 vtkm::exec::internal::ErrorMessageBuffer errorMessage(errorString, MESSAGE_SIZE);
36 functor.SetErrorMessageBuffer(errorMessage);
37
38 const vtkm::Id iterations = size / 1024;
39 vtkm::Id index = 0;
40 for (vtkm::Id i = 0; i < iterations; ++i)
41 {
42 functor(index, index + 1024);
43 index += 1024;
44 }
45 functor(index, size);
46
47 if (errorMessage.IsErrorRaised())
48 {
49 throw vtkm::cont::ErrorExecution(errorString);
50 }
51 }
52
ScheduleTask(vtkm::exec::serial::internal::TaskTiling3D & functor,vtkm::Id3 size)53 void DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>::ScheduleTask(
54 vtkm::exec::serial::internal::TaskTiling3D& functor,
55 vtkm::Id3 size)
56 {
57 const vtkm::Id MESSAGE_SIZE = 1024;
58 char errorString[MESSAGE_SIZE];
59 errorString[0] = '\0';
60 vtkm::exec::internal::ErrorMessageBuffer errorMessage(errorString, MESSAGE_SIZE);
61 functor.SetErrorMessageBuffer(errorMessage);
62
63 for (vtkm::Id k = 0; k < size[2]; ++k)
64 {
65 for (vtkm::Id j = 0; j < size[1]; ++j)
66 {
67 functor(0, size[0], j, k);
68 }
69 }
70
71 if (errorMessage.IsErrorRaised())
72 {
73 throw vtkm::cont::ErrorExecution(errorString);
74 }
75 }
76 }
77 }
78