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

Introduce Log-levels in DART (2) #316

Merged
merged 10 commits into from
Mar 9, 2017
Merged

Introduce Log-levels in DART (2) #316

merged 10 commits into from
Mar 9, 2017

Conversation

devreal
Copy link
Member

@devreal devreal commented Mar 7, 2017

Giving this another shot (refer to #247 for previous discussion). This PR adds the following on top of it:

  1. Resolve DART_LOG* functions to a single function call (printf-style argument checking is preserved). This yields some significant savings in binary size (151kB vs 240kB for libdart-mpi.a with debug output enabled)
  2. Ensure mutual exclusion between threads to avoid interleaved log output.
  3. A bunch of fixes to format specifier.
  4. Do not silently drop overlong log messages but print truncate line. It's up to the developer to fix them.

Related to #109

dart_global_unit_t unit_id;
dart_myid(&unit_id);
// avoid inter-thread log interference
dart_mutex_lock(&logmutex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acquiring a mutex for every log message has significant overhead, but more important, it also leads to implicit synchronization. This is only needed for multi-threaded logging, right? In this case, I suggest to wrap the dart_mutex_* calls in #ifdef DART_ENABLE_THREADSUPPORT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually handled in dart_mutex_*, which resolves to an empty static inline call if DART_ENABLE_THREADSUPPORT is not defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I assumed, but dart_mutex_* is part of the DART interface, the "empty" implementation is just in DART-MPI. So any other implementation of dart_mutex_*, e.g. in DART-SHMEM or DART-GASPI would depend on this assumption, too. (Stichwort Schichtenbruch).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dart_mutex_* is actually part of the dart_base interface, not the public DART interface. Thus, it should be safe to use in other modules (shmem, tasking, ...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, but that adds to my point. That is: we need the #ifdef guards in both places, the logging functions and the implementation of dart_mutex_*.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't. Both logging.h and mutex.h are part of the dart-base interface. logging.c is compiled as part of dart-base. The modules that use the DART_LOG* macros will never even see the dart_mutex_* calls in dart__logging__message. So if there is no support for for threads, logging.c will be compiled with an empty version to dart_mutex_* and anything linking against dart_base will call that compiled function. Of course, if you decide to build dart_base and dart_shmem with different threading settings other things are likely to break...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see. But shouldn't dart_mutex_* be renamed to dart_base_mutex_* then? Not sure how I did this with the locality stuff in dart/base, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I used dart__base__locality* for the common functions in dart/base. We should do the same for dart_mutex*.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now dart__base__mutex* (although I am not a big fan of the double underscore namespace thingy...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither, but it's all we got. Life is hard without colons.

"[ %*d %.5s ] [ %*d ] %-*s:%-*d %.3s DART: %s\n",
DASH__DART_LOGGING__UNIT__WIDTH, unit_id.id,
loglevel_names[level],
DASH__DART_LOGGING__PROC__WIDTH, pid,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These macros could be renamed to DART_LOGGING__PROC_WIDTH etc., I used the prefix DASH__ back then but it's pretty stupid to write DASH__DART... in hindsight. Spelled out, it's DASH DASH Runtime ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also, there is no need to have it in the header file anymore.

@fuchsto fuchsto merged commit fe195c0 into development Mar 9, 2017
@fuchsto fuchsto deleted the feat-dart-loglevel branch March 9, 2017 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants