Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special case for sparse IndexSpace overlap test #463

Closed
mpokorny opened this issue Dec 21, 2018 · 10 comments
Closed

Special case for sparse IndexSpace overlap test #463

mpokorny opened this issue Dec 21, 2018 · 10 comments
Assignees

Comments

@mpokorny
Copy link
Contributor

The implementation of Realm::IndexSpace<N,T>::overlaps_approx()

template <int N, typename T>
inline bool IndexSpace<N,T>::overlaps_approx(const IndexSpace<N,T>& other) const
{
if(dense()) {
if(other.dense()) {
// just test bounding boxes
return bounds.overlaps(other.bounds);
} else {
// have the other guy test against our bounding box
return other.contains_any_approx(bounds);
}
} else {
if(other.dense()) {
return contains_any_approx(other.bounds);
} else {
// nasty case - both sparse
assert(0);
return true;
}
}
}

bails out when both index spaces are sparse. However, I was wondering whether there isn't a special case that is actually fairly easy to resolve: that is, when the sparsity maps are identical and the bounds overlap. Something like
if (sparsity == other.sparsity) return bounds.overlaps(other.bounds);
before the assert(0);.
I'm uncertain about the correctness in general, but it seems reasonable based on my limited understanding. Making this change in my local repo allowed me to work around the otherwise missing implementation, and provided the correct result in my application.

@streichler
Copy link
Contributor

Yes, that'd be correct. Apart from a minor code reordering tweak, I'll submit a fix for that shortly. Thanks for the suggestion!

@streichler streichler self-assigned this Dec 21, 2018
@mpokorny
Copy link
Contributor Author

Another test when both IndexSpaces are sparse?
if (!bounds.overlaps(other.bounds)) return false;
Perhaps that's always valid and could be done up front, although I'm not sure of the relative performance impacts of applying tests in the various branches.

@mpokorny
Copy link
Contributor Author

Another question: if I understand the purpose (doubtful!) of Realm::IndexSpace<N,T>::overlaps_approx(), if it's the case that when the return value is false then necessarily the IndexSpaces don't overlap, wouldn't it be correct to return the value of bounds.overlaps(other.bounds) whenever both IndexSpaces are sparse? Maybe not efficient for the runtime, but at least correct. Sorry to keep bugging you, but my code continues to trip over this section of the Legion code, even with the changes proposed so far.

@streichler
Copy link
Contributor

Yes, overlaps_approx must return true if there is overlap, but it's also allowed to return true in non-overlap cases. The goal is that this imprecision will only happen when it's holes in a sparsity mask that avoid the overlap. (Technically it'd be legal to simply return true in all cases, but that wouldn't be very useful.)

Can you describe the use case that is causing you to call this method?

@mpokorny
Copy link
Contributor Author

mpokorny commented Dec 21, 2018 via email

@streichler
Copy link
Contributor

Can you paste the backtrace here?

@mpokorny
Copy link
Contributor Author

#0 0x0000003d1da32495 in raise () from /lib64/libc.so.6
#1 0x0000003d1da33c75 in abort () from /lib64/libc.so.6
#2 0x0000003d1da2b60e in __assert_fail_base () from /lib64/libc.so.6
#3 0x0000003d1da2b6d0 in __assert_fail () from /lib64/libc.so.6
#4 0x0000000002217555 in Realm::IndexSpace<3, long long>::overlaps_approx (this=0x7fb41d013c80, other=...)
at legion/runtime/realm/indexspace.inl:1195
#5 0x00000000022187f0 in Realm::OverlapTester<3, long long>::test_overlap (this=0x7fb400012aa0, space=...,
overlaps=std::set with 1 element = {...}, approx=true)
at legion/runtime/realm/deppart/partitions.cc:279
#6 0x000000000237120f in Realm::ImageOperation<3, long long, 3, long long>::set_overlap_tester (this=0x7fb41cb029c0,
tester=0x7fb400012aa0) at legion/runtime/realm/deppart/image.cc:574
#7 0x0000000002218a9e in Realm::ComputeOverlapMicroOp<3, long long>::execute (this=0x7fb40000f770)
at legion/runtime/realm/deppart/partitions.cc:499
#8 0x0000000002200dec in Realm::PartitioningMicroOp::finish_dispatch (this=0x7fb40000f770, op=0x7fb41cb029c0, inline_ok=true)
at legion/runtime/realm/deppart/partitions.cc:429
#9 0x0000000002218c13 in Realm::ComputeOverlapMicroOp<3, long long>::dispatch (this=0x7fb40000f770, op=0x7fb41cb029c0,
inline_ok=true) at legion/runtime/realm/deppart/partitions.cc:524
#10 0x0000000002370939 in Realm::ImageOperation<3, long long, 3, long long>::execute (this=0x7fb41cb029c0)
at legion/runtime/realm/deppart/image.cc:523
#11 0x0000000002201d27 in Realm::PartitioningOpQueue::worker_thread_loop (this=0x318d430)
at legion/runtime/realm/deppart/partitions.cc:874
#12 0x000000000221a7d2 in Realm::Thread::thread_entry_wrapper<Realm::PartitioningOpQueue, &Realm::PartitioningOpQueue::worker_thread_loop> (obj=0x318d430) at legion/runtime/realm/threads.inl:131
#13 0x00000000021cc126 in Realm::KernelThread::pthread_entry (data=0x318d560)
at legion/runtime/realm/threads.cc:700
#14 0x0000003d1e207aa1 in start_thread () from /lib64/libpthread.so.0
#15 0x0000003d1dae8bcd in clone () from /lib64/libc.so.6

@streichler
Copy link
Contributor

Ok, I've reproduced the error with a small test case. I'll work on a fix tonight.

@streichler
Copy link
Contributor

@mpokorny can you try this again in the master branch? Commit fcbfb04 hopefully cleans this up.

@mpokorny
Copy link
Contributor Author

Looks good, all test cases for my application now pass. Thanks, @streichler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants