lanl / lanl/MATAR

making asserts output array label

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
35
Forks
17
Avg merge
3m
Merged PRs (30d)
1

Description

added the following macro on line 111 of kokkos_types.h:

#ifndef NDEBUG
#define MATAR_CHECK_BOUNDS(i, dim, view)
if ((i) >= (dim)) {
printf("\n[MATAR BOUNDS ERROR]\n");
printf(" Location: %s:%d\n", FILE, LINE);
printf(" Array Label: %s\n", this_array_.label().c_str());
printf(" Attempted access at index [%zu], but dimension is %zu\n\n", (size_t)(i), (size_t)(dim));
assert(false);
}
#else
// In Release mode, this macro does absolutely nothing
#define MATAR_CHECK_BOUNDS(i, dim, view) ((void)0)
#endif

and then changed line 3670 (in the current repo numbering) to:

template <typename T, typename Layout, typename ExecSpace, typename MemoryTraits>
KOKKOS_INLINE_FUNCTION
T& CArrayKokkos<T,Layout,ExecSpace,MemoryTraits>::operator()(size_t i) const {
// This expands to the full check in Debug, and disappears in Release
MATAR_CHECK_BOUNDS(i, dims_[0], this_array_);

return this_array_(i);

}

and forced an out of bounds memory call for a CArrayKokkos 1D array to get the following output:
[MATAR BOUNDS ERROR]
Location: <path_to>kokkos_types.h:3687
Array Label: testing
Attempted access at index [5], but dimension is 4

Assertion failed: (false), function operator(), file kokkos_types.h, line 3687.

can be implemented for other data types to know which array had a bad memory access
the Location part could probably be deleted as it was intended to go to the executed code location but went to the header file instead

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in kokkos_types.h at the MATAR_CHECK_BOUNDS macro near line 111 and the CArrayKokkos operator() implementation near line 3670. Review the other data types that perform bounds checks and determine where the array label can be reported. Done means relevant debug-mode out-of-bounds assertions identify the affected array, while release-mode behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.