File: mtest_common.h

package info (click to toggle)
mpich 4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,184 kB
  • sloc: ansic: 1,040,629; cpp: 82,270; javascript: 40,763; perl: 27,933; python: 16,041; sh: 14,676; xml: 14,418; f90: 12,916; makefile: 9,270; fortran: 8,046; java: 4,635; asm: 324; ruby: 103; awk: 27; lisp: 19; php: 8; sed: 4
file content (70 lines) | stat: -rw-r--r-- 3,329 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#ifndef MTEST_COMMON_H_INCLUDED
#define MTEST_COMMON_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef enum {
    MTEST_MEM_TYPE__UNSET,
    MTEST_MEM_TYPE__UNREGISTERED_HOST,
    MTEST_MEM_TYPE__REGISTERED_HOST,
    MTEST_MEM_TYPE__DEVICE,
    MTEST_MEM_TYPE__SHARED,
    MTEST_MEM_TYPE__RANDOM,
    MTEST_MEM_TYPE__ALL,
} mtest_mem_type_e;

MPI_Aint MTestDefaultMaxBufferSize(void);

typedef void MTestArgList;
MTestArgList *MTestArgListCreate(int argc, char *argv[]);
char *MTestArgListSearch(MTestArgList * head, const char *arg);
char *MTestArgListGetString(MTestArgList * head, const char *arg);
int MTestArgListGetInt(MTestArgList * head, const char *arg);
long MTestArgListGetLong(MTestArgList * head, const char *arg);
const char *MTestArgListGetString_with_default(MTestArgList * head, const char *arg,
                                               const char *default_str);
int MTestArgListGetInt_with_default(MTestArgList * head, const char *arg, int default_val);
long MTestArgListGetLong_with_default(MTestArgList * head, const char *arg, long default_val);
mtest_mem_type_e MTestArgListGetMemType(MTestArgList * head, const char *arg);
void MTestArgListDestroy(MTestArgList * head);

mtest_mem_type_e MTest_memtype_random(void);
const char *MTest_memtype_name(mtest_mem_type_e memtype);
int *MTestParseIntList(const char *str, int *num);
char **MTestParseStringList(const char *str, int *num);
void MTestFreeStringList(char **str, int num);

#define MTEST_CREATE_AND_FREE_DTP_OBJS(dtp_, testsize_) ({              \
    int errs_ = 0;                                                      \
    MPI_Aint maxbufsize = MTestDefaultMaxBufferSize();                  \
    do {                                                                \
        int i_, err_;                                                   \
        DTP_obj_s obj_;                                                 \
        for(i_ = 0; i_ < testsize_; i_++) {                             \
            err_ = DTP_obj_create(dtp_, &obj_, maxbufsize);             \
            if (err_ != DTP_SUCCESS) {                                  \
                errs_++;                                                \
                break;                                                  \
            }                                                           \
            DTP_obj_free(obj_);                                         \
        }                                                               \
    } while (0);                                                        \
    errs_; })

#define MTestMalloc(size, type, hostbuf, devicebuf, device) MTestAlloc(size, type, hostbuf, devicebuf, 0, device)
#define MTestCalloc(size, type, hostbuf, devicebuf, device) MTestAlloc(size, type, hostbuf, devicebuf, 1, device)
void MTestAlloc(size_t size, mtest_mem_type_e type, void **hostbuf, void **devicebuf,
                bool is_calloc, int device);
void MTestFree(mtest_mem_type_e type, void *hostbuf, void *devicebuf);
void MTestCopyContent(const void *sbuf, void *dbuf, size_t size, mtest_mem_type_e type);
void MTest_finalize_gpu(void);
void MTest_init_visibility_gpu(void);
#endif