chapel-lang/chapel — pull request #1056 by gbtitus (2014-12-20 14:58:23+00:00)
Title: Simplify some locale model interactions with the runtime.

These are minor simplifications based on what really gets used, and not
used, for locale models that do (numa) and don't (flat) have sublocales.
In the runtime I've removed CHPL_LOCALE_MODEL_NUM_SUBLOCALES, which was
used to #ifdef out runtime code having to do with sublocales when we
were using a locale model that didn't have them. But it turns out much
of that code isn't called in the first place except with a locale model
that DOES have sublocales, and for the rest the performance savings
(which are tiny, probably unmeasurable) don't justify the impact to code
readability.

Elsewhere, I did some tidying up in the locale model code and some numa
specific tests, as preparation for future optimizations which will
short-circuit some places where we currently call the runtime for
sublocale-related information.

When we started down this development path we weren't sure what we would need and
not need in the various cases. This clean-up is taking advantage of greater knowledge
now, to remove what has turned out not to be needed.

The specific file changes are as follows.

runtime/src/tasks/fifo/tasks-fifo.c
runtime/src/tasks/massivethreads/tasks-massivethreads.c
Remove the dependence on CHPL_LOCALE_MODEL_HAS_SUBLOCALES and just
return 0 (zero) from chpl_task_getNumSublocales().

third-party/qthread/qthread-1.10/src/interfaces/chapel/tasks-qthreads.c
Remove the dependence on CHPL_LOCALE_MODEL_HAS_SUBLOCALES and just
return qthread_num_shepherds() from chpl_task_getNumSublocales().

third-party/qthread/qthread-1.10/src/interfaces/chapel/tasks-qthreads.h
Remove the dependences on CHPL_LOCALE_MODEL_HAS_SUBLOCALES. Always
store a sublocale index in task private data, even when we don't need
it, such as when we're using the flat locale model. The unmeasurably
small performance gain isn't worth the code messiness. And in these
three functions, we didn't need CHPL_LOCALE_MODEL_HAS_SUBLOCALES
anyway, because they're only called when we're using the numa locale
model:
- Always return qthread_shep() for chpl_task_getSubloc().
- Always set the sublocale in chpl_task_setSubloc().
- Always return the sublocale in chpl_task_getRequestedSubloc().

runtime/include/localeModels/flat/chpl-locale-model.h
Remove the definition of CHPL_LOCALE_MODEL_HAS_SUBLOCALES (now no
longer used) and a superfluous comment.

modules/internal/localeModels/flat/LocaleModel.chpl
modules/internal/localeModels/numa/LocaleModel.chpl
Remove the mention of CHPL_LOCALE_MODEL_NUM_SUBLOCALES, which no
longer exists.
Hoist the extern definitions for c_sublocid_none and c_sublocid_any,
instead of defining them multiple times, near where they're used.
For numa, add chpl_getSubloc() to wrap chpl_task_getSubloc(). So far
this is just a simple wrapper, but in the future I expect it to avoid
calling the tasking layer when we know what the result will be. For
flat, there are no calls to chpl_task_getSubloc(), so no need for this
wrapper.

modules/internal/ChapelRange.chpl
modules/internal/DefaultRectangular.chpl
Call chpl_getSubloc() instead of chpl_task_getSubloc(). Note that
these calls only occur under a param-based if-stmt that checks whether
the current locale has sublocales.

test/localeModels/numa/basics/checkSubloc.chpl
test/localeModels/numa/dataParallel/forall.chpl
Call chpl_getSUbloc() instead of chpl_task_getSubloc(). Note that
these tests are only run for the numa locale model.