Skip to content

Commit

Permalink
Fix matrix binary ops for large case where int4 isn't enough (#222)
Browse files Browse the repository at this point in the history
* Fix matrix binary ops for large case where int4 isn't enough

* fix offset too

* lint
  • Loading branch information
william-dawson authored Oct 16, 2023
1 parent 52b6c8a commit c9d018c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Source/Fortran/PSMatrixModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,12 @@ RECURSIVE SUBROUTINE ConstructMatrixFromBinary_ps(this, file_name, &

!! Compute Offset
local_triplets = total_values / this%process_grid%total_processors
local_offset = local_triplets * this%process_grid%global_rank
local_offset = INT(local_triplets, KIND=NTLONG) * &
& this%process_grid%global_rank
header_size = 3 * bytes_per_int + bytes_per_long
IF (this%process_grid%global_rank .EQ. &
& this%process_grid%total_processors - 1) THEN
local_triplets = INT(total_values) - INT(local_offset)
local_triplets = INT(total_values - local_offset)
END IF
local_offset = local_offset*(bytes_per_int*2 + bytes_per_data) + &
& header_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
CALL MPI_Allgather(SIZE(merged_local_data%values), 1, MPINTINTEGER, &
& local_values_buffer, 1, MPINTINTEGER, &
& this%process_grid%within_slice_comm, ierr)
total_values = GetMatrixSize(this)

write_offset = 0
write_offset = write_offset + header_size
Expand Down Expand Up @@ -53,7 +54,6 @@
END IF
CALL MPI_File_write_at(mpi_file_handler, zero_offset, header_buffer, &
& 3, MPINTINTEGER, message_status, ierr)
total_values = SUM(local_values_buffer)
CALL MPI_File_write_at(mpi_file_handler, &
& zero_offset + bytes_per_int * 3, total_values, &
& 1, MPINTLONG, message_status, ierr)
Expand Down

0 comments on commit c9d018c

Please sign in to comment.