-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparfu_create_test_1.c
188 lines (159 loc) · 6.11 KB
/
parfu_create_test_1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
////////////////////////////////////////////////////////////////////////////////
//
// University of Illinois/NCSA Open Source License
// http://otm.illinois.edu/disclose-protect/illinois-open-source-license
//
// Parfu is copyright © 2017, The Trustees of the University of Illinois.
// All rights reserved.
//
// Parfu was developed by:
// The University of Illinois
// The National Center For Supercomputing Applications (NCSA)
// Blue Waters Science and Engineering Applications Support Team (SEAS)
// Craig P Steffen <[email protected]>
//
// https://github.com/ncsa/parfu_archive_tool
// http://www.ncsa.illinois.edu/People/csteffen/parfu/
//
// For full licnse text see the LICENSE file provided with the source
// distribution.
//
////////////////////////////////////////////////////////////////////////////////
#include <parfu_primary.h>
int main(int nargs, char *args[]){
int *total_entries=NULL;
parfu_file_fragment_entry_list_t *my_list=NULL;
parfu_file_fragment_entry_list_t *second_list=NULL;
parfu_file_fragment_entry_list_t *expanded_list=NULL;
// char *expanded_list_buffer;
// int expanded_list_buffer_size;
char *mid_buffer=NULL;
long int mid_buffer_length;
int return_exponent;
// MPI_File *archive_file_MPI=NULL;
// MPI_Status my_MPI_Status;
// MPI_Info my_Info;
// MPI_File target_file_ptr=NULL;
int is_cat_test=0;
char my_command='X';
int valid_command=0;
char *command_argument;
char *directory_argument;
char *archive_file_name;
// MPI stuff
int n_ranks;
int my_rank;
if(nargs < 3){
fprintf(stderr,"\n\n");
fprintf(stderr,"usage:\n");
fprintf(stderr," parfu_create_test_1 <command> <target_dir> <archive1>.pfu [<archive2>.pfu]\n");
fprintf(stderr," <command> sets up what we're going to do. Valid commands are:\n");
fprintf(stderr," \"cat\" catalog test.\n");
fprintf(stderr," <target_dir> is the directory to scan.\n");
fprintf(stderr," files from target dir will be stored in the specified *.pfu archive\n");
fprintf(stderr," one .pfu is required for archiving; additional archive files are optional.\n");
fprintf(stderr,"\n\n");
return 1;
}
command_argument=args[1];
directory_argument=args[2];
archive_file_name=args[3];
total_entries=malloc(sizeof(int));
if(!strcmp(command_argument,"cat")){
fprintf(stderr,"Command: catalog test.\n");
is_cat_test=1;
valid_command=1;
}
if(!strcmp(command_argument,"C")){
my_command='C';
valid_command=1;
}
if(!valid_command){
fprintf(stderr,"The command %s is not valid. Run this program with no arguments\n",
command_argument);
fprintf(stderr," for a list of valid commands.\n");
return 1;
}
if(is_cat_test){
fprintf(stderr,"About to build directory from: %s\n",directory_argument);
fprintf(stderr," and data will be archived in file %s\n",archive_file_name);
if((my_list=parfu_build_file_list_from_directory(directory_argument,0,total_entries))==NULL){
fprintf(stderr,"There was an error in parfu_build_file_list_from_directory!!!\n");
return 1;
}
fprintf(stderr,"Successfully built directory listing from >%s< with %d entries.\n",
directory_argument,*total_entries);
parfu_dump_fragment_entry_list(my_list,stderr);
fprintf(stderr,"now sort:\n");
parfu_qsort_entry_list(my_list);
parfu_dump_fragment_entry_list(my_list,stderr);
if((mid_buffer=parfu_fragment_list_to_buffer(my_list,
&mid_buffer_length,
PARFU_DEFAULT_MAX_BLOCK_SIZE_EXPONENT,
0))
==NULL){
fprintf(stderr,"help! failed to write stuff to buffer!!!\n");
return 1;
}
fprintf(stderr,"\n\n *********\n\n");
fprintf(stderr,"%s",mid_buffer);
fprintf(stderr,"\n\n *********\n\n");
fprintf(stderr,"about to create second list structure.\n");
if((second_list=parfu_buffer_to_file_fragment_list(mid_buffer,
&return_exponent,
0))
==NULL){
fprintf(stderr,"bummer. failed to read buffer back into structure.\n");
return 1;
}
fprintf(stderr,"now dumping new list that was populated from the buffer:\n");
parfu_dump_fragment_entry_list(second_list,stderr);
fprintf(stderr,"creating expanded list:\n");
if((expanded_list=parfu_split_fragments_in_list(my_list,
PARFU_DEFAULT_MIN_BLOCK_SIZE_EXPONENT,
PARFU_DEFAULT_MAX_BLOCK_SIZE_EXPONENT,
15))
==NULL){
fprintf(stderr,"function parfu_split_fragments_in_list() returned NULL!\n");
return 1;
}
fprintf(stderr,"Now dump the expanded list:\n");
fprintf(stderr," list should hvae %d entries.\n",expanded_list->n_entries_full);
parfu_dump_fragment_entry_list(expanded_list,stderr);
fprintf(stderr,"check offsets:\n");
parfu_check_offsets(expanded_list,stderr);
fprintf(stderr,"cat test doesn't do MPI stuff. Program ends.\n");
return 0;
}
// Any single node tests have happened above and exited cleanly
// so now we're safe to begin MPI initialization
MPI_Init(NULL,NULL);
MPI_Comm_size(MPI_COMM_WORLD,&n_ranks);
MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
if(my_command == 'C'){
if(my_rank==0)fprintf(stderr,"Command: Create archive.\n");
if(my_rank==0){
if((my_list=parfu_build_file_list_from_directory(directory_argument,0,total_entries))==NULL){
fprintf(stderr,"There was an error in parfu_build_file_list_from_directory!!!\n");
return 1;
}
fprintf(stderr,"Successfully built directory listing from >%s< with %d entries.\n",
directory_argument,*total_entries);
parfu_qsort_entry_list(my_list);
}
if(parfu_archive_1file_singFP(my_list,archive_file_name,
n_ranks,my_rank,
PARFU_DEFAULT_MAX_BLOCK_SIZE_EXPONENT,
536870912,
PARFU_DEFAULT_BLOCKS_PER_FRAGMENT)){
fprintf(stderr,"function parfu_archive_1file_singFP failed!!!\n");
fprintf(stderr,"exiting.\n");
return 1;
}
MPI_Barrier(MPI_COMM_WORLD);
if(my_rank==0) fprintf(stderr,"got past parfu_archive_1file_singFP()!\n");
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}