From 36cc9c524fd75dc904cd02fb0e537ff8cd367c06 Mon Sep 17 00:00:00 2001 From: Christopher Kelly Date: Fri, 23 Jun 2023 09:57:38 -0400 Subject: [PATCH] Threaded the constructor of GeneralLocalStencil --- Grid/stencil/GeneralLocalStencil.h | 104 ++++++++++++++--------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/Grid/stencil/GeneralLocalStencil.h b/Grid/stencil/GeneralLocalStencil.h index 5e9f2cd6..333f7028 100644 --- a/Grid/stencil/GeneralLocalStencil.h +++ b/Grid/stencil/GeneralLocalStencil.h @@ -79,60 +79,60 @@ public: this->_entries.resize(npoints* osites); this->_entries_p = &_entries[0]; + thread_for(site, osites, { + Coordinate Coor; + Coordinate NbrCoor; - Coordinate Coor; - Coordinate NbrCoor; - for(Integer site=0;siteoCoorFromOindex(Coor,site); - for(int d=0;d_rdimensions[d]; - NbrCoor[d] = (Coor[d] + shifts[ii][d] + rd )%rd; + for(Integer ii=0;iioCoorFromOindex(Coor,site); + for(int d=0;d_rdimensions[d]; + NbrCoor[d] = (Coor[d] + shifts[ii][d] + rd )%rd; + } + SE._offset = grid->oIndexReduced(NbrCoor); + + //////////////////////////////////////////////// + // Inner index permute calculation + // Simpler version using icoor calculation + //////////////////////////////////////////////// + SE._permute =0; + for(int d=0;d_fdimensions[d]; + int rd = grid->_rdimensions[d]; + int ly = grid->_simd_layout[d]; + + assert((ly==1)||(ly==2)); + + int shift = (shifts[ii][d]+fd)%fd; // make it strictly positive 0.. L-1 + int x = Coor[d]; // x in [0... rd-1] as an oSite + + int permute_dim = grid->PermuteDim(d); + int permute_slice=0; + if(permute_dim){ + int num = shift%rd; // Slice within dest osite cell of slice zero + int wrap = shift/rd; // Number of osite local volume cells crossed through + // x+num < rd dictates whether we are in same permute state as slice 0 + if ( x< rd-num ) permute_slice=wrap; + else permute_slice=(wrap+1)%ly; + } + if ( permute_slice ) { + int ptype =grid->PermuteType(d); + uint8_t mask =0x1<_entries[lex] = SE; } - SE._offset = grid->oIndexReduced(NbrCoor); - - //////////////////////////////////////////////// - // Inner index permute calculation - // Simpler version using icoor calculation - //////////////////////////////////////////////// - SE._permute =0; - for(int d=0;d_fdimensions[d]; - int rd = grid->_rdimensions[d]; - int ly = grid->_simd_layout[d]; - - assert((ly==1)||(ly==2)); - - int shift = (shifts[ii][d]+fd)%fd; // make it strictly positive 0.. L-1 - int x = Coor[d]; // x in [0... rd-1] as an oSite - - int permute_dim = grid->PermuteDim(d); - int permute_slice=0; - if(permute_dim){ - int num = shift%rd; // Slice within dest osite cell of slice zero - int wrap = shift/rd; // Number of osite local volume cells crossed through - // x+num < rd dictates whether we are in same permute state as slice 0 - if ( x< rd-num ) permute_slice=wrap; - else permute_slice=(wrap+1)%ly; - } - if ( permute_slice ) { - int ptype =grid->PermuteType(d); - uint8_t mask =0x1<_entries[lex] = SE; - } - } + }); } };