Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Venado optimizations #755

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
48 changes: 48 additions & 0 deletions scripts/build_bml_cray.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Make sure all the paths are correct

rm -rf build
rm -rf install_cray

MY_PATH=$(pwd)


export CC=${CC:=cc}
#export FC=${FC:=/opt/cray/pe/cce/17.0.0/bin/crayftn}
export FC=${FC:=ftn}
export CXX=${CXX:=CC}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-ef -DCRAY_SDK"}
mewall marked this conversation as resolved.
Show resolved Hide resolved
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DINTEL_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DCRAY_SDK"}
#export BLAS_VENDOR=${BLAS_VENDOR:=OpenBlas}
#export BLAS_VENDOR=${BLAS_VENDOR:=Intel10_64lp}
#export BLAS_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
#export BLAS_LIBRARIES="-L/projects/darwin-nv/rhel9/aarch64/packages/nvpl/23.11/lib -lnvpl_blas_lp64_gomp"
#export LAPACK_LIBRARIES="-L/projects/darwin-nv/rhel9/aarch64/packages/nvpl/23.11/lib -lnvpl_lapack_lp64_gomp"
export LAPACK_LIBRARIES="-L${CRAY_PE_LIBSCI_PREFIX}/lib"
export BML_OPENMP=${BML_OPENMP:=yes}
export BML_COMPLEX=${BML_COMPLEX:=no}
#export CUDA_ROOT=${CUDA_PATH}
#export CUDA_DIR=${CUDA_PATH}
#export CUDA_INCLUDE=${CUDA_INCLUDES}
#CUDA_INCLUDESexport CUDA_LIB=${CUDA_LIBS}
#export CUDA_TOOLKIT_ROOT_DIR=${CUDATOOLKIT_ROOT}
#export BML_CUDA=${BML_CUDA:=yes}
export BML_CUSOLVER=${BML_CUSOLVER:=yes}
export INSTALL_DIR=${INSTALL_DIR:="${MY_PATH}/install_cray"}
#export BML_TESTING=${BML_TESTING:=yes}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export MAGMA_ROOT=${MAGMA_ROOT:="/usr/projects/icapt/mewall/venado/packages/magma-2.7.2/install_cray"}
export BML_MAGMA=${BML_MAGMA:=yes}
export CMAKE_PREFIX_PATH="$CUDATOOLKIT_HOME/../../math_libs/lib64"
#export EXTRA_FFLAGS=${EXTRA_FFLAGS:="-DNVHPC_SDK"}
export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DCRAY_SDK -ef"}
export EXTRA_CFLAGS=${EXTRA_CFLAGS:=""}
export BML_POSIX_MEMALIGN=${BML_POSIX_MEMALIGN:=no}
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-DCRAY_SDK -I${CUDA_ROOT}/include -lcudart"}
#export EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:="-DCRAY_SDK -L${CUDA_ROOT}/lib64 -lcudart"}

./build.sh configure


54 changes: 54 additions & 0 deletions scripts/build_bml_cray_nvpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Make sure all the paths are correct

rm -rf build
rm -rf install_cray_nvpl

MY_PATH=$(pwd)


export CC=${CC:=cc}
#export FC=${FC:=/opt/cray/pe/cce/17.0.0/bin/crayftn}
export FC=${FC:=ftn}
export CXX=${CXX:=CC}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-ef -DCRAY_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DINTEL_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DCRAY_SDK"}
#export BLAS_VENDOR=${BLAS_VENDOR:=OpenBlas}
#export BLAS_VENDOR=${BLAS_VENDOR:=Intel10_64lp}
#export BLAS_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
export BLAS_LIBRARIES="-L$NVPL_HOME/lib -lnvpl_blas_lp64_gomp"
export LAPACK_LIBRARIES="-L$NVPL_HOME/lib -lnvpl_lapack_lp64_gomp"
#export LAPACK_LIBRARIES="-L${CRAY_PE_LIBSCI_PREFIX}/lib"
export BML_OPENMP=${BML_OPENMP:=yes}
export BML_COMPLEX=${BML_COMPLEX:=no}
#export CUDA_ROOT=${CUDA_PATH}
#export CUDA_DIR=${CUDA_PATH}
#export CUDA_INCLUDE=${CUDA_INCLUDES}
#CUDA_INCLUDESexport CUDA_LIB=${CUDA_LIBS}
#export CUDA_TOOLKIT_ROOT_DIR=${CUDATOOLKIT_ROOT}
#export BML_CUDA=${BML_CUDA:=yes}
export BML_CUSOLVER=${BML_CUSOLVER:=yes}
export INSTALL_DIR=${INSTALL_DIR:="${MY_PATH}/install_cray_nvpl"}
#export BML_TESTING=${BML_TESTING:=yes}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export MAGMA_ROOT=${MAGMA_ROOT:="/usr/projects/icapt/mewall/venado/packages/magma-2.7.2/install_cray_nvpl"}
export BML_MAGMA=${BML_MAGMA:=yes}
export CMAKE_PREFIX_PATH="$CUDATOOLKIT_HOME/../../math_libs/lib64"
#export EXTRA_FFLAGS=${EXTRA_FFLAGS:="-DNVHPC_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DCRAY_SDK -ef"}
export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-I/usr/include -I/usr/include/c++/12 -I/usr/include/c++/12/aarch64-suse-linux"}
#export CMAKE_C_FLAGS=${CMAKE_CXX_FLAGS:="-I/usr/include -I/usr/include/c++/12 -I/usr/include/c++/12/aarch64-suse-linux"}
#export CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS:="-I/usr/include -I/usr/include/c++/12 -I/usr/include/c++/12/aarch64-suse-linux"}
export BML_POSIX_MEMALIGN=${BML_POSIX_MEMALIGN:=no}
export CMAKE_C_FLAGS="-homp -g -L/usr/lib64/gcc/aarch64-suse-linux/12 -DCRAY_SDK"
export CMAKE_CXX_FLAGS="-homp -g -L/usr/lib64/gcc/aarch64-suse-linux/12"
export CMAKE_Fortran_FLAGS="-homp -g -ef -L/usr/lib64/gcc/aarch64-suse-linux/12 -DCRAY_SDK"
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-DCRAY_SDK -I${CUDA_ROOT}/include -lcudart"}
#export EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:="-DCRAY_SDK -L${CUDA_ROOT}/lib64 -lcudart"}
#EXTRA_LINK_FLAGS="-L/usr/lib64/gcc/aarch64-suse-linux/12"

./build.sh configure


49 changes: 49 additions & 0 deletions scripts/build_bml_nvhpc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Make sure all the paths are correct

rm -rf build
rm -rf install_nvhpc

MY_PATH=$(pwd)


export CC=${CC:=nvc}
export FC=${FC:=nvfortran}
export CXX=${CXX:=nvc++}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-ef -DCRAY_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DINTEL_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DCRAY_SDK"}
#export BLAS_VENDOR=${BLAS_VENDOR:=OpenBlas}
#export BLAS_VENDOR=${BLAS_VENDOR:=Intel10_64lp}
#export BLAS_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
#export BLAS_LIBRARIES="-L/projects/darwin-nv/rhel9/aarch64/packages/nvpl/23.11/lib -lnvpl_blas_lp64_gomp"
#export LAPACK_LIBRARIES="-L/projects/darwin-nv/rhel9/aarch64/packages/nvpl/23.11/lib -lnvpl_lapack_lp64_gomp"
#export LAPACK_LIBRARIES="-L${CRAY_PE_LIBSCI_PREFIX}/lib"
export BLAS_LIBRARIES="-L$NVPL_HOME/lib -lnvpl_blas_lp64_gomp"
export LAPACK_LIBRARIES="-L$NVPL_HOME/lib -lnvpl_lapack_lp64_gomp"
export BML_OPENMP=${BML_OPENMP:=yes}
export BML_COMPLEX=${BML_COMPLEX:=yes}
#export CUDA_ROOT=${CUDA_PATH}
export CUDA_DIR=${CUDA_PATH}
#export CUDA_INCLUDE=${CUDA_INCLUDES}
#CUDA_INCLUDESexport CUDA_LIB=${CUDA_LIBS}
#export CUDA_TOOLKIT_ROOT_DIR=${CUDATOOLKIT_ROOT}
#export BML_CUDA=${BML_CUDA:=yes}
export BML_CUSOLVER=${BML_CUSOLVER:=yes}
export INSTALL_DIR=${INSTALL_DIR:="${MY_PATH}/install_nvhpc"}
#export BML_TESTING=${BML_TESTING:=yes}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export MAGMA_ROOT=${MAGMA_ROOT:="/usr/projects/icapt/mewall/venado/packages/magma-2.7.2/install_nvhpc"}
export BML_MAGMA=${BML_MAGMA:=yes}
export CMAKE_PREFIX_PATH="${NVHPC_ROOT}/math_libs/lib64"
#export EXTRA_FFLAGS=${EXTRA_FFLAGS:="-DNVHPC_SDK"}
export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DNVHPC_SDK -O2"}
export CMAKE_C_FLAGS=${EXTRA_CFLAGS:="-DNVHPC_SDK -O2"}
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-DNVHPC_SDK"}
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-DCRAY_SDK -I${CUDA_ROOT}/include -lcudart"}
#export EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:="-DCRAY_SDK -L${CUDA_ROOT}/lib64 -lcudart"}

./build.sh configure


46 changes: 46 additions & 0 deletions scripts/build_chicoma_hackathon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# Make sure all the paths are correct

rm -r build
#rm -r install_magma_2.7.2
rm -r install_hackathon

MY_PATH=$(pwd)


export CC=${CC:=cc}
export FC=${FC:=ftn}
export CXX=${CXX:=CC}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-ef -DCRAY_SDK"}
mewall marked this conversation as resolved.
Show resolved Hide resolved
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DINTEL_SDK"}
#export CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS:="-DCRAY_SDK"}
export BLAS_VENDOR=${BLAS_VENDOR:=Intel10_64lp}
#export BLAS_VENDOR=${BLAS_VENDOR:=OpenBLAS}
#export LAPACK_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
#export BLAS_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
export BML_OPENMP=${BML_OPENMP:=yes}
export BML_COMPLEX=${BML_COMPLEX:=yes}
#export CUDA_ROOT=${CUDA_PATH}
#export CUDA_DIR=${CUDA_PATH}
#export CUDA_INCLUDE=${CUDA_INCLUDES}
#CUDA_INCLUDESexport CUDA_LIB=${CUDA_LIBS}
#export CUDA_TOOLKIT_ROOT_DIR=${CUDATOOLKIT_ROOT}
#export BML_CUDA=${BML_CUDA:=yes}
export BML_CUSOLVER=${BML_CUSOLVER:=yes}
export INSTALL_DIR=${INSTALL_DIR:="${MY_PATH}/install_hackathon"}
#export BML_TESTING=${BML_TESTING:=yes}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
#export MAGMA_ROOT=${MAGMA_ROOT:="/usr/projects/icapt/mewall/packages/gpmd/magma/install"}
export MAGMA_ROOT=${MAGMA_ROOT:="/usr/projects/icapt/mewall/packages/gpmd/magma-2.7.2/install"}
export BML_MAGMA=${BML_MAGMA:=yes}
#export BML_POSIX_MEMALIGN=${BML_POSIX_MEMALIGN:=no}
#export CMAKE_PREFIX_PATH="$MKLROOT/lib/intel64"
#export EXTRA_FFLAGS=${EXTRA_FFLAGS:="-fdefault-integer-8"}
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:=""}
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-DCRAY_SDK -I${CUDA_ROOT}/include -lcudart"}
#export EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:="-DCRAY_SDK -L${CUDA_ROOT}/lib64 -lcudart"}

./build.sh configure


36 changes: 36 additions & 0 deletions scripts/build_venado_hackathon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Make sure all the paths are correct

rm -r build
#rm -r install_magma_2.7.2
rm -r install_hackathon

MY_PATH=$(pwd)


export CC=${CC:=cc}
export FC=${FC:=ftn}
export CXX=${CXX:=CC}
#export BLAS_VENDOR=${BLAS_VENDOR:=OpenBLAS}
#export LAPACK_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
#export BLAS_LIBRARIES="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
export LAPACK_LIBRARIES="-L/opt/cray/pe/libsci/23.12.5/GNU/12.3/aarch64/lib"
export BML_OPENMP=${BML_OPENMP:=yes}
export BML_COMPLEX=${BML_COMPLEX:=yes}
export BML_CUSOLVER=${BML_CUSOLVER:=yes}
export INSTALL_DIR=${INSTALL_DIR:="${MY_PATH}/install_hackathon"}
#export BML_TESTING=${BML_TESTING:=yes}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export MAGMA_ROOT=${MAGMA_ROOT:="/usr/projects/icapt/mewall/venado/packages/magma-2.7.2/install"}
export BML_MAGMA=${BML_MAGMA:=yes}
#export BML_POSIX_MEMALIGN=${BML_POSIX_MEMALIGN:=no}
export CMAKE_PREFIX_PATH=$CUDA_HOME/../../math_libs/lib64:$CMAKE_PREFIX_PATH
export EXTRA_FFLAGS=${EXTRA_CFLAGS:="-mcpu=neoverse-v2"}
export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-mcpu=neoverse-v2"}
#export EXTRA_CFLAGS=${EXTRA_CFLAGS:="-DCRAY_SDK -I${CUDA_ROOT}/include -lcudart"}
#export EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:="-DCRAY_SDK -L${CUDA_ROOT}/lib64 -lcudart"}

./build.sh configure


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;
}
}
16 changes: 16 additions & 0 deletions src/C-interface/dense/bml_setters_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
#include "bml_setters_dense.h"
#include "bml_types_dense.h"

#ifdef BML_USE_MAGMA
#include "magma_v2.h"
#endif

void bml_set_N_dense(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a use case for setting N after construction. Is it to avoid constructing a new matrix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanlucf22 Yes. This was addressed in the commit comment but the bullets needed fixing to clarify (now corrected). This is to avoid repeated memory allocations which became a bottleneck in MD simulations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks dangerous to me: you modify N without modifying anything else will lead to matrices in inconsistent state!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mention in the comments, it is unsafe. It's possible to change N so that the matrix will exceed its original allocation. It's exposed only as bml_set_N_dense(), for experts. It works. Can you explain how the matrix will be inconsistent? It's needed for an application, we need to figure out how to make this method available in some form.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If needed we can protect against exceeding initial size by adding an extra variable to the struct keeping track of the size of the originally allocated matrix. But it's less intrusive to leave the struct alone...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the performance issue comes from the allocation of the struct members domain and domain2:

bml_domain_t *domain;

I looked into it at some point, but the fix I tried was breaking qmd-progress.
These two struct members could be static or initialized as needed.
Increasing N would obviously lead to a memory allocation too small to hold an NxN matrix.

What is the use case? Is N decreasing and you want to reuse the allocation? Whatever it is, I think looking into domain and domain2 is a safer and better alternative.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is needing to use a MAGMA working array of differing size on different MD iterations, where max N is known. The problem is that creating a new array each time is slow, due to the GPU allocation. The solution is to allocate using max N once and to resize the array using bml_set_N_dense() as needed. How can I use domain and domain2 to do this? I'm not familiar with those.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now.

I was not suggesting to use domain and domain2. I was just saying their allocation may be the main culprit when it comes to allocation time for a dense matrix. Maybe an issue to deal with another time.

Another suggestion: having a function resizeNoAlloc(int n) that would just change N if n<=N, otherwise would change N and reallocate memory? Having an extra struct member keeping track of allocated memory size would be good in that case.

bml_matrix_dense_t * A,
int N)
{
A->N = N;
#ifdef BML_USE_MAGMA
A->ld = magma_roundup(A->N, 32);
#else
A->ld = A->N;
#endif
}

void
bml_set_element_dense(
bml_matrix_dense_t * A,
Expand Down
4 changes: 4 additions & 0 deletions src/C-interface/dense/bml_setters_dense.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#include <complex.h>

void bml_set_N_dense(
bml_matrix_dense_t * A,
int N);

void bml_set_element_dense(
bml_matrix_dense_t * A,
int i,
Expand Down
23 changes: 23 additions & 0 deletions src/Fortran-interface/bml_c_interface_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ function bml_get_bandwidth_C(a) bind(C, name="bml_get_bandwidth")
type(C_PTR), value, intent(in) :: a
integer(C_INT) :: bml_get_bandwidth_C
end function bml_get_bandwidth_C

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_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 Expand Up @@ -448,6 +460,12 @@ subroutine bml_scale_inplace_C(alpha, a) bind(C, name="bml_scale_inplace")
type(C_PTR), value :: a
end subroutine bml_scale_inplace_C

subroutine bml_set_N_dense_C(a,n) bind(C, name="bml_set_N_dense")
import :: C_PTR, C_INT
type(C_PTR), value, intent(in) :: a
integer(C_INT), value, intent(in) :: n
end subroutine bml_set_N_dense_C

subroutine bml_set_row_C(a, i, row, threshold) bind(C, name="bml_set_row")
import :: C_PTR, C_INT, C_DOUBLE
type(C_PTR), value, intent(in) :: a
Expand Down Expand Up @@ -616,6 +634,11 @@ function bml_transpose_new_C(a) bind(C, name="bml_transpose_new")
type(C_PTR) :: bml_transpose_new_C
end function bml_transpose_new_C

subroutine bml_transpose_C(a) bind(C, name="bml_transpose")
import :: C_PTR
type(C_PTR), value, intent(in) :: a
end subroutine bml_transpose_C

subroutine bml_write_bml_matrix_C(a, filename) &
& bind(C, name="bml_write_bml_matrix")
import :: C_PTR, C_CHAR
Expand Down
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
11 changes: 10 additions & 1 deletion src/Fortran-interface/bml_setters_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ module bml_setters_m
public :: bml_set_diagonal
public :: bml_set_element
public :: bml_set_element_new

public :: bml_set_N_dense

contains

subroutine bml_set_N_dense(a,n)
type(bml_matrix_t), intent(inout) :: a
integer(C_INT), intent(in) :: n

call bml_set_N_dense_C(a%ptr,n)

end subroutine bml_set_N_dense

!Setters for element new
subroutine bml_set_element_new_single_real(a,i,j,element)

Expand Down
Loading
Loading