4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
36 #include <sys/types.h>
48 void usage(char *prog)
50 printf("usage: %s {-o|-m|-l<tgt>} filenamefmt count\n", prog);
51 printf(" %s {-o|-m|-l<tgt>} filenamefmt -seconds\n", prog);
52 printf(" %s {-o|-m|-l<tgt>} filenamefmt start count\n", prog);
55 /* Print process rank, loop count, message, and exit (i.e. a fatal error) */
56 int rprintf(int rank, int loop, const char *fmt, ...)
60 printf("rank %d, loop %d: ", rank, loop);
70 int main(int argc, char ** argv)
72 int i, rc = 0, do_open = 0, do_link = 0, rank;
73 char format[4096], *fmt, *tgt = NULL;
75 long start, last, end;
76 long begin = 0, count;
78 rc = MPI_Init(&argc, &argv);
79 if (rc != MPI_SUCCESS)
80 rprintf(-1, -1, "MPI_Init failed: %d\n", rc);
82 if (argc < 4 || argc > 5) {
87 if (strcmp(argv[1], "-o") == 0) {
90 } else if (strncmp(argv[1], "-l", 2) == 0 && argv[1][2]) {
93 } else if (strcmp(argv[1], "-m") != 0) {
98 if (strlen(argv[2]) > 4080) {
99 printf("name too long\n");
103 rc = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
104 if (rc != MPI_SUCCESS)
105 rprintf(-1, -1, "MPI_Comm_rank failed: %d\n", rc);
107 rc = MPI_Barrier(MPI_COMM_WORLD);
108 if (rc != MPI_SUCCESS)
109 rprintf(rank, -1, "prep MPI_Barrier failed: %d\n", rc);
111 start = last = time(0);
114 end = strtol(argv[3], NULL, 0);
116 begin = strtol(argv[3], NULL, 0);
117 end = strtol(argv[4], NULL, 0);
127 if (strchr(argv[2], '%'))
130 sprintf(format, "%s%%d", argv[2]);
133 printf("starting at %s", ctime(&start));
134 for (i = 0; i < count && time(0) < end; i++, begin++) {
135 sprintf(filename, fmt, begin);
137 int fd = open(filename, O_CREAT|O_RDWR, 0644);
139 printf("open(%s) error: %s\n", filename,
145 } else if (do_link) {
146 rc = link(tgt, filename);
148 printf("link(%s, %s) error: %s\n",
149 tgt, filename, strerror(errno));
154 rc = mknod(filename, S_IFREG| 0444, 0);
156 printf("mknod(%s) error: %s\n",
157 filename, strerror(errno));
162 if ((i % 10000) == 0) {
163 printf(" - created %d (time %ld total %ld last %ld)\n",
164 i, time(0), time(0) - start, time(0) - last);
168 printf("total: %d creates in %ld seconds: %f creates/second\n", i,
169 time(0) - start, ((float)i / (time(0) - start)));
171 printf("finish at %s", ctime(&start));