1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Shared testing code.
32 * @author Jose Fonseca <jfonseca@vmware.com>
44 #include "gallivm/lp_bld.h"
46 #include "pipe/p_state.h"
47 #include "util/u_format.h"
48 #include "util/u_math.h"
49 #include "util/u_dump.h"
51 #include "gallivm/lp_bld_type.h"
54 #define LP_TEST_NUM_SAMPLES 32
58 write_tsv_header(FILE *fp
);
62 test_some(unsigned verbose
, FILE *fp
,
66 test_single(unsigned verbose
, FILE *fp
);
69 test_all(unsigned verbose
, FILE *fp
);
72 #if defined(PIPE_CC_MSVC)
74 unsigned __int64
__rdtsc();
75 #pragma intrinsic(__rdtsc)
76 #define rdtsc() __rdtsc()
78 #elif defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
80 static inline uint64_t
84 __asm__
__volatile__ ("rdtsc" : "=a"(lo
), "=d"(hi
));
85 return ((uint64_t)lo
) | (((uint64_t)hi
) << 32);
101 dump_type(FILE *fp
, struct lp_type type
);
105 read_elem(struct lp_type type
, const void *src
, unsigned index
);
109 write_elem(struct lp_type type
, void *dst
, unsigned index
, double src
);
113 random_elem(struct lp_type type
, void *dst
, unsigned index
);
117 read_vec(struct lp_type type
, const void *src
, double *dst
);
121 write_vec(struct lp_type type
, void *dst
, const double *src
);
125 random_vec(struct lp_type type
, void *dst
);
129 compare_vec_with_eps(struct lp_type type
, const void *res
, const void *ref
, double eps
);
133 compare_vec(struct lp_type type
, const void *res
, const void *ref
);
137 dump_vec(FILE *fp
, struct lp_type type
, const void *src
);
140 #endif /* !LP_TEST_H */