Blame test/trace_mechanism_test_helper.c
|
Packit Service |
7f3b24 |
// SPDX-License-Identifier: BSD-2-Clause
|
|
Packit Service |
7f3b24 |
/* Copyright (C) 2016 - 2020 Intel Corporation. */
|
|
Packit |
345191 |
#include "memkind.h"
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#include <stdio.h>
|
|
Packit |
345191 |
#include <stdlib.h>
|
|
Packit |
345191 |
#include <string.h>
|
|
Packit |
345191 |
|
|
Packit |
345191 |
int main(int argc, char *argv[])
|
|
Packit |
345191 |
{
|
|
Packit |
345191 |
int err = 0;
|
|
Packit |
345191 |
const size_t size = 1024 * 1024;
|
|
Packit |
345191 |
void *buf = NULL;
|
|
Packit |
345191 |
|
|
Packit |
345191 |
//It is expected that "MEMKIND_HBW" or "MEMKIND_HUGETLB" argument is passed
|
|
Packit |
345191 |
if (argc != 2) {
|
|
Packit |
345191 |
printf("Error: Wrong number of parameters\n");
|
|
Packit |
345191 |
err = -1;
|
|
Packit |
345191 |
return err;
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
|
|
Packit |
345191 |
if (strcmp(argv[1], "MEMKIND_HBW") == 0) {
|
|
Packit |
345191 |
buf = memkind_malloc(MEMKIND_HBW, size);
|
|
Packit |
345191 |
if (buf == NULL) {
|
|
Packit |
345191 |
printf("Allocation of MEMKIND_HBW failed\n");
|
|
Packit |
345191 |
err = -1;
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
memkind_free(MEMKIND_HBW, buf);
|
|
Packit |
345191 |
} else if (strcmp(argv[1], "MEMKIND_HUGETLB") == 0) {
|
|
Packit |
345191 |
buf = memkind_malloc(MEMKIND_HUGETLB, size);
|
|
Packit |
345191 |
if (buf == NULL) {
|
|
Packit |
345191 |
printf("Allocation of MEMKIND_HUGETLB failed\n");
|
|
Packit |
345191 |
err = -1;
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
memkind_free(MEMKIND_HUGETLB, buf);
|
|
Packit |
345191 |
} else {
|
|
Packit |
345191 |
printf("Error: unknown parameter\n");
|
|
Packit |
345191 |
err = -1;
|
|
Packit |
345191 |
}
|
|
Packit |
345191 |
|
|
Packit |
345191 |
return err;
|
|
Packit |
345191 |
}
|