Skip to content

Commit

Permalink
Allow to idle-wait (LIBXSMM_DUMP_FILE=seconds), which allows keeping …
Browse files Browse the repository at this point in the history
…process specific files until interrupt (CTRL-C, etc).
  • Loading branch information
hfp committed May 31, 2021
1 parent 6f270d2 commit c44660e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/libxsmm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,16 +637,31 @@ LIBXSMM_API_INTERN void internal_dump(FILE* ostream, int urgent)
/* determine whether this instance is unique or not */
if (NULL != env_dump_files && '\0' != *env_dump_files && 0 == urgent) { /* dump per-node info */
const char* filename = strtok(env_dump_files, INTERNAL_DELIMS);
char buffer[1024];
for (; NULL != filename; filename = strtok(NULL, INTERNAL_DELIMS)) {
FILE* file = fopen(filename, "r");
if (NULL == file) {
char buffer[1024];
const char *const pid = strstr(filename, "PID");
if (NULL != pid) { /* PID-keyword is present */
int n = (int)(pid - filename);
n = LIBXSMM_SNPRINTF(buffer, sizeof(buffer), "%.*s%u%s", n, filename, libxsmm_get_pid(), filename + n + 3);
if (0 < n && (int)sizeof(buffer) > n) file = fopen(buffer, "r");
if (NULL != file) buffer[0] = '\0';
else { /* parse keywords */
const int seconds = atoi(filename);
if (0 == seconds) {
const char *const pid = strstr(filename, "PID");
if (NULL != pid) { /* PID-keyword is present */
int n = (int)(pid - filename);
n = LIBXSMM_SNPRINTF(buffer, sizeof(buffer), "%.*s%u%s", n, filename, libxsmm_get_pid(), filename + n + 3);
if (0 < n && (int)sizeof(buffer) > n) {
file = fopen(buffer, "r");
filename = buffer;
}
}
}
else if (0 < seconds) {
#if defined(_WIN32)
Sleep((DWORD)(1000 * seconds));
#else
LIBXSMM_EXPECT(EXIT_SUCCESS, sleep(seconds));
#endif
}
else for(;;) LIBXSMM_SYNC_YIELD;
}
if (NULL != file) {
int c = fgetc(file);
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
master-1.16.1-1500
master-1.16.1-1501

0 comments on commit c44660e

Please sign in to comment.