Skip to content

Commit

Permalink
Examples: Generate SimpleWaveScriptCaKernel
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Feb 21, 2014
1 parent 678081d commit df9353e
Show file tree
Hide file tree
Showing 13 changed files with 1,184 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Examples/SimpleWaveScriptCaKernel/cakernel.ccl
@@ -0,0 +1,25 @@
CCTK_CUDA_KERNEL initial_sine_calc TYPE=gpu_cuda/3dblock TILE="8,8,8" SHARECODE=yes STENCIL="0,0,0,0,0,0" EXTERIOR="0,0,0,0,0,0"
{
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=out {phi} "phi"
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=inout {pi} "pi"
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=in {x} "x"
CCTK_CUDA_KERNEL_PARAMETER
{
fdOrder
}
"fdOrder"
}

CCTK_CUDA_KERNEL calc_rhs TYPE=gpu_cuda/3dblock TILE="8,8,8" SHARECODE=yes STENCIL="0,0,0,0,0,0" EXTERIOR="0,0,0,0,0,0"
{
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=in {phi} "phi"
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=out {phirhs} "phirhs"
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=in {pi} "pi"
CCTK_CUDA_KERNEL_VARIABLE cached=no intent=out {pirhs} "pirhs"
CCTK_CUDA_KERNEL_PARAMETER
{
fdOrder
}
"fdOrder"
}

7 changes: 7 additions & 0 deletions Examples/SimpleWaveScriptCaKernel/configuration.ccl
@@ -0,0 +1,7 @@
# File produced by Kranc

REQUIRES GenericFD
OPTIONAL LoopControl
{
}
REQUIRES CUDA MPI CaKernel
63 changes: 63 additions & 0 deletions Examples/SimpleWaveScriptCaKernel/interface.ccl
@@ -0,0 +1,63 @@
# File produced by Kranc

implements: SimpleWaveScriptCaKernel

inherits: Accelerator Boundary GenericFD Grid



USES INCLUDE: CaCUDALib_driver_support.h
USES INCLUDE: GenericFD.h
USES INCLUDE: loopcontrol.h
USES INCLUDE: Symmetry.h
USES INCLUDE: Boundary.h

CCTK_INT FUNCTION MoLRegisterEvolved(CCTK_INT IN EvolvedIndex, CCTK_INT IN RHSIndex)
USES FUNCTION MoLRegisterEvolved

SUBROUTINE Diff_coeff(CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN dir, CCTK_INT IN nsize, CCTK_INT OUT ARRAY imin, CCTK_INT OUT ARRAY imax, CCTK_REAL OUT ARRAY q, CCTK_INT IN table_handle)
USES FUNCTION Diff_coeff

CCTK_INT FUNCTION MultiPatch_GetMap(CCTK_POINTER_TO_CONST IN cctkGH)
USES FUNCTION MultiPatch_GetMap

CCTK_INT FUNCTION Boundary_SelectGroupForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN group_name, CCTK_STRING IN bc_name)
USES FUNCTION Boundary_SelectGroupForBC

CCTK_INT FUNCTION Boundary_SelectVarForBC(CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN var_name, CCTK_STRING IN bc_name)
USES FUNCTION Boundary_SelectVarForBC

public:
CCTK_REAL phi_group type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0'
{
phi
} "phi_group"

public:
CCTK_REAL pi_group type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0'
{
pi
} "pi_group"

public:
CCTK_REAL phi_grouprhs type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0 Prolongation="None"'
{
phirhs
} "phi_grouprhs"

public:
CCTK_REAL pi_grouprhs type=GF timelevels=3 tags='tensortypealias="Scalar" tensorweight=0 Prolongation="None"'
{
pirhs
} "pi_grouprhs"

# These functions are provided by the CaKernel thorn

CCTK_INT FUNCTION Device_RegisterMem(CCTK_POINTER IN cctkGH, CCTK_INT IN vi, CCTK_INT IN num_tls)
REQUIRES FUNCTION Device_RegisterMem

CCTK_INT FUNCTION Device_UnRegisterMem(CCTK_POINTER IN cctkGH, CCTK_INT IN vi)
REQUIRES FUNCTION Device_UnRegisterMem

CCTK_POINTER FUNCTION Device_GetVarI (CCTK_POINTER IN cctkGH, CCTK_INT IN vi, CCTK_INT IN num_tls)
REQUIRES FUNCTION Device_GetVarI
200 changes: 200 additions & 0 deletions Examples/SimpleWaveScriptCaKernel/param.ccl
@@ -0,0 +1,200 @@
# File produced by Kranc


shares: GenericFD

USES CCTK_INT assume_stress_energy_state


shares: MethodOfLines

USES CCTK_INT MoL_Num_Evolved_Vars
USES CCTK_INT MoL_Num_ArrayEvolved_Vars

restricted:
CCTK_INT verbose "verbose" STEERABLE=ALWAYS
{
*:* :: ""
} 0

restricted:
CCTK_INT other_timelevels "Number of active timelevels for non-evolved grid functions" STEERABLE=RECOVER
{
0:3 :: ""
} 1

restricted:
CCTK_INT fdOrder "fdOrder"
{
2 :: ""
4 :: ""
} 2

restricted:
CCTK_INT SimpleWaveScriptCaKernel_MaxNumEvolvedVars "Number of evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_Evolved_Vars STEERABLE=RECOVER
{
2:2 :: "Number of evolved variables used by this thorn"
} 2

restricted:
CCTK_INT SimpleWaveScriptCaKernel_MaxNumArrayEvolvedVars "Number of Array evolved variables used by this thorn" ACCUMULATOR-BASE=MethodofLines::MoL_Num_ArrayEvolved_Vars STEERABLE=RECOVER
{
0:0 :: "Number of Array evolved variables used by this thorn"
} 0

restricted:
CCTK_INT timelevels "Number of active timelevels" STEERABLE=RECOVER
{
0:3 :: ""
} 3

restricted:
CCTK_INT rhs_timelevels "Number of active RHS timelevels" STEERABLE=RECOVER
{
0:3 :: ""
} 1

restricted:
CCTK_INT initial_sine_calc_calc_every "initial_sine_calc_calc_every" STEERABLE=ALWAYS
{
*:* :: ""
} 1

restricted:
CCTK_INT calc_rhs_calc_every "calc_rhs_calc_every" STEERABLE=ALWAYS
{
*:* :: ""
} 1

restricted:
CCTK_INT initial_sine_calc_calc_offset "initial_sine_calc_calc_offset" STEERABLE=ALWAYS
{
*:* :: ""
} 0

restricted:
CCTK_INT calc_rhs_calc_offset "calc_rhs_calc_offset" STEERABLE=ALWAYS
{
*:* :: ""
} 0

private:
KEYWORD phi_bound "Boundary condition to implement" STEERABLE=ALWAYS
{
"flat" :: "Flat boundary condition"
"none" :: "No boundary condition"
"static" :: "Boundaries held fixed"
"radiative" :: "Radiation boundary condition"
"scalar" :: "Dirichlet boundary condition"
"newrad" :: "Improved radiative boundary condition"
"skip" :: "skip boundary condition code"
} "skip"

private:
KEYWORD pi_bound "Boundary condition to implement" STEERABLE=ALWAYS
{
"flat" :: "Flat boundary condition"
"none" :: "No boundary condition"
"static" :: "Boundaries held fixed"
"radiative" :: "Radiation boundary condition"
"scalar" :: "Dirichlet boundary condition"
"newrad" :: "Improved radiative boundary condition"
"skip" :: "skip boundary condition code"
} "skip"

private:
KEYWORD phi_group_bound "Boundary condition to implement" STEERABLE=ALWAYS
{
"flat" :: "Flat boundary condition"
"none" :: "No boundary condition"
"static" :: "Boundaries held fixed"
"radiative" :: "Radiation boundary condition"
"scalar" :: "Dirichlet boundary condition"
"newrad" :: "Improved radiative boundary condition"
"skip" :: "skip boundary condition code"
} "none"

private:
KEYWORD pi_group_bound "Boundary condition to implement" STEERABLE=ALWAYS
{
"flat" :: "Flat boundary condition"
"none" :: "No boundary condition"
"static" :: "Boundaries held fixed"
"radiative" :: "Radiation boundary condition"
"scalar" :: "Dirichlet boundary condition"
"newrad" :: "Improved radiative boundary condition"
"skip" :: "skip boundary condition code"
} "none"

private:
CCTK_REAL phi_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
{
"0:*" :: "outgoing characteristic speed > 0"
} 1.

private:
CCTK_REAL pi_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
{
"0:*" :: "outgoing characteristic speed > 0"
} 1.

private:
CCTK_REAL phi_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
{
"0:*" :: "outgoing characteristic speed > 0"
} 1.

private:
CCTK_REAL pi_group_bound_speed "characteristic speed at boundary" STEERABLE=ALWAYS
{
"0:*" :: "outgoing characteristic speed > 0"
} 1.

private:
CCTK_REAL phi_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
{
"*:*" :: "value of limit value is unrestricted"
} 0.

private:
CCTK_REAL pi_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
{
"*:*" :: "value of limit value is unrestricted"
} 0.

private:
CCTK_REAL phi_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
{
"*:*" :: "value of limit value is unrestricted"
} 0.

private:
CCTK_REAL pi_group_bound_limit "limit value for r -> infinity" STEERABLE=ALWAYS
{
"*:*" :: "value of limit value is unrestricted"
} 0.

private:
CCTK_REAL phi_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
{
"*:*" :: "unrestricted"
} 0.

private:
CCTK_REAL pi_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
{
"*:*" :: "unrestricted"
} 0.

private:
CCTK_REAL phi_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
{
"*:*" :: "unrestricted"
} 0.

private:
CCTK_REAL pi_group_bound_scalar "Dirichlet boundary value" STEERABLE=ALWAYS
{
"*:*" :: "unrestricted"
} 0.

72 changes: 72 additions & 0 deletions Examples/SimpleWaveScriptCaKernel/schedule.ccl
@@ -0,0 +1,72 @@
# File produced by Kranc


STORAGE: phi_group[timelevels]

STORAGE: pi_group[timelevels]

STORAGE: phi_grouprhs[rhs_timelevels]

STORAGE: pi_grouprhs[rhs_timelevels]

schedule SimpleWaveScriptCaKernel_Startup at STARTUP
{
LANG: C
OPTIONS: meta
} "create banner"

schedule SimpleWaveScriptCaKernel_RegisterSymmetries in SymmetryRegister
{
LANG: C
OPTIONS: meta
} "register symmetries"

schedule CAKERNEL_Launch_initial_sine_calc as initial_sine_calc at initial
{
LANG: C
TAGS: Device=1
READS: grid::x(Everywhere)
READS: SimpleWaveScriptCaKernel::pi(Everywhere)
WRITES: SimpleWaveScriptCaKernel::phi(ERROR(Automatic))
WRITES: SimpleWaveScriptCaKernel::pi(ERROR(Automatic))
} "initial_sine_calc"

schedule CAKERNEL_Launch_calc_rhs as calc_rhs in mol_calcrhs
{
LANG: C
TAGS: Device=1
READS: SimpleWaveScriptCaKernel::phi(Everywhere)
READS: SimpleWaveScriptCaKernel::pi(Everywhere)
WRITES: SimpleWaveScriptCaKernel::phirhs(ERROR(Automatic))
WRITES: SimpleWaveScriptCaKernel::pirhs(ERROR(Automatic))
} "calc_rhs"

schedule SimpleWaveScriptCaKernel_SelectBoundConds in MoL_PostStep
{
LANG: C
OPTIONS: level
SYNC: phi_group
SYNC: pi_group
} "select boundary conditions"

schedule SimpleWaveScriptCaKernel_CheckBoundaries at BASEGRID
{
LANG: C
OPTIONS: meta
} "check boundaries treatment"

schedule SimpleWaveScriptCaKernel_RegisterVars in MoL_Register
{
LANG: C
OPTIONS: meta
} "Register Variables for MoL"

schedule SimpleWaveScriptCaKernel_Init in CCTK_BASEGRID after Accelerator_SetDevice
{
LANG: C
OPTIONS: local
} "Initialize CUDA Device"

schedule group ApplyBCs as SimpleWaveScriptCaKernel_ApplyBCs in MoL_PostStep after SimpleWaveScriptCaKernel_SelectBoundConds
{
} "Apply boundary conditions controlled by thorn Boundary"

0 comments on commit df9353e

Please sign in to comment.