static inline void gt_readjoiner_assembly_show_current_space(const char *label)
{
  GtUword m, f;
  if (gt_ma_bookkeeping_enabled())
  {
    m = gt_ma_get_space_current();
    f = gt_fa_get_space_current();
    gt_log_log("used space %s: %.2f MB (ma: %.2f MB; fa: %.2f MB)",
        label == NULL ? "" : label, GT_MEGABYTES(m + f), GT_MEGABYTES(m),
        GT_MEGABYTES(f));
  }
}
Example #2
0
void gt_firstcodes_spacelog_add(GtFirstcodesspacelog *fcsl,
                                int line,
                                const char *filename,
                                bool add,
                                const char *title,
                                bool work,
                                size_t size)
{
  GtFirstcodespacelogentry *entry;
  size_t logspace;

  if (add)
  {
    entry = gt_spacelog_find(fcsl,title);
    if (entry != NULL)
    {
      if (entry->size != 0)
      {
        fprintf(stderr,"existing entry for title \"%s\""
                       "(from file %s, line %d) "
                       "in spacelog entries must have size 0\n",
                       title,filename,line);
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      gt_spacelog_updateaddentry(entry,filename,line,title,size,work);
    } else
    {
      gt_spacelog_addentry(fcsl,filename,line,title,size,work);
    }
    if (work)
    {
      fcsl->workspace += size;
    } else
    {
      fcsl->splitspace += size;
    }
    gt_firstcodes_updatemax(fcsl);
  } else
  {
    entry = gt_spacelog_find(fcsl,title);
    if (entry == NULL)
    {
      fprintf(stderr,"cannot find title \"%s\" (from file %s, line %d) "
                     "in spacelog entries\n",title,filename,line);
      (void) gt_firstcodes_spacelog_showentries(stderr,fcsl);
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
    if ((entry->work && !work) || (!entry->work && work))
    {
      fprintf(stderr,"for title \"%s\" (from file %s, line %d) "
                     "in spacelog entries: inconsistent work/splitassignment\n",
               title,filename,line);
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
    if (work)
    {
      if (entry->size > fcsl->workspace)
      {
        gt_firstcodes_subtract_error(title, filename, line, entry->size, true,
                                     fcsl->workspace);
        (void) gt_firstcodes_spacelog_showentries(stderr,fcsl);
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      fcsl->workspace -= entry->size;
    } else
    {
      if (entry->size > fcsl->splitspace)
      {
        gt_firstcodes_subtract_error(title, filename, line, entry->size, false,
                                     fcsl->splitspace);
        (void) gt_firstcodes_spacelog_showentries(stderr,fcsl);
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      fcsl->splitspace -= entry->size;
    }
    if (size > 0)
    {
      gt_spacelog_updateaddentry(entry,filename,line,title,size,work);
      if (work)
      {
        fcsl->workspace += size;
      } else
      {
        fcsl->splitspace += size;
      }
      gt_firstcodes_updatemax(fcsl);
      if (size > entry->size)
      {
        add = true;
        size -= entry->size;
      } else
      {
        size = entry->size - size;
      }
    } else
    {
      size = entry->size;
      entry->size = 0;
    }
  }
  logspace = fcsl->workspace+fcsl->splitspace;
  gt_log_log(
#ifdef SKDEBUG
             "file %s, line %d: "
#endif
             "%s %s= %.2f, %s, w=%.2f, s=%.2f, sum=%.2f MB",
#ifdef SKDEBUG
             filename,
             line,
#endif
             work ? "w" : "s",
             add ? "+" : "-",
             GT_MEGABYTES(size),
             title,
             GT_MEGABYTES(fcsl->workspace),
             GT_MEGABYTES(fcsl->splitspace),
             GT_MEGABYTES(logspace));
#ifdef SKDEBUG
  if (gt_ma_bookkeeping_enabled())
  {
    unsigned long realspace = gt_ma_get_space_current() +
                              gt_fa_get_space_current();
    gt_log_log("current space usage %.2f MB (%.2f+%.2f)",
                                GT_MEGABYTES(realspace),
                                GT_MEGABYTES(gt_ma_get_space_current()),
                                GT_MEGABYTES(gt_fa_get_space_current()));
    if (fcsl->calc_difference)
    {
      double percent_difference;

      if ((unsigned long) logspace > realspace)
      {
        fprintf(stderr,"overestimating logspace\n");
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      if (realspace >= 1000000UL)
      {
        /*
        printf("realspace=%lu,logspace=%lu\n",realspace,
                                              (unsigned long) logspace);
        */
        percent_difference = 100.0 * (double) (realspace - logspace)/realspace;
        if (gt_double_larger_double(percent_difference,3.0))
        {
          fprintf(stderr,"space difference of %.2f%% is too large\n",
                       percent_difference);
          exit(GT_EXIT_PROGRAMMING_ERROR);
        }
        if (gt_double_smaller_double(fcsl->max_percent_difference,
                                     percent_difference))
        {
          fcsl->max_percent_difference = percent_difference;
        }
      }
    }
  }
#endif
}
Example #3
0
void gt_firstcodes_spacelog_start_diff(GtFirstcodesspacelog *fcsl)
{
  fcsl->calc_difference = gt_ma_bookkeeping_enabled();
}
Example #4
0
static int gt_encseq2spm_arguments_check(int rest_argc,
        void *tool_arguments,
        GtError *err)
{
    GtEncseq2spmArguments *arguments = tool_arguments;
    bool haserr = false;

    gt_error_check(err);
    if (rest_argc != 0)
    {
        gt_error_set(err,"unnecessary arguments");
        haserr = true;
    }
    if (!haserr && gt_str_length(arguments->spmspec) > 0)
    {
        const char *spmspecstring = gt_str_get(arguments->spmspec);
        if (strcmp(spmspecstring,"show") == 0)
        {
            arguments->outputspms = true;
        } else
        {
            if (strcmp(spmspecstring,"count") == 0)
            {
                arguments->countspms = true;
            } else
            {
                gt_error_set(err,"illegal argument \"%s\" to option -spm",
                             spmspecstring);
                haserr = true;
            }
        }
    }
    if (!haserr && gt_option_is_set(arguments->refoptionmemlimit))
    {
        if (gt_option_parse_spacespec(&arguments->maximumspace,
                                      "memlimit",
                                      arguments->memlimitarg,
                                      err) != 0)
        {
            haserr = true;
        }
        if (!haserr && !gt_ma_bookkeeping_enabled()) {
            gt_error_set(err, "option '-memlimit' requires "
                         "GT_MEM_BOOKKEEPING=on");
            haserr = true;
        }
    }
    if (!haserr && gt_option_is_set(arguments->refoptionphase2extra))
    {
        if (gt_option_parse_spacespec(&arguments->phase2extra,
                                      "phase2extra",
                                      arguments->phase2extraarg,
                                      err) != 0)
        {
            haserr = true;
        }
    }
#ifdef GT_THREADS_ENABLED
    if (!haserr) {
        if (gt_jobs > 1 && gt_ma_bookkeeping_enabled()) {
            gt_error_set(err, "gt option '-j' and GT_MEM_BOOKKEEPING=on "
                         "are incompatible");
            haserr = true;
        }
    }
#endif
    return haserr ? -1 : 0;
}