void core_test() { core_add(); core_sub(); core_mul(); core_div(); core_defun(); }
raf_t MPI_Load_raf(char *name,MPI_Comm comm){ raf_t raf=(raf_t)RTmalloc(sizeof(struct raf_struct_s)); raf_init(raf,name); raf->blocksize=65536; MPI_File f; MPI_Comm_size(comm,&(raf->workers)); MPI_Comm_rank(comm,&(raf->rank)); int e=MPI_File_open(comm,name,MPI_MODE_RDONLY,MPI_INFO_NULL,&f); if(e){ int i=1024; char msg[1024]; MPI_Error_string(e,msg,&i); Fatal(0,error,"err is %s\n",msg); } MPI_File_set_errhandler(f,MPI_ERRORS_ARE_FATAL); MPI_File_get_size(f,&(raf->size)); if ((raf->size)%(raf->blocksize)) Fatal(0,error,"file not multiple of block size"); if (((raf->size)/(raf->blocksize))%(raf->workers)) Fatal(0,error,"block count not multiple of worker count"); //Warning(info,"my share is %d",(raf->size)/(raf->workers)); raf->data=RTmalloc((raf->size)/(raf->workers)); if (1) { Warning(info,"using MPI_File_read_all"); MPI_Datatype ftype; MPI_Type_vector((raf->size)/(raf->blocksize),(raf->blocksize),(raf->blocksize)*(raf->workers),MPI_CHAR,&ftype); MPI_Type_commit(&ftype); MPI_File_set_view(f,(raf->blocksize)*(raf->rank),MPI_CHAR,ftype,"native",MPI_INFO_NULL); MPI_File_read_all(f,raf->data,(raf->size)/(raf->workers),MPI_CHAR,MPI_STATUS_IGNORE); MPI_File_close(&f); MPI_Type_free(&ftype); } else { Warning(info,"using MPI_File_read_at"); int blockcount=((raf->size)/(raf->blocksize))/(raf->workers); for(int i=0;i<blockcount;i++){ MPI_File_read_at(f,((i*(raf->workers)+(raf->rank))*(raf->blocksize)), (raf->data)+(i*(raf->blocksize)),(raf->blocksize),MPI_CHAR,MPI_STATUS_IGNORE); } MPI_File_close(&f); } raf->rq_tag=core_add(raf,request_service); raf->ack_tag=core_add(raf,receive_service); raf->shared.read=read_at; raf->shared.size=mpi_size; raf->shared.close=mpi_close; //Warning(info,"file loaded"); return raf; }