Skip to content

Commit

Permalink
allow horizontal APIs being called for all-masked points (#68)
Browse files Browse the repository at this point in the history
* use catalog index to access catalog%xx_sources

* correct masked value of conserved quantities (no used, just for documentation)

* allow horizontal APIs being called for all-masked points
  • Loading branch information
jornbr authored Apr 22, 2024
1 parent 4c31b93 commit 11f3eee
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 72 deletions.
27 changes: 16 additions & 11 deletions include/fabm_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,33 +495,38 @@

#ifdef _HAS_MASK_
# define _PACK_GLOBAL_(in,out,i,cache) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_SLICE_PLUS_1_(i) = in _INDEX_GLOBAL_INTERIOR_(cache%ipack(_I_));_LOOP_END_
# define _PACK_GLOBAL_PLUS_1_(in,i,out,j,cache) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_INTERIOR_PLUS_1_(cache%ipack(_I_),i);_LOOP_END_
# define _UNPACK_(in,i,out,cache,missing) _DO_CONCURRENT_(_I_,_START_,_STOP_);out(_I_) = in(cache%iunpack(_I_),i);end do
# define _UNPACK_TO_PLUS_1_(in,i,out,j,cache,missing) _DO_CONCURRENT_(_I_,_START_,_STOP_);out(_I_,j) = in(cache%iunpack(_I_),i);end do
# define _UNPACK_AND_ADD_TO_PLUS_1_(in,i,out,j,cache) _DO_CONCURRENT_(_I_,_START_,_STOP_);out(_I_,j) = out(_I_,j) + in(cache%iunpack(_I_),i);end do
# define _UNPACK_TO_GLOBAL_(in,i,out,cache,missing) _DO_CONCURRENT_(_I_,_START_,_STOP_);out _INDEX_GLOBAL_INTERIOR_(_I_) = in(cache%iunpack(_I_),i);end do
# define _UNPACK_TO_GLOBAL_PLUS_1_(in,i,out,j,cache,missing) _DO_CONCURRENT_(_I_,_START_,_STOP_);out _INDEX_GLOBAL_INTERIOR_PLUS_1_(_I_,j) = in(cache%iunpack(_I_),i);end do
#else
# define _PACK_GLOBAL_(in,out,i,cache) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_SLICE_PLUS_1_(i) = in _INDEX_GLOBAL_INTERIOR_(_START_+_I_-1);_LOOP_END_
# define _PACK_GLOBAL_PLUS_1_(in,i,out,j,cache) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_INTERIOR_PLUS_1_(_START_+_I_-1,i);_LOOP_END_
# define _UNPACK_(in,i,out,cache,missing) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_EXT_SLICE_ = in _INDEX_SLICE_PLUS_1_(i);_LOOP_END_
# define _UNPACK_TO_PLUS_1_(in,i,out,j,cache,missing) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_EXT_SLICE_PLUS_1_(j) = in _INDEX_SLICE_PLUS_1_(i);_LOOP_END_
# define _UNPACK_AND_ADD_TO_PLUS_1_(in,i,out,j,cache) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_EXT_SLICE_PLUS_1_(j) = out _INDEX_EXT_SLICE_PLUS_1_(j) + in _INDEX_SLICE_PLUS_1_(i);_LOOP_END_
# define _UNPACK_TO_GLOBAL_(in,i,out,cache,missing) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_GLOBAL_INTERIOR_(_START_+_I_-1) = in _INDEX_SLICE_PLUS_1_(i);_LOOP_END_
# define _UNPACK_TO_GLOBAL_PLUS_1_(in,i,out,j,cache,missing) _CONCURRENT_LOOP_BEGIN_EX_(cache);out _INDEX_GLOBAL_INTERIOR_PLUS_1_(_START_+_I_-1,j) = in _INDEX_SLICE_PLUS_1_(i);_LOOP_END_
#endif

#if defined(_HORIZONTAL_IS_VECTORIZED_)&&defined(_HAS_MASK_)
# define _HORIZONTAL_PACK_GLOBAL_(in,out,j,cache) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_HORIZONTAL_(cache%ipack(_J_));_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_PACK_GLOBAL_PLUS_1_(in,i,out,j,cache) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_HORIZONTAL_PLUS_1_(cache%ipack(_J_),i);_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_UNPACK_(in,i,out,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out(_J_) = in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_TO_PLUS_1_(in,i,out,j,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out(_J_,j) = in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_AND_ADD_TO_PLUS_1_(in,i,out,j,cache) _DO_CONCURRENT_(_J_,_START_,_STOP_);out(_J_,j) = out(_J_,j) + in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_TO_GLOBAL_(in,i,out,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out _INDEX_GLOBAL_HORIZONTAL_(_J_) = in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_TO_GLOBAL_PLUS_1_(in,i,out,j,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out _INDEX_GLOBAL_HORIZONTAL_PLUS_1_(_J_,j) = in(cache%iunpack(_J_),i);end do
#ifdef _HAS_MASK_
# ifdef _HORIZONTAL_IS_VECTORIZED_
# define _HORIZONTAL_PACK_GLOBAL_(in,out,j,cache) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_HORIZONTAL_(cache%ipack(_J_));_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_UNPACK_(in,i,out,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out(_J_) = in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_TO_PLUS_1_(in,i,out,j,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out(_J_,j) = in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_AND_ADD_TO_PLUS_1_(in,i,out,j,cache) _DO_CONCURRENT_(_J_,_START_,_STOP_);out(_J_,j) = out(_J_,j) + in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_TO_GLOBAL_(in,i,out,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out _INDEX_GLOBAL_HORIZONTAL_(_J_) = in(cache%iunpack(_J_),i);end do
# define _HORIZONTAL_UNPACK_TO_GLOBAL_PLUS_1_(in,i,out,j,cache,missing) _DO_CONCURRENT_(_J_,_START_,_STOP_);out _INDEX_GLOBAL_HORIZONTAL_PLUS_1_(_J_,j) = in(cache%iunpack(_J_),i);end do
# else
# define _HORIZONTAL_PACK_GLOBAL_(in,out,j,cache) out _INDEX_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_HORIZONTAL_(_START_+_J_-1)
# define _HORIZONTAL_UNPACK_(in,i,out,cache,missing) if (cache%n == 0) then;out _INDEX_EXT_HORIZONTAL_SLICE_ = missing;else;out _INDEX_EXT_HORIZONTAL_SLICE_ = in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);end if
# define _HORIZONTAL_UNPACK_TO_PLUS_1_(in,i,out,j,cache,missing) if (cache%n == 0) then;out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) = missing;else;out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);end if
# define _HORIZONTAL_UNPACK_AND_ADD_TO_PLUS_1_(in,i,out,j,cache) if (cache%n /= 0) then;out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) = out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) + in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);end if
# define _HORIZONTAL_UNPACK_TO_GLOBAL_(in,i,out,cache,missing) if (cache%n == 0) then;out _INDEX_GLOBAL_HORIZONTAL_(_START_+_J_-1) = missing;else;out _INDEX_GLOBAL_HORIZONTAL_(_START_+_J_-1) = in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);end if
# define _HORIZONTAL_UNPACK_TO_GLOBAL_PLUS_1_(in,i,out,j,cache,missing) if (cache%n == 0) then;out _INDEX_GLOBAL_HORIZONTAL_PLUS_1_(_START_+_J_-1,j) = missing;else;out _INDEX_GLOBAL_HORIZONTAL_PLUS_1_(_START_+_J_-1,j) = in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);end if
# endif
#else
# define _HORIZONTAL_PACK_GLOBAL_(in,out,j,cache) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_HORIZONTAL_(_START_+_J_-1);_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_PACK_GLOBAL_PLUS_1_(in,i,out,j,cache) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_GLOBAL_HORIZONTAL_PLUS_1_(_START_+_J_-1,i);_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_UNPACK_(in,i,out,cache,missing) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_EXT_HORIZONTAL_SLICE_ = in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_UNPACK_TO_PLUS_1_(in,i,out,j,cache,missing) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) = in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);_HORIZONTAL_LOOP_END_
# define _HORIZONTAL_UNPACK_AND_ADD_TO_PLUS_1_(in,i,out,j,cache) _CONCURRENT_HORIZONTAL_LOOP_BEGIN_EX_(cache);out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) = out _INDEX_EXT_HORIZONTAL_SLICE_PLUS_1_(j) + in _INDEX_HORIZONTAL_SLICE_PLUS_1_(i);_HORIZONTAL_LOOP_END_
Expand Down
Loading

0 comments on commit 11f3eee

Please sign in to comment.