#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mpi.h>
#include <ve_offload.h>
static struct veo_proc_handle *veo_proc_handle = NULL;
#define MAX_LEN (1024*1024)
int
main()
{
int myrank;
int nprocs;
int nelems = MAX_LEN;
MPI_Init( 0, 0 );
MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
printf( "myrank = %d, nprocs = %d, started\n", myrank, nprocs );
fflush( stdout );
int venode = 0;
printf( "myrank = %d, nprocs = %d, proc = %16p, created\n", myrank, nprocs, proc );
if ( handle ) {
printf( "myrank = %d, nprocs = %d, handle = %16p, VE code loaded\n", myrank, nprocs, handle );
}
else {
printf( "myrank = %d, nprocs = %d, handle = %16p, VE code not loaded\n", myrank, nprocs, handle );
exit(1);
}
void *vebuf;
if (ret != 0) {
fprintf(stderr, "veo_alloc_hmem failed: %d", ret);
exit(1);
}
printf( "myrank = %d, nprocs = %d, vebuf = %16p, allocated\n", myrank, nprocs, vebuf );
uint64_t rc;
uint64_t id;
if (ret != 0) {
fprintf(stderr, "veo_args_set_hmem failed: %d", ret);
exit(1);
}
printf( "myrank = %d, nprocs = %d, id = %lu, rc=%p, VE offload\n", myrank, nprocs, id, rc );
int peer = myrank^1;
if ( peer >= nprocs ) peer = MPI_PROC_NULL;
if (ret != 0) {
fprintf(stderr, "veo_args_set_hmem failed: %d", ret);
exit(1);
}
printf( "myrank = %d, nprocs = %d, id = %lu, rc=%lu, VE offload\n", myrank, nprocs, id, rc );
MPI_Status status;
MPI_Barrier(MPI_COMM_WORLD);
if ( myrank%2 == 0) {
MPI_Send((void *)vebuf, MAX_LEN, MPI_INT, peer, 0, MPI_COMM_WORLD);
}
else {
MPI_Recv((void *)vebuf, MAX_LEN, MPI_INT, peer, 0, MPI_COMM_WORLD, &status );
}
MPI_Barrier(MPI_COMM_WORLD);
if (ret != 0) {
fprintf(stderr, "veo_args_set_hmem failed: %d", ret);
exit(1);
}
printf( "myrank = %d, nprocs = %d, id = %lu, rc=%lu, VE offload\n", myrank, nprocs, id, rc );
uint64_t result;
MPI_Reduce( &rc, &result, 1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD );
if ( myrank == 0 ) {
printf( "Result : %s\n", result ? "Failed" : "Success" );
fflush( stdout );
}
MPI_Finalize();
return 0;
}