Skip to content

Commit

Permalink
New introspection methods
Browse files Browse the repository at this point in the history
o Back out bml_get_ptr_dense() from bml_getters
o Write fortran wrapper for existing bml_get_data_ptr_dense() method
o Write new bml_get_ld_dense() to enable magma matrix pointer use
  • Loading branch information
mewall committed Jan 14, 2025
1 parent 84be6e9 commit 559bc8e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 19 deletions.
7 changes: 0 additions & 7 deletions src/C-interface/dense/bml_getters_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,3 @@ bml_get_diagonal_dense(
}
return NULL;
}

void *
bml_get_ptr_dense(
bml_matrix_dense_t * A)
{
return (void *)A->matrix;
}
19 changes: 19 additions & 0 deletions src/C-interface/dense/bml_introspection_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,22 @@ bml_get_data_ptr_dense(
{
return A->matrix;
}

/** Return the dense matrix ld parameter.
*
* \param A The dense matrix.
* \return The matrix ld parameter.
*/
int
bml_get_ld_dense(
bml_matrix_dense_t * A)
{
if (A != NULL)
{
return A->ld;
}
else
{
return -1;
}
}
12 changes: 9 additions & 3 deletions src/Fortran-interface/bml_c_interface_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,17 @@ function bml_get_bandwidth_C(a) bind(C, name="bml_get_bandwidth")
integer(C_INT) :: bml_get_bandwidth_C
end function bml_get_bandwidth_C

function bml_get_ptr_dense_C(a) bind(C, name="bml_get_ptr_dense")
function bml_get_data_ptr_dense_C(a) bind(C, name="bml_get_data_ptr_dense")
import :: C_PTR
type(C_PTR), value, intent(in) :: a
type(C_PTR) :: bml_get_ptr_dense_C
end function bml_get_ptr_dense_C
type(C_PTR) :: bml_get_data_ptr_dense_C
end function bml_get_data_ptr_dense_C

function bml_get_ld_dense_C(a) bind(C, name="bml_get_ld_dense")
import :: C_PTR, C_INT
type(C_PTR), value, intent(in) :: a
integer(C_INT) :: bml_get_ld_dense_C
end function bml_get_ld_dense_C

function bml_get_sparsity_C(a, threshold) bind(C, name="bml_get_sparsity")
import :: C_PTR, C_DOUBLE, C_INT
Expand Down
10 changes: 1 addition & 9 deletions src/Fortran-interface/bml_getters_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module bml_getters_m
module procedure bml_get_diagonal_double_complex
end interface bml_get_diagonal

public :: bml_get_row, bml_get_diagonal, bml_get_ptr_dense
public :: bml_get_row, bml_get_diagonal

contains

Expand Down Expand Up @@ -189,12 +189,4 @@ subroutine bml_get_row_double_complex(a, i, row)

end subroutine bml_get_row_double_complex

function bml_get_ptr_dense(a)
type(bml_matrix_t), intent(inout) :: a
type(C_PTR) :: bml_get_ptr_dense

bml_get_ptr_dense = bml_get_ptr_dense_C(a%ptr)

end function bml_get_ptr_dense

end module bml_getters_m
23 changes: 23 additions & 0 deletions src/Fortran-interface/bml_introspection_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module bml_introspection_m
public :: bml_get_bandwidth
public :: bml_get_distribution_mode
public :: bml_get_sparsity
public :: bml_get_data_ptr_dense
public :: bml_get_ld_dense

contains

Expand Down Expand Up @@ -247,4 +249,25 @@ function bml_get_sparsity(a, threshold) result(sparsity)

end function bml_get_sparsity

function bml_get_data_ptr_dense(a)
type(bml_matrix_t), intent(inout) :: a
type(C_PTR) :: bml_get_data_ptr_dense

bml_get_data_ptr_dense = bml_get_data_ptr_dense_C(a%ptr)

end function bml_get_data_ptr_dense

!> Return the dense matrix ld parameter.
!!
!!\param a The matrix.
!!\return The matrix ld parameter.
function bml_get_ld_dense(a)

type(bml_matrix_t), intent(in) :: a
integer :: bml_get_ld_dense

bml_get_ld_dense = bml_get_ld_dense_C(a%ptr)

end function bml_get_ld_dense

end module bml_introspection_m

0 comments on commit 559bc8e

Please sign in to comment.