apply clang-format

This commit is contained in:
Axel Kohlmeyer
2021-05-05 23:48:10 -04:00
parent 9e4c618d30
commit 5fcd0d8b79
2 changed files with 142 additions and 128 deletions

View File

@ -13,13 +13,15 @@
/* Single-processor "stub" versions of MPI routines */
#include "mpi.h"
#include "../version.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/time.h>
#include "mpi.h"
#include "../version.h"
/* data structure for double/int */
@ -38,7 +40,7 @@ MPI_Datatype *ptr_datatype[MAXEXTRA_DATATYPE];
int index_datatype[MAXEXTRA_DATATYPE];
int size_datatype[MAXEXTRA_DATATYPE];
static int _mpi_is_initialized=0;
static int _mpi_is_initialized = 0;
/* ---------------------------------------------------------------------- */
/* MPI Functions */
@ -86,7 +88,7 @@ int MPI_Get_library_version(char *version, int *resultlen)
if (!version || !resultlen) return MPI_ERR_ARG;
len = strlen(string);
memcpy(version,string,len+1);
memcpy(version, string, len + 1);
*resultlen = len;
return MPI_SUCCESS;
}
@ -103,7 +105,7 @@ int MPI_Get_processor_name(char *name, int *resultlen)
if (!name || !resultlen) return MPI_ERR_ARG;
len = strlen(host);
memcpy(name,host,len+1);
memcpy(name, host, len + 1);
*resultlen = len;
return MPI_SUCCESS;
}
@ -175,7 +177,7 @@ double MPI_Wtime()
double time;
struct timeval tv;
gettimeofday(&tv,NULL);
gettimeofday(&tv, NULL);
time = 1.0 * tv.tv_sec + 1.0e-6 * tv.tv_usec;
return time;
#endif
@ -187,14 +189,22 @@ double MPI_Wtime()
static int stubtypesize(MPI_Datatype datatype)
{
if (datatype == MPI_INT) return sizeof(int);
else if (datatype == MPI_FLOAT) return sizeof(float);
else if (datatype == MPI_DOUBLE) return sizeof(double);
else if (datatype == MPI_CHAR) return sizeof(char);
else if (datatype == MPI_BYTE) return sizeof(char);
else if (datatype == MPI_LONG) return sizeof(long);
else if (datatype == MPI_LONG_LONG) return sizeof(uint64_t);
else if (datatype == MPI_DOUBLE_INT) return sizeof(double_int);
if (datatype == MPI_INT)
return sizeof(int);
else if (datatype == MPI_FLOAT)
return sizeof(float);
else if (datatype == MPI_DOUBLE)
return sizeof(double);
else if (datatype == MPI_CHAR)
return sizeof(char);
else if (datatype == MPI_BYTE)
return sizeof(char);
else if (datatype == MPI_LONG)
return sizeof(long);
else if (datatype == MPI_LONG_LONG)
return sizeof(uint64_t);
else if (datatype == MPI_DOUBLE_INT)
return sizeof(double_int);
else {
int i;
for (i = 0; i < nextra_datatype; i++)
@ -222,10 +232,10 @@ int MPI_Request_free(MPI_Request *request)
/* ---------------------------------------------------------------------- */
int MPI_Send(const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm)
int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not send message to self\n");
++callcount;
@ -235,10 +245,10 @@ int MPI_Send(const void *buf, int count, MPI_Datatype datatype,
/* ---------------------------------------------------------------------- */
int MPI_Isend(const void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Request *request)
int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int source,
int tag, MPI_Comm comm, MPI_Request *request)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not send message to self\n");
++callcount;
@ -248,10 +258,10 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype datatype,
/* ---------------------------------------------------------------------- */
int MPI_Rsend(const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm)
int MPI_Rsend(const void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not rsend message to self\n");
++callcount;
@ -261,10 +271,10 @@ int MPI_Rsend(const void *buf, int count, MPI_Datatype datatype,
/* ---------------------------------------------------------------------- */
int MPI_Recv(void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Status *status)
int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
MPI_Comm comm, MPI_Status *status)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not recv message from self\n");
++callcount;
@ -274,10 +284,10 @@ int MPI_Recv(void *buf, int count, MPI_Datatype datatype,
/* ---------------------------------------------------------------------- */
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Request *request)
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
MPI_Comm comm, MPI_Request *request)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not recv message from self\n");
++callcount;
@ -289,7 +299,7 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
int MPI_Wait(MPI_Request *request, MPI_Status *status)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not wait on message from self\n");
++callcount;
@ -301,7 +311,7 @@ int MPI_Wait(MPI_Request *request, MPI_Status *status)
int MPI_Waitall(int n, MPI_Request *request, MPI_Status *status)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not wait on message from self\n");
++callcount;
@ -311,10 +321,9 @@ int MPI_Waitall(int n, MPI_Request *request, MPI_Status *status)
/* ---------------------------------------------------------------------- */
int MPI_Waitany(int count, MPI_Request *request, int *index,
MPI_Status *status)
int MPI_Waitany(int count, MPI_Request *request, int *index, MPI_Status *status)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not wait on message from self\n");
++callcount;
@ -324,12 +333,11 @@ int MPI_Waitany(int count, MPI_Request *request, int *index,
/* ---------------------------------------------------------------------- */
int MPI_Sendrecv(const void *sbuf, int scount, MPI_Datatype sdatatype,
int dest, int stag, void *rbuf, int rcount,
MPI_Datatype rdatatype, int source, int rtag,
MPI_Comm comm, MPI_Status *status)
int MPI_Sendrecv(const void *sbuf, int scount, MPI_Datatype sdatatype, int dest,
int stag, void *rbuf, int rcount, MPI_Datatype rdatatype,
int source, int rtag, MPI_Comm comm, MPI_Status *status)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not send message to self\n");
++callcount;
@ -341,7 +349,7 @@ int MPI_Sendrecv(const void *sbuf, int scount, MPI_Datatype sdatatype,
int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count)
{
static int callcount=0;
static int callcount = 0;
if (callcount == 0) {
printf("MPI Stub WARNING: Should not get count of message to self\n");
++callcount;
@ -353,7 +361,7 @@ int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count)
int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out)
{
*comm_out = comm+1;
*comm_out = comm + 1;
return 0;
}
@ -361,47 +369,56 @@ int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out)
int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *comm_out)
{
*comm_out = comm+1;
*comm_out = comm + 1;
return 0;
}
/* ---------------------------------------------------------------------- */
int MPI_Comm_free(MPI_Comm *comm) {return 0;}
int MPI_Comm_free(MPI_Comm *comm)
{
return 0;
}
/* ---------------------------------------------------------------------- */
MPI_Fint MPI_Comm_c2f(MPI_Comm comm) { return comm; };
MPI_Fint MPI_Comm_c2f(MPI_Comm comm)
{
return comm;
};
/* ---------------------------------------------------------------------- */
MPI_Comm MPI_Comm_f2c(MPI_Fint comm) { return comm; };
MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
{
return comm;
};
/* ---------------------------------------------------------------------- */
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)
{
*group = comm;
return 0;
*group = comm;
return 0;
}
/* ---------------------------------------------------------------------- */
int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm)
{
*newcomm = group;
return 0;
*newcomm = group;
return 0;
}
/* ---------------------------------------------------------------------- */
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup)
{
if (n > 0)
*newgroup = MPI_COMM_WORLD;
else
*newgroup = group;
return 0;
if (n > 0)
*newgroup = MPI_COMM_WORLD;
else
*newgroup = group;
return 0;
}
/* ---------------------------------------------------------------------- */
@ -425,8 +442,8 @@ int MPI_Cart_get(MPI_Comm comm, int maxdims, int *dims, int *periods,
/* ---------------------------------------------------------------------- */
int MPI_Cart_shift(MPI_Comm comm, int direction, int displ,
int *source, int *dest)
int MPI_Cart_shift(MPI_Comm comm, int direction, int displ, int *source,
int *dest)
{
*source = *dest = 0;
return 0;
@ -444,8 +461,7 @@ int MPI_Cart_rank(MPI_Comm comm, int *coords, int *rank)
/* store size of user datatype in extra lists */
int MPI_Type_contiguous(int count, MPI_Datatype oldtype,
MPI_Datatype *newtype)
int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype)
{
if (nextra_datatype == MAXEXTRA_DATATYPE) return -1;
ptr_datatype[nextra_datatype] = newtype;
@ -477,9 +493,9 @@ int MPI_Type_free(MPI_Datatype *datatype)
int i;
for (i = 0; i < nextra_datatype; i++)
if (datatype == ptr_datatype[i]) {
ptr_datatype[i] = ptr_datatype[nextra_datatype-1];
index_datatype[i] = index_datatype[nextra_datatype-1];
size_datatype[i] = size_datatype[nextra_datatype-1];
ptr_datatype[i] = ptr_datatype[nextra_datatype - 1];
index_datatype[i] = index_datatype[nextra_datatype - 1];
size_datatype[i] = size_datatype[nextra_datatype - 1];
nextra_datatype--;
break;
}
@ -502,12 +518,18 @@ int MPI_Op_free(MPI_Op *op)
/* ---------------------------------------------------------------------- */
int MPI_Barrier(MPI_Comm comm) {return 0;}
int MPI_Barrier(MPI_Comm comm)
{
return 0;
}
/* ---------------------------------------------------------------------- */
int MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
int root, MPI_Comm comm) {return 0;}
int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root,
MPI_Comm comm)
{
return 0;
}
/* ---------------------------------------------------------------------- */
@ -519,7 +541,7 @@ int MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
int n = count * stubtypesize(datatype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -527,27 +549,25 @@ int MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
/* copy values from data1 to data2 */
int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op,
int root, MPI_Comm comm)
int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
MPI_Op op, int root, MPI_Comm comm)
{
int n = count * stubtypesize(datatype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
/* ---------------------------------------------------------------------- */
int MPI_Scan(void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
int MPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
MPI_Op op, MPI_Comm comm)
{
int n = count * stubtypesize(datatype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -562,7 +582,7 @@ int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
int n = sendcount * stubtypesize(sendtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -577,7 +597,7 @@ int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
int n = sendcount * stubtypesize(sendtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -591,7 +611,7 @@ int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
int n = *recvcounts * stubtypesize(datatype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -600,13 +620,13 @@ int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
/* copy values from data1 to data2 */
int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm)
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm)
{
int n = sendcount * stubtypesize(sendtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -621,7 +641,7 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
int n = sendcount * stubtypesize(sendtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -630,17 +650,16 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
/* copy values from data1 to data2 */
int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm)
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm)
{
int n = recvcount * stubtypesize(recvtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
/* ---------------------------------------------------------------------- */
/* copy values from data1 to data2 */
@ -652,7 +671,7 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
int n = recvcount * stubtypesize(recvtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -667,7 +686,7 @@ int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
int n = sendcount * stubtypesize(sendtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}
@ -676,14 +695,13 @@ int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
/* copy values from data1 to data2 */
int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls,
MPI_Datatype sendtype,
void *recvbuf, int *recvcounts, int *rdispls,
MPI_Datatype recvtype, MPI_Comm comm)
MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
int *rdispls, MPI_Datatype recvtype, MPI_Comm comm)
{
int n = *sendcounts * stubtypesize(sendtype);
if (sendbuf == MPI_IN_PLACE || recvbuf == MPI_IN_PLACE) return 0;
memcpy(recvbuf,sendbuf,n);
memcpy(recvbuf, sendbuf, n);
return 0;
}