Blame test/mpi/rma/large-small-acc.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2015 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
/* This code tests the case when a large ACC is issued, and then
Packit 0848f5
 * several small ACCs is issued between the same origin and target.
Packit 0848f5
 * The purpose of this test is to check if the ordering of ACCs
Packit 0848f5
 * is guaranteed. */
Packit 0848f5
Packit 0848f5
#include "mpi.h"
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include <stdint.h>
Packit 0848f5
Packit 0848f5
#define LOOP 5
Packit 0848f5
#define DATA_COUNT 8192
Packit 0848f5
Packit 0848f5
int main(int argc, char *argv[])
Packit 0848f5
{
Packit 0848f5
    int rank, nprocs;
Packit 0848f5
    MPI_Win win;
Packit 0848f5
    uint64_t buf[DATA_COUNT], orig_buf[DATA_COUNT];
Packit 0848f5
    uint64_t small_orig_buf_1 = 2, small_orig_buf_2[2] = { 3, 3 };
Packit 0848f5
    int i, j, error = 0;
Packit 0848f5
Packit 0848f5
    MPI_Init(&argc, &argv);
Packit 0848f5
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
Packit 0848f5
    MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
Packit 0848f5
Packit 0848f5
    for (j = 0; j < LOOP; j++) {
Packit 0848f5
Packit 0848f5
        error = 0;
Packit 0848f5
Packit 0848f5
        for (i = 0; i < DATA_COUNT; i++) {
Packit 0848f5
            buf[i] = 0;
Packit 0848f5
            orig_buf[i] = 1;
Packit 0848f5
        }
Packit 0848f5
Packit 0848f5
        MPI_Win_create(buf, sizeof(uint64_t) * DATA_COUNT, sizeof(uint64_t),
Packit 0848f5
                       MPI_INFO_NULL, MPI_COMM_WORLD, &win);
Packit 0848f5
Packit 0848f5
        MPI_Win_fence(0, win);
Packit 0848f5
Packit 0848f5
        if (rank == 0) {
Packit 0848f5
            /* ACC (atomic PUT) to win_buf[0...DATA_COUNT-1] */
Packit 0848f5
            MPI_Accumulate(orig_buf, DATA_COUNT, MPI_UINT64_T, 1, 0, DATA_COUNT, MPI_UINT64_T,
Packit 0848f5
                           MPI_REPLACE, win);
Packit 0848f5
            /* ACC (atomic PUT) to win_buf[0] */
Packit 0848f5
            MPI_Accumulate(&small_orig_buf_1, 1, MPI_UINT64_T, 1, 0, 1, MPI_UINT64_T, MPI_REPLACE,
Packit 0848f5
                           win);
Packit 0848f5
            /* ACC (atomic PUT) to win_buf[1,2] */
Packit 0848f5
            MPI_Accumulate(&small_orig_buf_2, 2, MPI_UINT64_T, 1, 1, 2, MPI_UINT64_T, MPI_REPLACE,
Packit 0848f5
                           win);
Packit 0848f5
        }
Packit 0848f5
Packit 0848f5
        MPI_Win_fence(0, win);
Packit 0848f5
Packit 0848f5
        if (rank == 1) {
Packit 0848f5
            for (i = 0; i < DATA_COUNT; i++) {
Packit 0848f5
                if (i == 0) {
Packit 0848f5
                    if (buf[i] != 2) {
Packit 0848f5
                        error++;
Packit 0848f5
                    }
Packit 0848f5
                }
Packit 0848f5
                else if (i == 1 || i == 2) {
Packit 0848f5
                    if (buf[i] != 3) {
Packit 0848f5
                        error++;
Packit 0848f5
                    }
Packit 0848f5
                }
Packit 0848f5
                else {
Packit 0848f5
                    if (buf[i] != 1) {
Packit 0848f5
                        error++;
Packit 0848f5
                    }
Packit 0848f5
                }
Packit 0848f5
            }
Packit 0848f5
        }
Packit 0848f5
Packit 0848f5
        MPI_Win_free(&win);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    if (rank == 1 && error == 0) {
Packit 0848f5
        printf(" No Errors\n");
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
    return 0;
Packit 0848f5
}