示例#1
0
文件: benchmark.c 项目: kranfix/pal
static void setup_memory(struct p_bench_raw_memory *mem, char **raw,
                         size_t size)
{
    assert(mem != NULL);
    assert(size > 0);
    assert(raw != NULL);

    size_t raw_output_size = sizeof(uintmax_t) * size * max_output;
    size_t raw_size =
        raw_output_size +
        (sizeof(float) + sizeof(double) + sizeof(uintmax_t)) * size * 2;

    if (*raw == NULL) {
        *raw = malloc(raw_size);
    } else {
        *raw = realloc(*raw, raw_size);
    }
    if (*raw == NULL) {
        (void)fprintf(stderr, "Unable to allocate memory: %zu\n", size);
        exit(EXIT_FAILURE);
    }

    setup_output_pointers(mem, *raw);
    setup_input_pointers(mem, *raw + raw_output_size, size);
}
示例#2
0
文件: benchmark.c 项目: olajep/pal
static void setup_memory(struct p_bench_raw_memory *mem, char **raw,
                         size_t size)
{
    assert(mem != NULL);
    assert(size > 0);
    assert(raw != NULL);

    size_t raw_output_size = MAX_OUTPUTS * MAX_ELEMS * sizeof(uintmax_t);
    size_t raw_size =
        raw_output_size + MAX_INPUTS * MAX_ELEMS * (sizeof(uintmax_t));

#ifdef __epiphany__
    *raw = RAW_MEM;
#else
    if (*raw == NULL) {
        *raw = malloc(raw_size);
    } else {
        *raw = realloc(*raw, raw_size);
    }
    if (*raw == NULL) {
        (void)fprintf(stderr, "Unable to allocate memory: %zu\n", size);
        exit(EXIT_FAILURE);
    }
#endif

    setup_output_pointers(mem, *raw);
    setup_input_pointers(mem, *raw + raw_output_size, size);
}