Skip to content

Commit 881a8fc

Browse files
author
Qing Liu
committed
add test_ost_speed_100ost.
1 parent 4ce042f commit 881a8fc

File tree

2 files changed

+162
-4
lines changed

2 files changed

+162
-4
lines changed

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
CC=cc
22
CFLAGS=-c
33
LDFLAGS=
4-
SOURCES=interf.c test_ost_speed.c
4+
SOURCES=interf.c test_ost_speed.c test_ost_speed_100ost.c
55
OBJECTS=$(SOURCES:.c=.o)
6-
EXECUTABLE=interf test_ost_speed
6+
EXECUTABLE=interf test_ost_speed test_ost_speed_100ost
77

8-
all: interf test_ost_speed
8+
all: interf test_ost_speed test_ost_speed_100ost
99
interf: interf.c
1010
${CC} -g -c -DH5_USE_16_API interf.c
1111
${CC} -g -o interf interf.o
1212
test_ost_speed: test_ost_speed.c
1313
${CC} -g -c -DH5_USE_16_API test_ost_speed.c
1414
${CC} -g -o test_ost_speed test_ost_speed.o
15+
test_ost_speed_100ost: test_ost_speed_100ost.c
16+
${CC} -g -c -DH5_USE_16_API test_ost_speed_100ost.c
17+
${CC} -g -o test_ost_speed_100ost test_ost_speed_100ost.o
1518
clean:
1619
rm -f *.o core.* *~ *err *out
17-
rm -f interf test_ost_speed
20+
rm -f interf test_ost_speed test_ost_speed_100ost
1821

test_ost_speed_100ost.c

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#include <stdio.h>
2+
#include "mpi.h"
3+
#include "hdf5.h"
4+
#include <unistd.h>
5+
#include <fcntl.h>
6+
#include <stdlib.h>
7+
#include <math.h>
8+
#include <string.h>
9+
#include <sys/time.h>
10+
#include <sys/vfs.h>
11+
#include <sys/ioctl.h>
12+
13+
// LUSTRE Structure
14+
// from /usr/include/lustre/lustre_user.h
15+
#define LUSTRE_SUPER_MAGIC 0x0BD00BD0
16+
# define LOV_USER_MAGIC 0x0BD10BD0
17+
# define LL_IOC_LOV_SETSTRIPE _IOW ('f', 154, long)
18+
# define LL_IOC_LOV_GETSTRIPE _IOW ('f', 155, long)
19+
#define O_LOV_DELAY_CREATE 0100000000
20+
21+
struct lov_user_ost_data { // per-stripe data structure
22+
uint64_t l_object_id; // OST object ID
23+
uint64_t l_object_gr; // OST object group (creating MDS number)
24+
uint32_t l_ost_gen; // generation of this OST index
25+
uint32_t l_ost_idx; // OST index in LOV
26+
} __attribute__((packed));
27+
struct lov_user_md { // LOV EA user data (host-endian)
28+
uint32_t lmm_magic; // magic number = LOV_USER_MAGIC_V1
29+
uint32_t lmm_pattern; // LOV_PATTERN_RAID0, LOV_PATTERN_RAID1
30+
uint64_t lmm_object_id; // LOV object ID
31+
uint64_t lmm_object_gr; // LOV object group
32+
uint32_t lmm_stripe_size; // size of stripe in bytes
33+
uint16_t lmm_stripe_count; // num stripes in use for this object
34+
uint16_t lmm_stripe_offset; // starting stripe offset in lmm_objects
35+
struct lov_user_ost_data lmm_objects[0]; // per-stripe data
36+
} __attribute__((packed));
37+
38+
int main (int argc, char ** argv)
39+
{
40+
int old_mask;
41+
int perm, f;
42+
int i, j, k, rank;
43+
44+
MPI_Init (&argc, &argv);
45+
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
46+
47+
old_mask = umask (0);
48+
umask (old_mask);
49+
perm = old_mask ^ 0666;
50+
51+
char temp_string[100], dataset_name[100];
52+
53+
sprintf (temp_string
54+
,"%s%d.h5"
55+
,"interf"
56+
,rank
57+
);
58+
59+
k = 0;
60+
61+
62+
unlink (temp_string); // clean up old stuff
63+
64+
struct timeval t1;
65+
gettimeofday (&t1, NULL);
66+
67+
f = open (temp_string
68+
,O_RDONLY | O_CREAT | O_LOV_DELAY_CREATE
69+
,perm
70+
);
71+
72+
struct lov_user_md lum;
73+
lum.lmm_magic = LOV_USER_MAGIC;
74+
lum.lmm_pattern = 0;
75+
lum.lmm_stripe_size = 0;
76+
lum.lmm_stripe_count = 1;
77+
lum.lmm_stripe_offset = rank;
78+
ioctl (f, LL_IOC_LOV_SETSTRIPE
79+
,(void *) &lum
80+
);
81+
close (f);
82+
83+
hid_t fid = H5Fopen (temp_string, H5F_ACC_RDWR, H5P_DEFAULT);
84+
85+
if (fid < 0)
86+
{
87+
fid = H5Fcreate (temp_string, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
88+
if (fid < 0)
89+
{
90+
fprintf (stderr, "HDF5 ERROR: "
91+
"cannot open/create %s\n"
92+
,temp_string);
93+
return -1;
94+
}
95+
}
96+
97+
hid_t h5_dataset_id;
98+
hid_t h5_dataspace_id, h5_memspace_id;
99+
herr_t status;
100+
int vrank = 2;
101+
hsize_t h5_localdims[vrank];
102+
// 512x512 is 2M
103+
int NX = 512*4;
104+
int NY = 512*2;
105+
h5_localdims[0] = NY;
106+
h5_localdims[1] = NX;
107+
double my_data[NY][NX];
108+
109+
for (i = 0; i < NY; i++)
110+
for (j =0; j < NX; j++)
111+
my_data[i][j] = i + j + vrank;
112+
113+
h5_dataspace_id = H5Screate_simple (vrank, h5_localdims, NULL);
114+
115+
sprintf (dataset_name, "var");
116+
// h5_dataset_id = H5Dopen (fid, dataset_name);
117+
118+
h5_dataset_id = H5Dcreate (fid
119+
,dataset_name
120+
,H5T_NATIVE_DOUBLE
121+
,h5_dataspace_id
122+
,H5P_DEFAULT
123+
);
124+
125+
status = H5Dwrite (h5_dataset_id
126+
,H5T_NATIVE_DOUBLE
127+
,H5S_ALL
128+
,H5S_ALL
129+
,H5P_DEFAULT
130+
,&my_data[0][0]
131+
);
132+
133+
if (status == 0)
134+
{
135+
// printf ("%d th iteration is done.\n", k);
136+
}
137+
else
138+
{
139+
printf ("%d th iteration has error.\n", k);
140+
}
141+
k++;
142+
143+
H5Dclose (h5_dataset_id);
144+
H5Sclose (h5_dataspace_id);
145+
H5Fclose (fid);
146+
147+
struct timeval t2;
148+
gettimeofday (&t2, NULL);
149+
150+
printf("%d %.6lf\n", rank, t2.tv_sec + t2.tv_usec/1000000.0 - t1.tv_sec - t1.tv_usec/1000000.0);
151+
152+
MPI_Finalize ();
153+
154+
return 0;
155+
}

0 commit comments

Comments
 (0)