Nek5000
SEM for Incompressible NS
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
jl
tests
sort_test2.c
Go to the documentation of this file.
1
#include <stddef.h>
2
#include <stdlib.h>
3
#include <stdio.h>
4
#include <limits.h>
5
#include <string.h>
6
#include "
c99.h
"
7
#include "
name.h
"
8
#include "
fail.h
"
9
#include "
types.h
"
10
#include "
mem.h
"
11
#include "
sort.h
"
12
#include "
rdtsc.h
"
13
14
#if 1
15
16
DEFINE_HW_COUNTER
()
17
18
#define N (1<<20)
19
20
ulong
A
[
N
],
out
[
N
];
21
uint
P
[
N
];
22
23
int
main
()
24
{
25
buffer
buf =
null_buffer
;
26
uint
i
;
27
unsigned
long
long
tic, toc;
28
unsigned
r;
29
#define TIME(t, repeat, what) do { \
30
for(r=repeat;r;--r) { what; } \
31
tic = getticks(); \
32
for(r=repeat;r;--r) { what; } \
33
toc = getticks(); \
34
t = toc-tic; \
35
} while(0)
36
37
for
(i=0;i!=
N
;++
i
) {
38
A[
i
]=rand();
39
A[
i
]<<=CHAR_BIT*
sizeof
(int)-1;
40
A[
i
]^=rand();
41
A[
i
]<<=CHAR_BIT*
sizeof
(int)-1;
42
A[
i
]^=rand();
43
if
(0) A[
i
]&=0x000ff00;
44
}
45
46
for
(i=
N
;
i
;i>>=1) {
47
unsigned
long
long
t;
48
TIME
(t, (
N
/i),
49
sortv_long
(out, A,i,
sizeof
(
ulong
), &buf));
50
printf(
"sortv %d : %g cycles per item\n"
,
51
(
int
)i, t/(
double
)(
N
/i)/(
double
)i);
52
}
53
54
for
(i=
N
;
i
;i>>=1) {
55
unsigned
long
long
t;
56
TIME
(t, (
N
/i),
57
sortp_long
(&buf,0, A,i,
sizeof
(
ulong
)));
58
printf(
"sortp %d : %g cycles per item\n"
,
59
(
int
)i, t/(
double
)(
N
/i)/(
double
)i);
60
}
61
62
buffer_free
(&buf);
63
return
0;
64
}
65
66
#else
67
68
int
main
()
69
{
70
return
0;
71
}
72
73
#endif
74
uint
#define uint
Definition:
types.h:70
rdtsc.h
buffer_free
#define buffer_free(b)
Definition:
mem.h:158
types.h
mem.h
P
uint P[N]
Definition:
sort_test2.c:21
A
ulong A[N]
Definition:
sort_test2.c:20
c99.h
sort.h
main
int main()
Definition:
sort_test2.c:23
fail.h
array
Definition:
mem.h:111
ulong
#define ulong
Definition:
types.h:75
TIME
#define TIME(t, repeat, what)
DEFINE_HW_COUNTER
#define DEFINE_HW_COUNTER()
Definition:
rdtsc.h:4
sortp_long
#define sortp_long
Definition:
sort.h:57
i
for i
Definition:
xxt_test.m:74
null_buffer
#define null_buffer
Definition:
mem.h:154
out
ulong out[N]
Definition:
sort_test2.c:20
name.h
establishes some macros to establish naming conventions
N
#define N
Definition:
sort_test2.c:18
sortv_long
#define sortv_long
Definition:
sort.h:56
Generated on Tue Jul 14 2015 10:52:58 for Nek5000 by
1.8.8