2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 // Maintainer: joaander
52 #include <boost/python.hpp>
53 using namespace boost::python
;
54 #include <boost/bind.hpp>
55 using namespace boost
;
57 #include "TableDihedralForceComputeGPU.h"
60 /*! \file TableDihedralForceComputeGPU.cc
61 \brief Defines the TableDihedralForceComputeGPU class
66 /*! \param sysdef System to compute forces on
67 \param table_width Width the tables will be in memory
68 \param log_suffix Name given to this instance of the table potential
70 TableDihedralForceComputeGPU::TableDihedralForceComputeGPU(boost::shared_ptr
<SystemDefinition
> sysdef
,
71 unsigned int table_width
,
72 const std::string
& log_suffix
)
73 : TableDihedralForceCompute(sysdef
, table_width
, log_suffix
)
75 // can't run on the GPU if there aren't any GPUs in the execution configuration
76 if (!exec_conf
->isCUDAEnabled())
78 m_exec_conf
->msg
->error() << "Creating a BondTableForceComputeGPU with no GPU in the execution configuration" << endl
;
79 throw std::runtime_error("Error initializing BondTableForceComputeGPU");
82 // allocate flags storage on the GPU
83 GPUArray
<unsigned int> flags(1, this->exec_conf
);
86 m_tuner
.reset(new Autotuner(32, 1024, 32, 5, 100000, "table_dihedral", this->m_exec_conf
));
89 /*! \post The table based forces are computed for the given timestep.
91 \param timestep specifies the current time step of the simulation
93 Calls gpu_compute_bondtable_forces to do the leg work
95 void TableDihedralForceComputeGPU::computeForces(unsigned int timestep
)
99 if (m_prof
) m_prof
->push(exec_conf
, "Dihedral Table");
101 // access the particle data
102 ArrayHandle
<Scalar4
> d_pos(m_pdata
->getPositions(), access_location::device
, access_mode::read
);
103 BoxDim box
= m_pdata
->getBox();
105 // access the table data
106 ArrayHandle
<Scalar2
> d_tables(m_tables
, access_location::device
, access_mode::read
);
108 ArrayHandle
<Scalar4
> d_force(m_force
,access_location::device
,access_mode::overwrite
);
109 ArrayHandle
<Scalar
> d_virial(m_virial
,access_location::device
,access_mode::overwrite
);
112 // Access the dihedral data for reading
113 ArrayHandle
<group_storage
<4> > d_gpu_dihedrallist(m_dihedral_data
->getGPUTable(), access_location::device
,access_mode::read
);
114 ArrayHandle
<unsigned int> d_gpu_n_dihedrals(m_dihedral_data
->getNGroupsArray(), access_location::device
, access_mode::read
);
115 ArrayHandle
<unsigned int> d_dihedrals_ABCD(m_dihedral_data
->getGPUPosTable(), access_location::device
, access_mode::read
);
118 // run the kernel on all GPUs in parallel
120 gpu_compute_table_dihedral_forces(d_force
.data
,
126 d_gpu_dihedrallist
.data
,
127 d_dihedrals_ABCD
.data
,
128 m_dihedral_data
->getGPUTableIndexer().getW(),
129 d_gpu_n_dihedrals
.data
,
134 m_exec_conf
->getComputeCapability());
138 if (exec_conf
->isCUDAErrorCheckingEnabled())
145 if (m_prof
) m_prof
->pop(exec_conf
);
148 void export_TableDihedralForceComputeGPU()
150 class_
<TableDihedralForceComputeGPU
, boost::shared_ptr
<TableDihedralForceComputeGPU
>, bases
<TableDihedralForceCompute
>, boost::noncopyable
>
151 ("TableDihedralForceComputeGPU",
152 init
< boost::shared_ptr
<SystemDefinition
>,
154 const std::string
& >())