Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
darshan
darshan
Commits
640f20ff
Commit
640f20ff
authored
Jan 22, 2017
by
Philip Carns
Browse files
demonstrator for
#218
parent
8babcd89
Changes
1
Show whitespace changes
Inline
Side-by-side
darshan-test/regression/test-cases/src/access-size-counter-test.c
0 → 100644
View file @
640f20ff
/*
* (C) 1995-2001 Clemson University and Argonne National Laboratory.
*
* See COPYING in top-level directory.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <mpi.h>
#include <errno.h>
#include <getopt.h>
/* DEFAULT VALUES FOR OPTIONS */
static
char
opt_file
[
256
]
=
"test.out"
;
/* function prototypes */
static
int
parse_args
(
int
argc
,
char
**
argv
);
static
void
usage
(
void
);
/* global vars */
static
int
mynod
=
0
;
static
int
nprocs
=
1
;
int
main
(
int
argc
,
char
**
argv
)
{
int
namelen
;
char
processor_name
[
MPI_MAX_PROCESSOR_NAME
];
char
buffer
[
128
]
=
{
0
};
int
fd
;
int
i
=
1
;
int
ret
;
/* startup MPI and determine the rank of this process */
MPI_Init
(
&
argc
,
&
argv
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
nprocs
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
mynod
);
MPI_Get_processor_name
(
processor_name
,
&
namelen
);
/* parse the command line arguments */
parse_args
(
argc
,
argv
);
if
(
mynod
==
0
)
{
fd
=
open
(
opt_file
,
O_WRONLY
|
O_TRUNC
|
O_CREAT
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
);
if
(
fd
<
0
)
{
perror
(
"open"
);
return
(
-
1
);
}
/* cycle through a range of unique write access sizes */
for
(
i
=
1
;
i
<
128
;
i
++
)
{
ret
=
write
(
fd
,
buffer
,
i
);
if
(
ret
<
0
)
{
perror
(
"write"
);
return
(
-
1
);
}
if
(
ret
!=
i
)
{
fprintf
(
stderr
,
"Short write: %d
\n
"
,
ret
);
return
(
-
1
);
}
}
close
(
fd
);
}
MPI_Finalize
();
return
(
0
);
}
static
int
parse_args
(
int
argc
,
char
**
argv
)
{
int
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"f:"
))
!=
EOF
)
{
switch
(
c
)
{
case
'f'
:
/* filename */
strncpy
(
opt_file
,
optarg
,
255
);
break
;
case
'?'
:
/* unknown */
if
(
mynod
==
0
)
usage
();
exit
(
1
);
default:
break
;
}
}
return
(
0
);
}
static
void
usage
(
void
)
{
printf
(
"Usage: stdio-test [<OPTIONS>...]
\n
"
);
printf
(
"
\n
<OPTIONS> is one of
\n
"
);
printf
(
" -f filename [default: test.out]
\n
"
);
printf
(
" -h print this help
\n
"
);
}
/*
* Local variables:
* c-indent-level: 3
* c-basic-offset: 3
* tab-width: 3
*
* vim: ts=3
* End:
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment