mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 15:09:31 +03:00
remove all floating point types and arithmetic
This commit is contained in:
parent
2749612c5f
commit
3d0a1e249f
3 changed files with 20 additions and 16 deletions
|
@ -25,7 +25,6 @@ with on-demand coalescing.
|
||||||
|
|
||||||
// os.c
|
// os.c
|
||||||
void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool* large, mi_os_tld_t* tld);
|
void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool* large, mi_os_tld_t* tld);
|
||||||
//int _mi_os_alloc_huge_os_pages(size_t pages, double max_secs, void** pstart, size_t* pages_reserved, size_t* psize) mi_attr_noexcept;
|
|
||||||
void _mi_os_free(void* p, size_t size, mi_stats_t* stats);
|
void _mi_os_free(void* p, size_t size, mi_stats_t* stats);
|
||||||
|
|
||||||
void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_secs, size_t* pages_reserved, size_t* psize);
|
void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_secs, size_t* pages_reserved, size_t* psize);
|
||||||
|
|
|
@ -434,7 +434,6 @@ static void mi_process_load(void) {
|
||||||
|
|
||||||
if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
|
if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
|
||||||
size_t pages = mi_option_get(mi_option_reserve_huge_os_pages);
|
size_t pages = mi_option_get(mi_option_reserve_huge_os_pages);
|
||||||
// double max_secs = (double)pages / 2.0; // 0.5s per page (1GiB)
|
|
||||||
mi_reserve_huge_os_pages_interleave(pages);
|
mi_reserve_huge_os_pages_interleave(pages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
src/stats.c
32
src/stats.c
|
@ -130,19 +130,23 @@ static void mi_printf_amount(int64_t n, int64_t unit, mi_output_fun* out, const
|
||||||
char buf[32];
|
char buf[32];
|
||||||
int len = 32;
|
int len = 32;
|
||||||
const char* suffix = (unit <= 0 ? " " : "b");
|
const char* suffix = (unit <= 0 ? " " : "b");
|
||||||
double base = (unit == 0 ? 1000.0 : 1024.0);
|
const int64_t base = (unit == 0 ? 1000 : 1024);
|
||||||
if (unit>0) n *= unit;
|
if (unit>0) n *= unit;
|
||||||
|
|
||||||
double pos = (double)(n < 0 ? -n : n);
|
const int64_t pos = (n < 0 ? -n : n);
|
||||||
if (pos < base)
|
if (pos < base) {
|
||||||
snprintf(buf,len, "%d %s ", (int)n, suffix);
|
snprintf(buf, len, "%d %s ", (int)n, suffix);
|
||||||
else if (pos < base*base)
|
}
|
||||||
snprintf(buf, len, "%.1f k%s", (double)n / base, suffix);
|
else {
|
||||||
else if (pos < base*base*base)
|
int64_t divider = base;
|
||||||
snprintf(buf, len, "%.1f m%s", (double)n / (base*base), suffix);
|
const char* magnitude = "k";
|
||||||
else
|
if (pos >= divider*base) { divider *= base; magnitude = "m"; }
|
||||||
snprintf(buf, len, "%.1f g%s", (double)n / (base*base*base), suffix);
|
if (pos >= divider*base) { divider *= base; magnitude = "g"; }
|
||||||
|
const int64_t tens = (n / (divider/10));
|
||||||
|
const long whole = (long)(tens/10);
|
||||||
|
const long frac1 = (long)(tens%10);
|
||||||
|
snprintf(buf, len, "%ld.%ld %s%s", whole, frac1, magnitude, suffix);
|
||||||
|
}
|
||||||
_mi_fprintf(out, (fmt==NULL ? "%11s" : fmt), buf);
|
_mi_fprintf(out, (fmt==NULL ? "%11s" : fmt), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,8 +203,10 @@ static void mi_stat_counter_print(const mi_stat_counter_t* stat, const char* msg
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mi_stat_counter_print_avg(const mi_stat_counter_t* stat, const char* msg, mi_output_fun* out) {
|
static void mi_stat_counter_print_avg(const mi_stat_counter_t* stat, const char* msg, mi_output_fun* out) {
|
||||||
double avg = (stat->count == 0 ? 0.0 : (double)stat->total / (double)stat->count);
|
const int64_t avg_tens = (stat->count == 0 ? 0 : (stat->total*10 / stat->count));
|
||||||
_mi_fprintf(out, "%10s: %7.1f avg\n", msg, avg);
|
const long avg_whole = (long)(avg_tens/10);
|
||||||
|
const long avg_frac1 = (long)(avg_tens%10);
|
||||||
|
_mi_fprintf(out, "%10s: %5ld.%ld avg %ld %ld\n", msg, avg_whole, avg_frac1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue