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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
27 * This file is part of Lustre, http://www.lustre.org/
28 * Lustre is a trademark of Sun Microsystems, Inc.
32 #include <sys/types.h>
44 void usage(char *prog)
46 printf("usage: %s {-o|-m|-l<tgt>} filenamefmt count\n", prog);
47 printf(" %s {-o|-m|-l<tgt>} filenamefmt -seconds\n", prog);
48 printf(" %s {-o|-m|-l<tgt>} filenamefmt start count\n", prog);
51 /* Print process rank, loop count, message, and exit (i.e. a fatal error) */
52 int rprintf(int rank, int loop, const char *fmt, ...)
56 printf("rank %d, loop %d: ", rank, loop);
66 int main(int argc, char ** argv)
68 int i, rc = 0, do_open = 0, do_link = 0, rank;
69 char format[4096], *fmt, *tgt = NULL;
71 long start, last, end;
72 long begin = 0, count;
74 rc = MPI_Init(&argc, &argv);
75 if (rc != MPI_SUCCESS)
76 rprintf(-1, -1, "MPI_Init failed: %d\n", rc);
78 if (argc < 4 || argc > 5) {
83 if (strcmp(argv[1], "-o") == 0) {
86 } else if (strncmp(argv[1], "-l", 2) == 0 && argv[1][2]) {
89 } else if (strcmp(argv[1], "-m") != 0) {
94 if (strlen(argv[2]) > 4080) {
95 printf("name too long\n");
99 rc = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
100 if (rc != MPI_SUCCESS)
101 rprintf(-1, -1, "MPI_Comm_rank failed: %d\n", rc);
103 rc = MPI_Barrier(MPI_COMM_WORLD);
104 if (rc != MPI_SUCCESS)
105 rprintf(rank, -1, "prep MPI_Barrier failed: %d\n", rc);
107 start = last = time(0);
110 end = strtol(argv[3], NULL, 0);
112 begin = strtol(argv[3], NULL, 0);
113 end = strtol(argv[4], NULL, 0);
123 if (strchr(argv[2], '%'))
126 sprintf(format, "%s%%d", argv[2]);
129 printf("starting at %s", ctime(&start));
130 for (i = 0; i < count && time(0) < end; i++, begin++) {
131 sprintf(filename, fmt, begin);
133 int fd = open(filename, O_CREAT|O_RDWR, 0644);
135 printf("open(%s) error: %s\n", filename,
141 } else if (do_link) {
142 rc = link(tgt, filename);
144 printf("link(%s, %s) error: %s\n",
145 tgt, filename, strerror(errno));
150 rc = mknod(filename, S_IFREG| 0444, 0);
152 printf("mknod(%s) error: %s\n",
153 filename, strerror(errno));
158 if ((i % 10000) == 0) {
159 printf(" - created %d (time %ld total %ld last %ld)\n",
160 i, time(0), time(0) - start, time(0) - last);
164 printf("total: %d creates in %ld seconds: %f creates/second\n", i,
165 time(0) - start, ((float)i / (time(0) - start)));
167 printf("finish at %s", ctime(&start));