14 #define _XOPEN_SOURCE 700
24 #include <sys/types.h>
31 #include "sion_error_handler.h"
40 int _sion_generic_collective_process_write_merge(
const void *data, sion_int64 *spec,
int sid );
44 #define DFUNCTION "_sion_coll_fwrite_merge"
45 size_t _sion_coll_fwrite_merge(
const void *data,
size_t size,
size_t nitems,
int sid) {
49 sion_int64 bwrote=0, spec[2];
50 int rc_own=SION_STD_SUCCESS,rc_cb=SION_STD_SUCCESS;
51 int collector, firstsender, lastsender;
54 return(_sion_errorprint(SION_SIZE_NOT_VALID,_SION_ERROR_RETURN,
"sion_coll_fwrite: invalid sion_filedesc %d", sid));
56 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"enter usecoll=%d collector=%d collsize=%d (%d tasks, %d files)\n",
59 sion_gendata=sion_filedesc->
dataptr;
60 sion_apidesc=sion_gendata->apidesc;
67 return(_sion_errorprint(SION_SIZE_NOT_VALID,_SION_ERROR_RETURN,
"sion_coll_fwrite: collsize=%d <= 0, returning ...\n", (
int) sion_filedesc->
collsize));
72 firstsender=collector+1;
73 lastsender=sion_filedesc->
rank+sion_filedesc->
collsize-1;
74 if(lastsender>sion_filedesc->
ntasks) lastsender=sion_filedesc->
ntasks-1;
81 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"COLLECTOR write data of size %ld at current position\n", (
long) spec[1]));
82 rc_own=_sion_generic_collective_process_write_merge(data,spec,sid);
84 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"SENDER send data of size %ld at current position\n", (
long) spec[1]));
89 if(!sion_apidesc->gather_execute_cb ) {
90 return(_sion_errorprint(SION_SIZE_NOT_VALID,_SION_ERROR_RETURN,
"sion_coll_fwrite: API %s not correctly initalized, collective I/O calls missing, aborting",sion_apidesc->name));
92 rc_cb=sion_apidesc->gather_execute_cb(data,spec,2, sion_filedesc->
fsblksize,
93 sion_gendata->comm_data_local,collector,firstsender,lastsender,sid,
94 _sion_generic_collective_process_write_merge);
97 if( (rc_own == SION_STD_SUCCESS) && (rc_cb == SION_STD_SUCCESS) ) {
103 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"leave usecoll=%d collector=%d collsize=%d (%d tasks, %d files) rc=%d\n",
111 #define DFUNCTION "_sion_generic_collective_process_write_merge"
112 int _sion_generic_collective_process_write_merge(
const void *data, sion_int64 *spec,
int sid ) {
114 int rc=SION_STD_SUCCESS;
115 sion_int64 bwrote=0, bytestowrite;
117 return(_sion_errorprint(SION_SIZE_NOT_VALID,_SION_ERROR_RETURN,
"_sion_generic_collective_process_write: invalid sion_filedesc %d", sid));
119 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"enter spec[0]=%d spec[1]=%d sid=%d\n", (
int) spec[0],(
int) spec[1],sid));
122 bytestowrite=spec[1];
126 _sion_errorprint(SION_SIZE_NOT_VALID,_SION_ERROR_RETURN,
"could not ensure free space for this block, returning %d ...\n", sid);
130 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"collector start to write data of size %lld at position %lld\n",
131 (
long long) bytestowrite, (
long long) sion_filedesc->
currentpos));
133 if(bwrote != bytestowrite) {
134 return(_sion_errorprint(SION_STD_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_generic_collective_process_write: problems writing data ...\n"));
139 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"collector wrote data block (bwrote=%d) of size %ld new pos %lld, %lld\n",
143 DPRINTFP((4, DFUNCTION, _SION_DEFAULT_RANK,
"leave spec[0]=%d spec[1]=%d sid=%d rc=%d\n", (
int) spec[0],(
int) spec[1],sid,rc));
int sion_ensure_free_space(int sid, sion_int64 bytes)
Funtion to ensure that enough space is available for writing.
void * _sion_vcdtovcon(int sid)
int _sion_vcdtype(int sid)
#define SION_FILEDESCRIPTOR
sion_int64 _sion_file_get_position(_sion_fileptr *sion_fileptr)
Get new position in file.
sion_int64 _sion_file_write(const void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Write data to file.
Sion File Descriptor Structure.