Skip to content

Commit aff9498

Browse files
authored
Merge pull request #8886 from hjelmn/format-others
examples/test: format using clang-format
2 parents 02b2010 + 669c0dc commit aff9498

File tree

144 files changed

+7386
-7604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+7386
-7604
lines changed

examples/connectivity_c.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,24 @@
77
*/
88

99
#include <errno.h>
10+
#include <mpi.h>
11+
#include <netdb.h>
1012
#include <stdio.h>
1113
#include <stdlib.h>
1214
#include <string.h>
13-
#include <netdb.h>
1415
#include <unistd.h>
15-
#include <mpi.h>
1616

17-
int
18-
main(int argc, char **argv)
17+
int main(int argc, char **argv)
1918
{
20-
MPI_Status status;
21-
int verbose = 0;
22-
int rank;
23-
int np; /* number of processes in job */
24-
int peer;
25-
int i;
26-
int j;
27-
int length;
28-
char name[MPI_MAX_PROCESSOR_NAME+1];
19+
MPI_Status status;
20+
int verbose = 0;
21+
int rank;
22+
int np; /* number of processes in job */
23+
int peer;
24+
int i;
25+
int j;
26+
int length;
27+
char name[MPI_MAX_PROCESSOR_NAME + 1];
2928

3029
MPI_Init(&argc, &argv);
3130
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -38,28 +37,27 @@ main(int argc, char **argv)
3837
strcpy(name, "unknown");
3938
}
4039

41-
if (argc>1 && strcmp(argv[1], "-v")==0)
40+
if (argc > 1 && strcmp(argv[1], "-v") == 0)
4241
verbose = 1;
4342

44-
for (i=0; i<np; i++) {
45-
if (rank==i) {
43+
for (i = 0; i < np; i++) {
44+
if (rank == i) {
4645
/* rank i sends to and receives from each higher rank */
47-
for(j=i+1; j<np; j++) {
46+
for (j = i + 1; j < np; j++) {
4847
if (verbose)
49-
printf("checking connection between rank %d on %s and rank %-4d\n",
50-
i, name, j);
48+
printf("checking connection between rank %d on %s and rank %-4d\n", i, name, j);
5149
MPI_Send(&rank, 1, MPI_INT, j, rank, MPI_COMM_WORLD);
5250
MPI_Recv(&peer, 1, MPI_INT, j, j, MPI_COMM_WORLD, &status);
5351
}
54-
} else if (rank>i) {
52+
} else if (rank > i) {
5553
/* receive from and reply to rank i */
5654
MPI_Recv(&peer, 1, MPI_INT, i, i, MPI_COMM_WORLD, &status);
5755
MPI_Send(&rank, 1, MPI_INT, i, rank, MPI_COMM_WORLD);
5856
}
5957
}
6058

6159
MPI_Barrier(MPI_COMM_WORLD);
62-
if (rank==0)
60+
if (rank == 0)
6361
printf("Connectivity test on %d processes PASSED.\n", np);
6462

6563
MPI_Finalize();

examples/dtrace/mpicommleak.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
*/
1010

1111
#include <errno.h>
12+
#include <netdb.h>
1213
#include <stdio.h>
1314
#include <stdlib.h>
1415
#include <string.h>
15-
#include <netdb.h>
1616
#include <unistd.h>
1717

1818
#include <mpi.h>
@@ -23,39 +23,40 @@ static void allocate_comms(void);
2323
static void deallocate_comms(void);
2424
static MPI_Comm communicator_a, communicator_b, communicator_c;
2525

26-
int
27-
main(int argc, char *argv[])
26+
int main(int argc, char *argv[])
2827
{
29-
int rank; /* COMM_WORLD rank of process */
30-
int np; /* number of processes in job */
31-
int i;
32-
int unslept;
28+
int rank; /* COMM_WORLD rank of process */
29+
int np; /* number of processes in job */
30+
int i;
31+
int unslept;
3332

3433
MPI_Init(&argc, &argv);
3534
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
3635
MPI_Comm_size(MPI_COMM_WORLD, &np);
3736

38-
for (i=0; i < ITERATIONS; i++) {
39-
/* allocate our communicators */
40-
allocate_comms();
37+
for (i = 0; i < ITERATIONS; i++) {
38+
/* allocate our communicators */
39+
allocate_comms();
4140

42-
/* simulate doing work */
43-
unslept = sleep(5);
41+
/* simulate doing work */
42+
unslept = sleep(5);
4443

45-
/* deallocate communicators forgetting one of the communicators */
46-
deallocate_comms();
44+
/* deallocate communicators forgetting one of the communicators */
45+
deallocate_comms();
4746
}
4847
MPI_Finalize();
4948
return 0;
5049
}
5150

52-
void allocate_comms(void) {
51+
void allocate_comms(void)
52+
{
5353
MPI_Comm_dup(MPI_COMM_WORLD, &communicator_a);
5454
MPI_Comm_dup(MPI_COMM_WORLD, &communicator_b);
5555
MPI_Comm_dup(MPI_COMM_WORLD, &communicator_c);
5656
}
5757

58-
void deallocate_comms(void) {
58+
void deallocate_comms(void)
59+
{
5960
MPI_Comm_free(&communicator_a);
6061
MPI_Comm_free(&communicator_c);
6162
}

examples/hello_c.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* Sample MPI "hello world" application in C
88
*/
99

10-
#include <stdio.h>
1110
#include "mpi.h"
11+
#include <stdio.h>
1212

13-
int main(int argc, char* argv[])
13+
int main(int argc, char *argv[])
1414
{
1515
int rank, size, len;
1616
char version[MPI_MAX_LIBRARY_VERSION_STRING];
@@ -19,8 +19,7 @@ int main(int argc, char* argv[])
1919
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
2020
MPI_Comm_size(MPI_COMM_WORLD, &size);
2121
MPI_Get_library_version(version, &len);
22-
printf("Hello, world, I am %d of %d, (%s, %d)\n",
23-
rank, size, version, len);
22+
printf("Hello, world, I am %d of %d, (%s, %d)\n", rank, size, version, len);
2423
MPI_Finalize();
2524

2625
return 0;

examples/hello_oshmem_c.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
* $HEADER$
1010
*/
1111

12-
#include <stdio.h>
1312
#include "shmem.h"
13+
#include <stdio.h>
1414

1515
#if !defined(OSHMEM_SPEC_VERSION) || OSHMEM_SPEC_VERSION < 10200
16-
#error This application uses API 1.2 and up
16+
# error This application uses API 1.2 and up
1717
#endif
1818

19-
int main(int argc, char* argv[])
19+
int main(int argc, char *argv[])
2020
{
2121
int proc, nproc;
2222
char name[SHMEM_MAX_NAME_LEN];
@@ -28,8 +28,7 @@ int main(int argc, char* argv[])
2828
shmem_info_get_name(name);
2929
shmem_info_get_version(&major, &minor);
3030

31-
printf("Hello, world, I am %d of %d: %s (version: %d.%d)\n",
32-
proc, nproc, name, major, minor);
31+
printf("Hello, world, I am %d of %d: %s (version: %d.%d)\n", proc, nproc, name, major, minor);
3332
shmem_finalize();
3433

3534
return 0;

examples/oshmem_circular_shift.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
* $HEADER$
99
*/
1010

11-
#include <stdio.h>
1211
#include <shmem.h>
12+
#include <stdio.h>
1313

14-
int main (void)
14+
int main(void)
1515
{
1616
static int aaa, bbb;
1717
int num_pes, my_pe, peer;
@@ -32,4 +32,3 @@ int main (void)
3232

3333
return 0;
3434
}
35-

examples/oshmem_max_reduction.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ long src[N];
2323
long dst[N];
2424
long pWrk[_SHMEM_REDUCE_SYNC_SIZE];
2525

26-
int main(void)
26+
int main(void)
2727
{
2828
int i;
2929
int my_pe, num_pes;
@@ -47,7 +47,7 @@ int main(void)
4747

4848
printf("%d/%d dst =", my_pe, num_pes);
4949

50-
for (i = 0; i < N; i+= 1) {
50+
for (i = 0; i < N; i += 1) {
5151
printf(" %ld", dst[i]);
5252
}
5353

@@ -56,4 +56,3 @@ int main(void)
5656

5757
return 0;
5858
}
59-

examples/oshmem_shmalloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ int main(void)
2727

2828
shmem_finalize();
2929
}
30-

examples/oshmem_strided_puts.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
*
2525
*/
2626

27-
#include <stdio.h>
2827
#include <shmem.h>
28+
#include <stdio.h>
2929

3030
int main(void)
3131
{
32-
short source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
32+
short source[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
3333
static short target[10];
3434
int me;
3535

@@ -44,9 +44,8 @@ int main(void)
4444
shmem_barrier_all(); /* sync sender and receiver */
4545

4646
if (me == 1) {
47-
printf("target on PE %d is %hd %hd %hd %hd %hd\n", me,
48-
target[0], target[1], target[2],
49-
target[3], target[4] );
47+
printf("target on PE %d is %hd %hd %hd %hd %hd\n", me, target[0], target[1], target[2],
48+
target[3], target[4]);
5049
}
5150
shmem_barrier_all(); /* sync before exiting */
5251
shmem_finalize();

examples/oshmem_symmetric_data.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* $HEADER$
99
*/
1010

11-
#include <stdio.h>
1211
#include <shmem.h>
12+
#include <stdio.h>
1313

1414
#define SIZE 16
1515

16-
int main(int argc, char* argv[])
16+
int main(int argc, char *argv[])
1717
{
1818
short source[SIZE];
1919
static short target[SIZE];
@@ -27,13 +27,13 @@ int main(int argc, char* argv[])
2727

2828
if (my_pe == 0) {
2929
/* initialize array */
30-
for(i = 0; i < SIZE; i++) {
30+
for (i = 0; i < SIZE; i++) {
3131
source[i] = i;
3232
}
3333
/* local, not symmetric */
3434
/* static makes it symmetric */
3535
/* put "size" words into target on each PE */
36-
for(i = 1; i < num_pe; i++) {
36+
for (i = 1; i < num_pe; i++) {
3737
shmem_short_put(target, source, SIZE, i);
3838
}
3939
}
@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
4343
if (my_pe != 0) {
4444
printf("Target on PE %d is \t", my_pe);
4545

46-
for(i = 0; i < SIZE; i++) {
46+
for (i = 0; i < SIZE; i++) {
4747
printf("%hd \t", target[i]);
4848
}
4949
printf("\n");

examples/ring_c.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Simple ring test program in C.
88
*/
99

10-
#include <stdio.h>
1110
#include "mpi.h"
11+
#include <stdio.h>
1212

1313
int main(int argc, char *argv[])
1414
{
@@ -34,8 +34,8 @@ int main(int argc, char *argv[])
3434
if (0 == rank) {
3535
message = 10;
3636

37-
printf("Process 0 sending %d to %d, tag %d (%d processes in ring)\n",
38-
message, next, tag, size);
37+
printf("Process 0 sending %d to %d, tag %d (%d processes in ring)\n", message, next, tag,
38+
size);
3939
MPI_Send(&message, 1, MPI_INT, next, tag, MPI_COMM_WORLD);
4040
printf("Process 0 sent to %d\n", next);
4141
}
@@ -49,8 +49,7 @@ int main(int argc, char *argv[])
4949
and can quit normally. */
5050

5151
while (1) {
52-
MPI_Recv(&message, 1, MPI_INT, prev, tag, MPI_COMM_WORLD,
53-
MPI_STATUS_IGNORE);
52+
MPI_Recv(&message, 1, MPI_INT, prev, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
5453

5554
if (0 == rank) {
5655
--message;
@@ -68,8 +67,7 @@ int main(int argc, char *argv[])
6867
to be received before the program can exit */
6968

7069
if (0 == rank) {
71-
MPI_Recv(&message, 1, MPI_INT, prev, tag, MPI_COMM_WORLD,
72-
MPI_STATUS_IGNORE);
70+
MPI_Recv(&message, 1, MPI_INT, prev, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
7371
}
7472

7573
/* All done */

0 commit comments

Comments
 (0)