Skip to content

Commit

Permalink
Merge pull request #83 from stevenrbrandt/fix-simd-try2
Browse files Browse the repository at this point in the history
Fix Simd
  • Loading branch information
leowerneck committed Jul 27, 2023
2 parents c064859 + e8f6015 commit 1a09bc0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
17 changes: 14 additions & 3 deletions CarpetX/WaveToy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,38 @@
from subprocess import call
import numpy as np
from fstr import f
from outputC import lhrh

par.set_parval_from_str("outputC::PRECISION", "CCTK_REALVEC")

pre_kernel = """
#include <iostream>
#include <cmath>
const int nx = 10, ny = 10;
int mask;
using std::cos;
using std::sin;
typedef double CCTK_REALVEC;
struct PointDesc {
static constexpr int DI[3]={0,0,0};
double x,y;
double x,y,dx=.01,dy=.02;
int I=0;
};
namespace Arith {
template<typename T>
double iota() { return T(0); }
}
struct GF {
double data;
double& operator()(int n) { return data; }
double& operator()(int n,int p) { return data; }
double& operator()(int n,int l,int p) { return data; }
};
double cctk_delta_space[3] = {.5, .4};
Expand Down Expand Up @@ -132,7 +144,7 @@ def main():
z0 = thorn.declare_param('z0',default=0,vmin=-100,vmax=100,doc="The z pos of the wave")
zero = thorn.declare_param('zero',default=0,vmin=0,vmax=0,doc="zero")

centering='CVV'
centering='VVC'

# AUXEVOL needed for the evo, can be freed after evaluating rhs (1 time level)
# AUX uu_rhs (1 time level)
Expand All @@ -146,7 +158,6 @@ def main():
regrid_error = thorn.get_regrid_error()
x,y,z = thorn.get_xyz()

from outputC import lhrh
import indexedexp as ixp
import NRPy_param_funcs as par

Expand Down
5 changes: 3 additions & 2 deletions cactusthorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,15 +726,16 @@ def generate(self,dirname=None,cactus_config="sim",cactus_thornlist=None,schedul
assert "Bad value for gri.ET_driver={gri.ET_driver}"
for func in src.funcs:
print('',file=fd)
if gri.ET_driver == "CarpetX":
print(" using CCTK_BOOLVEC = simdl<CCTK_REAL>;",file=fd)
print(" using CCTK_REALVEC = simd<CCTK_REAL>;",file=fd)
print(f(u"void {func.name}(CCTK_ARGUMENTS) {{"),file=fd)
if gri.ET_driver == "Carpet":
print(f(u" DECLARE_CCTK_ARGUMENTS_{func.name};"),file=fd)
elif gri.ET_driver == "CarpetX":
print(f(u" DECLARE_CCTK_ARGUMENTSX_{func.name};"),file=fd)
print(" DECLARE_CCTK_PARAMETERS;",file=fd)
if gri.ET_driver == "CarpetX":
print(" using CCTK_BOOLVEC = simdl<CCTK_REAL>;",file=fd)
print(" using CCTK_REALVEC = simd<CCTK_REAL>;",file=fd)
print(" constexpr std::size_t CCTK_VECSIZE CCTK_ATTRIBUTE_UNUSED = std::tuple_size_v<CCTK_REALVEC>;",file=fd)
print(" const Loop::GF3D5layout CCTK_ATTRIBUTE_UNUSED VVV_layout(cctkGH, {0,0,0});",file=fd)
print(" const Loop::GF3D5layout CCTK_ATTRIBUTE_UNUSED VVC_layout(cctkGH, {0,0,1});",file=fd)
Expand Down
6 changes: 4 additions & 2 deletions grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ def _gfaccess(gfarrayname, varname, ijklstring, context):
elif gftype == "EXTERNAL":
return retstring + varname + "(" + mask + find_centering(varname) + "_index)"
elif gftype == "CORE":
if varname in ["x", "y", "z"]:
if varname in ["y", "z"]:
return retstring + "p." + varname
elif varname == "x":
return retstring + "p.x + Arith::iota<CCTK_REALVEC>() * p.dx"
elif varname == "regrid_error":
return retstring + varname + "(CCC_index)"
return retstring + varname + "("+mask+"CCC_index)"
else:
raise Exception("Unknown CORE variable: " + varname)
elif gftype == "TILE_TMP":
Expand Down

0 comments on commit 1a09bc0

Please sign in to comment.