<commit_before>#include <stdio.h>
#include <stdlib.h>
#include "chplcomm.h"
#include "chplexit.h"
#include "chplmem.h"
#include "chplrt.h"
#include "gdb.h"

#undef exit

static void _chpl_exit_common(int status, int all) {
  fflush(stdout);
  fflush(stderr);
  if (status != 0) {
    gdbShouldBreakHere();
  }
  if (all) {
    exitChplThreads();         // tear down the threads
  }
  if (all) {
    _chpl_comm_barrier("_chpl_comm_exit_all");
    _chpl_comm_exit_all(status);
  } else {
    _chpl_comm_exit_any(status);
  }
  exit(status);
}


void _chpl_exit_all(int status) {
  printFinalMemStat(0, 0);   // print the final memory statistics
  _chpl_exit_common(status, 1);
}


void _chpl_exit_any(int status) {
  _chpl_exit_common(status, 0);
}
<commit_msg>Move a call to exitChplThreads() to after the final barrier<commit_after>#include <stdio.h>
#include <stdlib.h>
#include "chplcomm.h"
#include "chplexit.h"
#include "chplmem.h"
#include "chplrt.h"
#include "gdb.h"

#undef exit

static void _chpl_exit_common(int status, int all) {
  fflush(stdout);
  fflush(stderr);
  if (status != 0) {
    gdbShouldBreakHere();
  }
  if (all) {
    _chpl_comm_barrier("_chpl_comm_exit_all");
    exitChplThreads();         // tear down the threads
    _chpl_comm_exit_all(status);
  } else {
    _chpl_comm_exit_any(status);
  }
  exit(status);
}


void _chpl_exit_all(int status) {
  printFinalMemStat(0, 0);   // print the final memory statistics
  _chpl_exit_common(status, 1);
}


void _chpl_exit_any(int status) {
  _chpl_exit_common(status, 0);
}

{'fraction_non_alphanumeric': 0.131697869593286, 'fraction_numerical': 0.006455777921239509, 'mean_word_length': 4.166666666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3062973', 'n_tokens_mistral': 635, 'n_tokens_neox': 622, 'n_words': 125}