Skip to content

Commit 8b8b44f

Browse files
committed
leader: fix write and read offset bug
1 parent 8a4063b commit 8b8b44f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/network/leader.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void execute_read(struct leader_resources *l_r) {
303303
// compute local address to write
304304
size_t local_address = 0;
305305
if (b->virtual_address == to_write_address_v) {
306-
local_address = 0;
306+
local_address = b->node_address;
307307
to_write_address_v += to_read_size;
308308
} else {
309309
local_address += to_write_address_v - b->virtual_address;
@@ -318,7 +318,7 @@ void execute_read(struct leader_resources *l_r) {
318318
void *buff = malloc(sizeof(char) * (to_read_size + 1));
319319
MPI_Status st;
320320
MPI_Recv(buff, to_read_size, MPI_BYTE, b->id, 4, MPI_COMM_WORLD, &st);
321-
memcpy((void*)(read_buff + (offset * sizeof(char))), buff, to_read_size);
321+
memcpy((void *) (read_buff + (offset * sizeof(char))), buff, to_read_size);
322322
offset += to_read_size;
323323
nb_read++;
324324
free(m);
@@ -365,7 +365,7 @@ void execute_write(struct leader_resources *l_r) {
365365
// compute local address to write
366366
size_t local_address = 0;
367367
if (b->virtual_address == to_write_address_v) {
368-
local_address = 0;
368+
local_address = b->node_address;
369369
to_write_address_v += to_write_size;
370370
} else {
371371
local_address += to_write_address_v - b->virtual_address;
@@ -383,7 +383,7 @@ void execute_write(struct leader_resources *l_r) {
383383
MPI_Recv(&m2, sizeof(struct message), MPI_BYTE, b->id, 3, MPI_COMM_WORLD, &st);
384384
debug("Send Data", l_r->id);
385385
// debug_n(d_w->data, l_r->id, d_w->size);
386-
MPI_Send((void*)((char*)d_w->data + offset), to_write_size, MPI_BYTE, b->id, 4, MPI_COMM_WORLD);
386+
MPI_Send((void *) ((char *) d_w->data + offset), to_write_size, MPI_BYTE, b->id, 4, MPI_COMM_WORLD);
387387
offset += to_write_size;
388388
}
389389

0 commit comments

Comments
 (0)