Skip to content

Commit ec55d8f

Browse files
author
Bussmann
committed
Fixed issue #73
1 parent c853148 commit ec55d8f

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

lib/isaac/isaac_defines.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif
3939

4040
#ifndef ISAAC_GUARD_SIZE
41-
#define ISAAC_GUARD_SIZE 2
41+
#define ISAAC_GUARD_SIZE 1
4242
#endif
4343

4444
#ifndef ISAAC_DEFAULT_STEP

lib/isaac/isaac_kernel.hpp

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,40 @@ ISAAC_HOST_DEVICE_INLINE isaac_float get_value (
255255
return result;
256256
}
257257

258-
template < typename TLocalSize >
258+
template < bool TInterpolation, typename TLocalSize >
259259
ISAAC_HOST_DEVICE_INLINE void check_coord( isaac_float3& coord, const TLocalSize local_size)
260260
{
261+
constexpr auto extra_border = static_cast<decltype(local_size.value.x)>(TInterpolation);
261262
if (coord.x < isaac_float(0))
262263
coord.x = isaac_float(0);
263264
if (coord.y < isaac_float(0))
264265
coord.y = isaac_float(0);
265266
if (coord.z < isaac_float(0))
266267
coord.z = isaac_float(0);
267-
if ( coord.x >= isaac_float(local_size.value.x) )
268-
coord.x = isaac_float(local_size.value.x)-isaac_float(1)-FLT_MIN;
269-
if ( coord.y >= isaac_float(local_size.value.y) )
270-
coord.y = isaac_float(local_size.value.y)-isaac_float(1)-FLT_MIN;
271-
if ( coord.z >= isaac_float(local_size.value.z) )
272-
coord.z = isaac_float(local_size.value.z)-isaac_float(1)-FLT_MIN;
268+
if ( coord.x >= isaac_float(local_size.value.x-extra_border) )
269+
coord.x = isaac_float(local_size.value.x-extra_border)-FLT_MIN;
270+
if ( coord.y >= isaac_float(local_size.value.y-extra_border) )
271+
coord.y = isaac_float(local_size.value.y-extra_border)-FLT_MIN;
272+
if ( coord.z >= isaac_float(local_size.value.z-extra_border) )
273+
coord.z = isaac_float(local_size.value.z-extra_border)-FLT_MIN;
274+
}
275+
276+
template < bool TInterpolation, typename TLocalSize >
277+
ISAAC_HOST_DEVICE_INLINE void check_coord_with_guard( isaac_float3& coord, const TLocalSize local_size)
278+
{
279+
constexpr auto extra_border = static_cast<decltype(local_size.value.x)>(TInterpolation);
280+
if (coord.x < isaac_float(-ISAAC_GUARD_SIZE))
281+
coord.x = isaac_float(-ISAAC_GUARD_SIZE);
282+
if (coord.y < isaac_float(-ISAAC_GUARD_SIZE))
283+
coord.y = isaac_float(-ISAAC_GUARD_SIZE);
284+
if (coord.z < isaac_float(-ISAAC_GUARD_SIZE))
285+
coord.z = isaac_float(-ISAAC_GUARD_SIZE);
286+
if ( coord.x >= isaac_float(local_size.value.x+ISAAC_GUARD_SIZE-extra_border) )
287+
coord.x = isaac_float(local_size.value.x+ISAAC_GUARD_SIZE-extra_border)-FLT_MIN;
288+
if ( coord.y >= isaac_float(local_size.value.y+ISAAC_GUARD_SIZE-extra_border) )
289+
coord.y = isaac_float(local_size.value.y+ISAAC_GUARD_SIZE-extra_border)-FLT_MIN;
290+
if ( coord.z >= isaac_float(local_size.value.z+ISAAC_GUARD_SIZE-extra_border) )
291+
coord.z = isaac_float(local_size.value.z+ISAAC_GUARD_SIZE-extra_border)-FLT_MIN;
273292
}
274293

275294
template <
@@ -330,11 +349,15 @@ struct merge_source_iterator
330349
isaac_float3 left = {-1, 0, 0};
331350
left = left + pos;
332351
if (!TSource::has_guard && TSource::persistent)
333-
check_coord( left, local_size);
352+
check_coord<TInterpolation>( left, local_size);
353+
else
354+
check_coord_with_guard<TInterpolation>( left, local_size);
334355
isaac_float3 right = { 1, 0, 0};
335356
right = right + pos;
336357
if (!TSource::has_guard && TSource::persistent)
337-
check_coord( right, local_size );
358+
check_coord<TInterpolation>( right, local_size );
359+
else
360+
check_coord_with_guard<TInterpolation>( right, local_size);
338361
isaac_float d1;
339362
if (TInterpolation)
340363
d1 = right.x - left.x;
@@ -344,11 +367,15 @@ struct merge_source_iterator
344367
isaac_float3 up = { 0,-1, 0};
345368
up = up + pos;
346369
if (!TSource::has_guard && TSource::persistent)
347-
check_coord( up, local_size );
370+
check_coord<TInterpolation>( up, local_size );
371+
else
372+
check_coord_with_guard<TInterpolation>( up, local_size);
348373
isaac_float3 down = { 0, 1, 0};
349374
down = down + pos;
350375
if (!TSource::has_guard && TSource::persistent)
351-
check_coord( down, local_size );
376+
check_coord<TInterpolation>( down, local_size );
377+
else
378+
check_coord_with_guard<TInterpolation>( down, local_size);
352379
isaac_float d2;
353380
if (TInterpolation)
354381
d2 = down.y - up.y;
@@ -358,11 +385,15 @@ struct merge_source_iterator
358385
isaac_float3 front = { 0, 0,-1};
359386
front = front + pos;
360387
if (!TSource::has_guard && TSource::persistent)
361-
check_coord( front, local_size );
388+
check_coord<TInterpolation>( front, local_size );
389+
else
390+
check_coord_with_guard<TInterpolation>( front, local_size);
362391
isaac_float3 back = { 0, 0, 1};
363392
back = back + pos;
364393
if (!TSource::has_guard && TSource::persistent)
365-
check_coord( back, local_size );
394+
check_coord<TInterpolation>( back, local_size );
395+
else
396+
check_coord_with_guard<TInterpolation>( back, local_size);
366397
isaac_float d3;
367398
if (TInterpolation)
368399
d3 = back.z - front.z;

0 commit comments

Comments
 (0)