Skip to content

Commit

Permalink
[FIX] GetOffset for periodic cases in CUDA.
Browse files Browse the repository at this point in the history
  • Loading branch information
naoyam committed Apr 26, 2012
1 parent dabcc61 commit 5f6727c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/physis/physis_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,32 @@ extern "C" {
+ i3 * PSGridDim((__PSGridDev*)g, 0)
* PSGridDim((__PSGridDev*)g, 1);
}

CUDA_DEVICE
inline PSIndexType __PSGridGetOffsetPeriodic1DDev(const void *g,
PSIndexType i1) {
return (i1 + PSGridDim((__PSGridDev*)g, 0)) % PSGridDim((__PSGridDev*)g, 0);
}

CUDA_DEVICE
inline PSIndexType __PSGridGetOffsetPeriodic2DDev(const void *g,
PSIndexType i1,
PSIndexType i2) {
return __PSGridGetOffsetPeriodic1DDev(g, i1) +
(i2 + PSGridDim((__PSGridDev*)g, 1)) % PSGridDim((__PSGridDev*)g, 1)
* PSGridDim((__PSGridDev*)g, 0);
}

CUDA_DEVICE
inline PSIndexType __PSGridGetOffsetPeriodic3DDev(const void *g,
PSIndexType i1,
PSIndexType i2,
PSIndexType i3) {
return __PSGridGetOffsetPeriodic2DDev(g, i1, i2) +
(i3 + PSGridDim((__PSGridDev*)g, 2)) % PSGridDim((__PSGridDev*)g, 2)
* PSGridDim((__PSGridDev*)g, 0) * PSGridDim((__PSGridDev*)g, 1);
}


extern void __PSReduceGridFloat(void *buf, enum PSReduceOp op,
__PSGrid *g);
Expand Down

0 comments on commit 5f6727c

Please sign in to comment.