Grid 0.7.0
Lattice_transpose.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/lattice/Lattice_transpose.h
6
7 Copyright (C) 2015
8
9Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 See the full license in the file "LICENSE" in the top level distribution directory
27*************************************************************************************/
28/* END LEGAL */
29#ifndef GRID_LATTICE_TRANSPOSE_H
30#define GRID_LATTICE_TRANSPOSE_H
31
33// Transpose
35
37
39// Transpose
41/*
42template<class vobj>
43inline Lattice<vobj> transpose(const Lattice<vobj> &lhs){
44 Lattice<vobj> ret(lhs.Grid());
45 autoView( ret_v, ret, AcceleratorWrite);
46 autoView( lhs_v, lhs, AcceleratorRead);
47 accelerator_for(ss,lhs_v.size(),vobj::Nsimd(),{
48 coalescedWrite(ret_v[ss], transpose(lhs_v(ss)));
49 });
50 return ret;
51};
52*/
53
55// Index level dependent transpose
57template<int Index,class vobj>
59{
60 Lattice<decltype(transposeIndex<Index>(vobj()))> ret(lhs.Grid());
61 autoView( ret_v, ret, AcceleratorWrite);
62 autoView( lhs_v, lhs, AcceleratorRead);
63 accelerator_for(ss,lhs_v.size(),vobj::Nsimd(),{
64 coalescedWrite(ret_v[ss] , transposeIndex<Index>(lhs_v(ss)));
65 });
66 return ret;
67};
68
70#endif
#define accelerator_for(iterator, num, nsimd,...)
auto TransposeIndex(const Lattice< vobj > &lhs) -> Lattice< decltype(transposeIndex< Index >(vobj()))>
#define autoView(l_v, l, mode)
@ AcceleratorRead
@ AcceleratorWrite
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36