Skip to content

Commit 54ce12c

Browse files
committed
working on bulk transfer all
1 parent ce83ba7 commit 54ce12c

File tree

8 files changed

+76
-27
lines changed

8 files changed

+76
-27
lines changed

run_client.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
pushd ./build/bin || exit 1 # Exit if cd fails
66
export PDC_DEBUG=1
7-
"./region_transfer_2D_partial"
7+
#"./region_transfer_all_append"
8+
"./sandbox"
89
popd
910

run_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ echo "deleting existing data"
1111
rm -rf /home/nlewi26/src/work_space/source/pdc/build/bin/pdc_data
1212

1313
pushd ./build
14-
ctest -L serial
14+
#ctest -L serial --stop-on-failure --output-on-failure
15+
ctest -L serial -I 1,37 -I 39,68
1516
popd

src/server/include/pdc_client_server_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ typedef struct data_server_region_t {
338338
// Used primarily as a local_temp
339339
void *obj_data_ptr;
340340
// FIXME: (Noah) we should dynamically allocate this number....
341-
char * storage_location[1024]; // save the file location to enable reopening
341+
char * storage_location[4096]; // save the file location to enable reopening
342342
// number of elements per region
343343
int region_size_elements;
344344
struct data_server_region_t *prev;

src/server/pdc_server_region/pdc_server_data.c

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <math.h>
3838
#include <sys/shm.h>
3939
#include <sys/mman.h>
40+
#include <errno.h>
4041

4142
#include "pdc_config.h"
4243

@@ -126,7 +127,16 @@ static int
126127
server_open_storage(char *storage_location, pdcid_t obj_id, uint64_t region_index)
127128
{
128129
fill_storage_path(storage_location, obj_id, region_index);
129-
return open(storage_location, O_RDWR | O_CREAT, 0666);
130+
131+
errno = 0;
132+
int fd = open(storage_location, O_RDWR | O_CREAT, 0666);
133+
134+
if(fd <= 0) {
135+
LOG_ERROR("Failed to open file: %s\n", storage_location);
136+
perror("open");
137+
}
138+
139+
return fd;
130140
}
131141

132142
perr_t
@@ -395,6 +405,7 @@ PDC_Server_register_obj_region_by_pointer(data_server_region_t **new_obj_reg_ptr
395405
else {
396406
if (new_obj_reg->fd == -1) {
397407
// FIXME: (Noah)
408+
new_obj_reg->storage_location[region_index] = (char *)malloc(sizeof(char) * ADDR_MAX);
398409
fill_storage_path(new_obj_reg->storage_location[region_index], obj_id, region_index);
399410
}
400411
if (new_obj_reg->fd < 0) {
@@ -406,6 +417,8 @@ PDC_Server_register_obj_region_by_pointer(data_server_region_t **new_obj_reg_ptr
406417
// FIXME: (Noah)
407418
new_obj_reg->fd = open(new_obj_reg->storage_location[region_index], O_RDWR | O_CREAT, 0666);
408419
if (new_obj_reg->fd < 0) {
420+
LOG_ERROR("Failed to open file %s\n", new_obj_reg->storage_location[region_index]);
421+
perror("open");
409422
goto done;
410423
}
411424
}
@@ -4536,9 +4549,9 @@ PDC_Server_data_io_from_region_per_file(uint64_t obj_id, struct pdc_region_info
45364549
uint64_t *offset = region_info->offset;
45374550
int ndim = region_info->ndim;
45384551

4539-
printf("\tobj meta ndim: %d\n", ndim);
4552+
LOG_JUST_PRINT("\tobj meta ndim: %d\n", ndim);
45404553
for (int i = 0; i < ndim; i++) {
4541-
printf("\tobj meta dims[%d] = %" PRIu64 "\n", i, global_size[i]);
4554+
LOG_JUST_PRINT("\tobj meta dims[%d] = %" PRIu64 "\n", i, global_size[i]);
45424555
}
45434556

45444557
// Compute flat offset from global start
@@ -4547,25 +4560,38 @@ PDC_Server_data_io_from_region_per_file(uint64_t obj_id, struct pdc_region_info
45474560
flat_offset += offset[i] * stride;
45484561
stride *= global_size[i];
45494562
}
4563+
4564+
LOG_JUST_PRINT("\tnum_elements: %d\n", num_elements);
4565+
LOG_JUST_PRINT("\tflat_offset: %d\n", flat_offset);
45504566

45514567
// Determine initial region index
45524568
uint64_t region_index = 0;
45534569
if (region == NULL) {
4554-
region_index = 0;
4570+
region_index = flat_offset / num_elements;
45554571
} else {
4572+
if(region->region_size_elements == UNITIALIZED_DATA_SERVER_REGION_SIZE_ELEMENTS) {
4573+
region->region_size_elements = num_elements;
4574+
}
45564575
region_index = flat_offset / region->region_size_elements;
45574576
}
45584577

4578+
LOG_JUST_PRINT("\tregion_index: %d\n", region_index);
4579+
45594580
// Register the initial region
45604581
PDC_Server_register_obj_region_by_pointer(&region, obj_id, 0, region_index);
45614582

4583+
if(region->region_size_elements == UNITIALIZED_DATA_SERVER_REGION_SIZE_ELEMENTS) {
4584+
region->region_size_elements = num_elements;
4585+
}
4586+
45624587
// Allocate indices for iteration
45634588
uint64_t *indices = (uint64_t *)calloc(ndim, sizeof(uint64_t));
45644589
if (indices == NULL) {
45654590
PGOTO_ERROR(FAIL, "calloc failed for indices");
45664591
}
45674592

45684593
for (uint64_t count = 0; count < num_elements; count++) {
4594+
printf("cur count: %d\n", count);
45694595
// Compute flat index
45704596
uint64_t flat_index = 0;
45714597
uint64_t temp_stride = 1;
@@ -4577,33 +4603,40 @@ PDC_Server_data_io_from_region_per_file(uint64_t obj_id, struct pdc_region_info
45774603
// Determine region
45784604
uint64_t new_region_index = flat_index / region->region_size_elements;
45794605
if (new_region_index != region_index) {
4606+
uint64_t old_region_size = region->region_size_elements;
45804607
if (region) {
45814608
PDC_Server_unregister_obj_region_by_pointer(region, 0);
45824609
region = NULL;
45834610
}
45844611
region_index = new_region_index;
45854612
PDC_Server_register_obj_region_by_pointer(&region, obj_id, 0, region_index);
4613+
region->region_size_elements = old_region_size;
45864614
}
45874615

45884616
if (region == NULL || region->region_size_elements == 0) {
45894617
PGOTO_ERROR(FAIL, "Region not properly initialized");
45904618
}
45914619

4592-
// Compute offset within region
45934620
uint64_t offset_region = flat_index % region->region_size_elements;
45944621
void *target_buf = (char *)buf + (count * unit);
45954622
off_t file_offset = offset_region * unit;
45964623

45974624
ssize_t res;
4625+
errno = 0;
45984626
if (io_type == REGION_PER_FILE_IO_TYPE_READ) {
45994627
res = pread(region->fd, target_buf, unit, file_offset);
46004628
} else {
46014629
res = pwrite(region->fd, target_buf, unit, file_offset);
46024630
}
46034631

46044632
if (res != (ssize_t)unit) {
4633+
LOG_JUST_PRINT("expected io size %d: actual io size %d\n", unit, res);
4634+
LOG_JUST_PRINT("region size %d, region index: %d\n", region->region_size_elements, region_index);
4635+
LOG_JUST_PRINT("io error storage location: %s\n", region->storage_location[region_index]);
46054636
perror(io_type == REGION_PER_FILE_IO_TYPE_READ ? "pread" : "pwrite");
4606-
PGOTO_ERROR(FAIL, "I/O operation failed");
4637+
PGOTO_ERROR(FAIL, "I/O operation failed\n");
4638+
} else {
4639+
LOG_JUST_PRINT("io storage location: %s\n", region->storage_location[region_index]);
46074640
}
46084641

46094642
// Advance indices

src/server/pdc_server_region/pdc_server_region_request_handler.h

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ transfer_request_all_bulk_transfer_read_cb(const struct hg_cb_info *info)
7979
for (i = 0; i < request_data.n_objs; ++i) {
8080
temp_ptrs[i] = PDC_Server_get_obj_region(request_data.obj_id[i]);
8181
// FIXME: Noah
82-
if(temp_ptrs[i] == NULL) {
82+
if(temp_ptrs[i]->region_size_elements == UNITIALIZED_DATA_SERVER_REGION_SIZE_ELEMENTS) {
8383
LOG_ERROR("GOING TO GENERATE INCORRECT REGION INDEXES\n");
8484
}
8585
PDC_Server_register_obj_region_by_pointer(&(temp_ptrs[i]), request_data.obj_id[i], 1, 0);
@@ -174,11 +174,6 @@ transfer_request_all_bulk_transfer_write_cb(const struct hg_cb_info *info)
174174

175175
FUNC_ENTER(NULL);
176176

177-
#ifdef TANG_DEBUG
178-
PDC_get_time_str(cur_time);
179-
LOG_DEBUG("%s ==PDC_SERVER[%d]: enter\n", cur_time, PDC_get_rank());
180-
#endif
181-
182177
gettimeofday(&last_cache_activity_timeval_g, NULL);
183178

184179
#ifdef PDC_TIMING
@@ -197,17 +192,36 @@ transfer_request_all_bulk_transfer_write_cb(const struct hg_cb_info *info)
197192
#ifndef PDC_SERVER_CACHE
198193
data_server_region_t **temp_ptrs =
199194
(data_server_region_t **)malloc(sizeof(data_server_region_t *) * request_data.n_objs);
195+
196+
LOG_JUST_PRINT("========================REQUEST ALL INFO===============================\n");
200197
for (i = 0; i < request_data.n_objs; ++i) {
198+
LOG_JUST_PRINT("obj_id: %d\n", request_data.obj_id[i]);
199+
LOG_JUST_PRINT("\tobj ndim: %d\n", request_data.obj_ndim[i]);
200+
LOG_JUST_PRINT("\tobj unit: %d\n", request_data.unit[i]);
201+
LOG_JUST_PRINT("\tregion ndim[%d]=%d\n", i, request_data.remote_ndim[i]);
202+
for(int j = 0; j < request_data.remote_ndim[i]; j++) {
203+
LOG_JUST_PRINT("\tregion size[%d]=%d\n", j, request_data.remote_length[i][j]);
204+
LOG_JUST_PRINT("\tregion offset[%d]=%d\n", j, request_data.remote_offset[i][j]);
205+
}
206+
201207
temp_ptrs[i] = PDC_Server_get_obj_region(request_data.obj_id[i]);
208+
202209
// FIXME: Noah
203-
LOG_ERROR("\n\n\n\n NOT IMPLEMENTED \n\n\n\n\n");
204-
PDC_Server_register_obj_region_by_pointer(temp_ptrs + i, request_data.obj_id[i], 1, 0);
205-
}
206-
#endif
210+
// Compute total number of elements
211+
uint64_t num_elements = 1;
212+
// FIXME: this loops through the obj_ndim instead of the remote ndim
213+
for (int j = 0; j < request_data.obj_ndim[i]; j++) {
214+
num_elements *= request_data.remote_length[i][j];
215+
}
207216

208-
#ifdef TANG_DEBUG
209-
PDC_get_time_str(cur_time);
210-
LOG_DEBUG("%s ==PDC_SERVER[%d]: before (cache) writing\n", cur_time, PDC_get_rank());
217+
if(temp_ptrs[i]->region_size_elements == UNITIALIZED_DATA_SERVER_REGION_SIZE_ELEMENTS) {
218+
temp_ptrs[i]->region_size_elements = num_elements;
219+
}
220+
221+
uint64_t region_index = num_elements / temp_ptrs[i]->region_size_elements;
222+
PDC_Server_register_obj_region_by_pointer(temp_ptrs + i, request_data.obj_id[i], 1, region_index);
223+
}
224+
LOG_JUST_PRINT("=====================================END===============================\n");
211225
#endif
212226

213227
for (i = 0; i < request_data.n_objs; ++i) {

src/server/pdc_server_region/pdc_server_region_transfer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ PDC_transfer_request_id_register()
261261
static void
262262
PDC_Server_io_not_by_region_region_per_file(char *user_specified_path, int is_write)
263263
{
264+
LOG_ERROR("\n\n\n\nUNIMPLEMENTED\n\n\n\n");
264265
}
265266

266267
perr_t

src/tests/region_transfer_2D_partial.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ main(int argc, char **argv)
182182
memset(data_read, 0, BUF_LEN);
183183

184184
LOG_INFO("Sleeping for 1 s\n");
185-
sleep(2);
186185

187186
transfer_request = PDCregion_transfer_create(data_read, PDC_READ, obj1, reg, reg_global);
188187

src/tests/region_transfer_all_append.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#include <unistd.h>
3232
#include <sys/time.h>
3333
#include "pdc.h"
34-
#define BUF_LEN 64
35-
#define OBJ_NUM 17
36-
#define REQ_SIZE 8
34+
#define BUF_LEN 2
35+
#define OBJ_NUM 1
36+
#define REQ_SIZE 2
3737

3838
int
3939
main(int argc, char **argv)
@@ -785,7 +785,7 @@ main(int argc, char **argv)
785785
if (ret_value == 0)
786786
LOG_INFO("Test succeed!\n");
787787
else
788-
LOG_ERROR("ErROR: Test failed!\n");
788+
LOG_ERROR("Test failed!\n");
789789
}
790790

791791
#ifdef ENABLE_MPI

0 commit comments

Comments
 (0)