Skip to content

Commit

Permalink
Merge pull request #24 from mjbach/fallocate
Browse files Browse the repository at this point in the history
Addresses #23 and #18
  • Loading branch information
mjbach authored Aug 28, 2018
2 parents d7ed221 + 6c2872f commit 0998576
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion file_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ off_t file_tree_write(struct file_entry* file, lcio_job_t* job){
int count = 0;
err = malloc(sizeof(int));

fd = (int*) job->ioengine->open(file->fname, job);
fd = (int*) job->ioengine->create(file->fname, job);
if(*fd<0) {
perror("open");
fprintf(stderr,"fname %s\n", file->fname);
Expand Down
8 changes: 8 additions & 0 deletions lib/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@ void *posix_write(void *fdes, lcio_job_t *job, off_t flag) {

if(job->ftrunc){
if(flag == 0) {
#ifdef HAVE_POSIX_FALLOCATE
*rv = posix_fallocate(*(int*) fdes, job->blk_sz);
#else
*rv = ftruncate(*(int*) fdes, job->blk_sz);
#endif
if(*rv > -1) *rv = (ssize_t) job->blk_sz;
}
else {
#ifdef HAVE_POSIX_FALLOCATE
*rv = posix_fallocate(*(int*)fdes, flag);
#else
*rv = ftruncate(*(int*)fdes, flag);
#endif
if(*rv > -1) *rv = (ssize_t) flag;
}
return rv;
Expand Down
28 changes: 17 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ void check_config(lcio_param_t* params, int size){


int main(int argc, char** argv) {

MPI_Init(&argc, &argv);

int world_rank;
int my_rank;
int grp_sz;
int world_sz;
int err = 0;
int color = MPI_UNDEFINED;
int i, j, res;
MPI_Comm world_comm;
Expand Down Expand Up @@ -131,7 +133,7 @@ int main(int argc, char** argv) {
* and do not need to be broadcast. See lcio.h:[60-77]
*/
const int count = 14;
int blens[14] = {32,16,8,1,1,1,1,1,1,1,1,1,1};
int blens[14] = {128,16,8,1,1,1,1,1,1,1,1,1,1};
MPI_Datatype array_of_types[14] =
{MPI_CHAR, MPI_CHAR, MPI_CHAR,
MPI_INT, MPI_INT,
Expand All @@ -143,7 +145,7 @@ int main(int argc, char** argv) {

/* displacements in struct */
disps[0] = (MPI_Aint) 0; //tmp_dir
disps[1] = cextent * 64; //type
disps[1] = cextent * 128; //type
disps[2] = disps[1] + (cextent * 16); //engine
disps[3] = disps[2] + (cextent * 8); //num_pes
disps[4] = disps[3] + iextent; //num_files
Expand Down Expand Up @@ -199,30 +201,34 @@ int main(int argc, char** argv) {
perror("fopen");
fprintf(stderr, "Configuration file not found.\n"
"Did you specify --config?\n");
MPI_Abort(world_comm, 1);
exit(1);
err = 1;
}
params = fill_parameters(cfg);

check_config(params, world_sz);
//print_cfg(cfg);
if(err != 1) {
params = fill_parameters(cfg);

check_config(params, world_sz);
}

dist_cfg = parse_conf_file(opts->dist_fname);
if(dist_cfg == NULL){
perror("fopen");
fprintf(stderr, "Distribution file not found.\n"
"Did you specify --dist?\n");
MPI_Abort(world_comm, 1);
exit(1);
err = 1;
}
dist = fill_dist(dist_cfg);
if (err != 1) dist = fill_dist(dist_cfg);
//print_cfg(dist_cfg);
} else {
params = malloc(sizeof(lcio_param_t));
dist = malloc(sizeof(lcio_dist_t));
}

MPI_Bcast(&err, 1, MPI_INT, 0, world_comm);
if(err == 1){
MPI_Finalize();
exit(0);
}

/*
* sorta nasty but other, more slick methods kept giving
* me segfaults. Likely due to how the MPI_datatype isn't
Expand Down

0 comments on commit 0998576

Please sign in to comment.