static inline void _sanity_check_idx(int idx)
{
- xbt_assert(idx >= 0, "dynar idx(=%d) < 0", (int) (idx));
+ xbt_assert(idx >= 0, "dynar idx(=%d) < 0", idx);
}
static inline void _check_inbound_idx(xbt_dynar_t dynar, int idx)
{
- if (idx < 0 || idx >= (int)dynar->used) {
+ if (idx < 0 || idx >= static_cast<int>(dynar->used)) {
THROWF(bound_error, idx, "dynar is not that long. You asked %d, but it's only %lu long",
- (int) (idx), (unsigned long) dynar->used);
+ idx, static_cast<unsigned long>(dynar->used));
}
}
unsigned long offset;
unsigned long cur;
- if (!n) return;
+ if (!n)
+ return;
_sanity_check_dynar(dynar);
_check_inbound_idx(dynar, idx);
++i;
} else {
if (colori == 0) {
- elm = _xbt_dynar_elm(dynar, ++p);
+ ++p;
+ elm = _xbt_dynar_elm(dynar, p);
++i;
} else { /* colori == 2 */
- elm = _xbt_dynar_elm(dynar, --q);
+ --q;
+ elm = _xbt_dynar_elm(dynar, q);
}
if (elm != elmi) {
memcpy(tmp, elm, elmsize);
{
int i ;
int size;
- if((!d1) && (!d2)) return 0;
- if((!d1) || (!d2))
- {
+ if((!d1) && (!d2))
+ return 0;
+ if((!d1) || (!d2)) {
XBT_DEBUG("nullptr dynar d1=%p d2=%p",d1,d2);
xbt_dynar_free(&d2);
return 1;
s1 = xbt_strdup(buf);
xbt_dynar_push(d, &s1);
}
- for (int cpt = 0; cpt < NB_ELEM; cpt++) {
- snprintf(buf,1023, "%d", cpt);
- s1 = xbt_strdup(buf);
- xbt_dynar_replace(d, cpt, &s1);
- }
- for (int cpt = 0; cpt < NB_ELEM; cpt++) {
- snprintf(buf,1023, "%d", cpt);
- s1 = xbt_strdup(buf);
- xbt_dynar_replace(d, cpt, &s1);
- }
- for (int cpt = 0; cpt < NB_ELEM; cpt++) {
- snprintf(buf,1023, "%d", cpt);
- s1 = xbt_strdup(buf);
- xbt_dynar_replace(d, cpt, &s1);
+ for (int i = 0 ; i < 3 ; i++) {
+ for (int cpt = 0; cpt < NB_ELEM; cpt++) {
+ snprintf(buf,1023, "%d", cpt);
+ s1 = xbt_strdup(buf);
+ xbt_dynar_replace(d, cpt, &s1);
+ }
}
for (int cpt = 0; cpt < NB_ELEM; cpt++) {
snprintf(buf,1023, "%d", cpt);
int main(int argc, char *argv[])
{
- int rank, size;
- int i;
- int *sb;
- int *rb;
+ int rank;
+ int size;
int status;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
int count = 2;
- sb = (int *) xbt_malloc(count * sizeof(int));
- rb = (int *) xbt_malloc(count * size * sizeof(int));
+ int* sb = (int *) xbt_malloc(count * sizeof(int));
+ int* rb = (int *) xbt_malloc(count * size * sizeof(int));
- for (i = 0; i < count; ++i)
+ for (int i = 0; i < count; ++i)
sb[i] = rank * count + i;
- for (i = 0; i < count * size; ++i)
+ for (int i = 0; i < count * size; ++i)
rb[i] = 0;
printf("[%d] sndbuf=[", rank);
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
printf("%d ", sb[i]);
printf("]\n");
status = MPI_Allgather(sb, count, MPI_INT, rb, count, MPI_INT, MPI_COMM_WORLD);
printf("[%d] rcvbuf=[", rank);
- for (i = 0; i < count * size; i++)
+ for (int i = 0; i < count * size; i++)
printf("%d ", rb[i]);
printf("]\n");
fflush(stdout);
}
}
- free(sb);
- free(rb);
+ xbt_free(sb);
+ xbt_free(rb);
MPI_Finalize();
return (EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
- int i,rank, size;
- int *sb, *rb;
- int *recv_counts, *recv_disps;
- int recv_sb_size;
+ int i;
+ int rank;
+ int size;
int status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- recv_counts = (int *) xbt_malloc(size * sizeof(int));
- recv_disps = (int *) xbt_malloc(size * sizeof(int));
+ int* recv_counts = (int *) xbt_malloc(size * sizeof(int));
+ int* recv_disps = (int *) xbt_malloc(size * sizeof(int));
- recv_sb_size = 0;
+ int recv_sb_size = 0;
for (i = 0; i < size; i++) {
recv_counts[i] = i + 1;
recv_disps[i] = recv_sb_size;
recv_sb_size += i + 1;
}
- sb = (int *) xbt_malloc(recv_counts[rank] * sizeof(int));
- rb = (int *) xbt_malloc(recv_sb_size * sizeof(int));
+ int* sb = (int *) xbt_malloc(recv_counts[rank] * sizeof(int));
+ int* rb = (int *) xbt_malloc(recv_sb_size * sizeof(int));
for (i = 0; i < recv_counts[rank]; ++i)
sb[i] = recv_disps[rank] + i;
fflush(stdout);
}
}
- free(sb);
- free(rb);
- free(recv_counts);
- free(recv_disps);
+ xbt_free(sb);
+ xbt_free(rb);
+ xbt_free(recv_counts);
+ xbt_free(recv_disps);
MPI_Finalize();
return (EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
- int rank, size;
+ int rank;
+ int size;
int i;
- int *sb;
- int *rb;
int status;
int mult=1;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- if (maxlen>1)mult=size;
- sb = (int *) xbt_malloc(size *maxlen * sizeof(int));
- rb = (int *) xbt_malloc(size *maxlen * sizeof(int));
+ if (maxlen > 1)
+ mult = size;
+ int* sb = (int *) xbt_malloc(size *maxlen * sizeof(int));
+ int* rb = (int *) xbt_malloc(size *maxlen * sizeof(int));
for (i = 0; i < size *maxlen; ++i) {
sb[i] = rank*size + i;
fflush(stdout);
}
}
- free(sb);
- free(rb);
+ xbt_free(sb);
+ xbt_free(rb);
MPI_Finalize();
return (EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
- int rank, size;
+ int rank;
+ int size;
int i;
- int *sb;
- int *rb;
int status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- sb = (int *) xbt_malloc(size * sizeof(int) * 2);
- rb = (int *) xbt_malloc(size * sizeof(int) * 2);
+ int* sb = (int *) xbt_malloc(size * sizeof(int) * 2);
+ int* rb = (int *) xbt_malloc(size * sizeof(int) * 2);
for (i = 0; i < size; ++i) {
sb[i] = rank*size + i;
fflush(stdout);
}
}
- free(sb);
- free(rb);
+ xbt_free(sb);
+ xbt_free(rb);
MPI_Finalize();
return (EXIT_SUCCESS);
}
static void print_buffer_int(void *buf, int len, char *msg, int rank)
{
- int tmp, *v;
+ int* v;
printf("[%d] %s (#%d): ", rank, msg, len);
- for (tmp = 0; tmp < len; tmp++) {
+ for (int tmp = 0; tmp < len; tmp++) {
v = buf;
printf("[%d]", v[tmp]);
}
int main(int argc, char **argv)
{
MPI_Comm comm;
- int *sbuf, *rbuf;
- int i,rank, size;
+ int i;
+ int rank;
+ int size;
int *sendcounts, *recvcounts, *rdispls, *sdispls;
MPI_Init(&argc, &argv);
/* Create the buffer */
MPI_Comm_size(comm, &size);
MPI_Comm_rank(comm, &rank);
- sbuf = (int *) xbt_malloc(size * size * sizeof(int));
- rbuf = (int *) xbt_malloc(size * size * sizeof(int));
+ int* sbuf = (int *) xbt_malloc(size * size * sizeof(int));
+ int* rbuf = (int *) xbt_malloc(size * size * sizeof(int));
/* Load up the buffers */
for (i = 0; i < size * size; i++) {
int main(int argc, char **argv)
{
- int size, rank;
+ int size;
+ int rank;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
int main(int argc, char **argv)
{
- int i, size, rank;
+ int i;
+ int size;
+ int rank;
int count = 2048;
MPI_Init(&argc, &argv);
int main(int argc, char *argv[])
{
- int i, rank, size;
- int *sb, *rb;
+ int rank;
+ int size;
int status;
int root = 0;
MPI_Comm_size(MPI_COMM_WORLD, &size);
int count = 2;
- sb = (int *) xbt_malloc(count * sizeof(int));
- rb = (int *) xbt_malloc(count * size * sizeof(int));
+ int* sb = (int *) xbt_malloc(count * sizeof(int));
+ int* rb = (int *) xbt_malloc(count * size * sizeof(int));
- for (i = 0; i < count; ++i)
+ for (int i = 0; i < count; ++i)
sb[i] = rank * count + i;
- for (i = 0; i < count * size; ++i)
+ for (int i = 0; i < count * size; ++i)
rb[i] = 0;
printf("[%d] sndbuf=[", rank);
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
printf("%d ", sb[i]);
printf("]\n");
if (rank == root) {
printf("[%d] rcvbuf=[", rank);
- for (i = 0; i < count * size; i++)
+ for (int i = 0; i < count * size; i++)
printf("%d ", rb[i]);
printf("]\n");
fflush(stdout);
}
}
- free(sb);
- free(rb);
+ xbt_free(sb);
+ xbt_free(rb);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
return (EXIT_SUCCESS);
int main( int argc, char **argv )
{
- int err = 0, toterr;
- int *sendbuf, *recvbuf, *recvcounts;
- int size, rank, i, sumval;
+ int err = 0;
+ int toterr;
+ int size;
+ int rank;
+ int i;
MPI_Comm comm;
MPI_Init( &argc, &argv );
MPI_Comm_size( comm, &size );
MPI_Comm_rank( comm, &rank );
- sendbuf = (int *) malloc( size * sizeof(int) );
+ int* sendbuf = (int *) malloc( size * sizeof(int) );
for (i=0; i<size; i++)
sendbuf[i] = rank + i;
- recvcounts = (int *)malloc( size * sizeof(int) );
- recvbuf = (int *)malloc( size * sizeof(int) );
+ int* recvcounts = (int*) malloc (size * sizeof(int));
+ int* recvbuf = (int*) malloc (size * sizeof(int));
for (i=0; i<size; i++)
recvcounts[i] = 1;
MPI_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm );
- sumval = size * rank + ((size - 1) * size)/2;
+ int sumval = size * rank + ((size - 1) * size)/2;
/* recvbuf should be size * (rank + i) */
if (recvbuf[0] != sumval) {
err++;
int main(int argc, char *argv[])
{
- int rank, size;
+ int rank;
+ int size;
int i;
- unsigned long long *sb;
- unsigned long long *rb;
int status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- sb = (unsigned long long *) xbt_malloc(size * sizeof(unsigned long long));
- rb = (unsigned long long *) xbt_malloc(size * sizeof(unsigned long long));
+ unsigned long long* sb = (unsigned long long *) xbt_malloc(size * sizeof(unsigned long long));
+ unsigned long long* rb = (unsigned long long *) xbt_malloc(size * sizeof(unsigned long long));
for (i = 0; i < size; ++i) {
sb[i] = rank*size + i;
int main(int argc, char **argv)
{
- int size, rank;
+ int size;
+ int rank;
int success = 1;
int retval;
int sendcount = 1; // one double to each process