Loading graph_fortran_binding/graph_fortran_binding.f90 +71 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ piecewise_2D_double, & piecewise_2D_cfloat, & piecewise_2D_cdouble PROCEDURE :: get_max_concurrency => graph_context_get_max_concurrency PROCEDURE :: set_device_number => graph_context_set_device_number END TYPE !******************************************************************************* Loading Loading @@ -773,6 +775,33 @@ INTEGER(C_LONG), VALUE :: source_size END FUNCTION !------------------------------------------------------------------------------- !> @brief Get the maximum number of concurrent devices. !> !> @param[in] c The graph C context. !> @returns The number of devices. !------------------------------------------------------------------------------- INTEGER(C_LONG) FUNCTION graph_get_max_concurrency(c) & BIND(C, NAME='graph_get_max_concurrency') USE, INTRINSIC :: ISO_C_BINDING IMPLICIT NONE TYPE(C_PTR), VALUE :: c END FUNCTION !------------------------------------------------------------------------------- !> @brief Choose the device number. !> !> @param[in] c The graph C context. !> @param[in] num The device number. !------------------------------------------------------------------------------- SUBROUTINE graph_set_device_number(c, num) & BIND(C, NAME='graph_set_device_number') USE, INTRINSIC :: ISO_C_BINDING IMPLICIT NONE TYPE(C_PTR), VALUE :: c INTEGER(C_LONG), VALUE :: num END SUBROUTINE END INTERFACE CONTAINS Loading Loading @@ -1698,4 +1727,46 @@ END FUNCTION !******************************************************************************* ! JIT !******************************************************************************* !------------------------------------------------------------------------------- !> @brief Get the maximum number of concurrent devices. !> !> @param[in] this @ref graph_context instance. !> @returns The number of devices. !------------------------------------------------------------------------------- FUNCTION graph_context_get_max_concurrency(this) IMPLICIT NONE ! Declare Arguments INTEGER(C_LONG) :: graph_context_get_max_concurrency CLASS(graph_context), INTENT(IN) :: this ! Start of executable. graph_context_get_max_concurrency = & graph_get_max_concurrency(this%c_context) END FUNCTION !------------------------------------------------------------------------------- !> @brief Choose the device number. !> !> @param[in,out] c The graph C context. !> @param[in] num The device number. !------------------------------------------------------------------------------- SUBROUTINE graph_context_set_device_number(this, num) IMPLICIT NONE ! Declare Arguments CLASS(graph_context), INTENT(INOUT) :: this INTEGER(C_LONG), INTENT(IN) :: num ! Start of executable. CALL graph_set_device_number(this%c_context, num) END SUBROUTINE END MODULE graph_tests/f_binding_test.f90 +8 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading Loading @@ -229,6 +231,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading Loading @@ -324,6 +328,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading Loading @@ -419,6 +425,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading
graph_fortran_binding/graph_fortran_binding.f90 +71 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ piecewise_2D_double, & piecewise_2D_cfloat, & piecewise_2D_cdouble PROCEDURE :: get_max_concurrency => graph_context_get_max_concurrency PROCEDURE :: set_device_number => graph_context_set_device_number END TYPE !******************************************************************************* Loading Loading @@ -773,6 +775,33 @@ INTEGER(C_LONG), VALUE :: source_size END FUNCTION !------------------------------------------------------------------------------- !> @brief Get the maximum number of concurrent devices. !> !> @param[in] c The graph C context. !> @returns The number of devices. !------------------------------------------------------------------------------- INTEGER(C_LONG) FUNCTION graph_get_max_concurrency(c) & BIND(C, NAME='graph_get_max_concurrency') USE, INTRINSIC :: ISO_C_BINDING IMPLICIT NONE TYPE(C_PTR), VALUE :: c END FUNCTION !------------------------------------------------------------------------------- !> @brief Choose the device number. !> !> @param[in] c The graph C context. !> @param[in] num The device number. !------------------------------------------------------------------------------- SUBROUTINE graph_set_device_number(c, num) & BIND(C, NAME='graph_set_device_number') USE, INTRINSIC :: ISO_C_BINDING IMPLICIT NONE TYPE(C_PTR), VALUE :: c INTEGER(C_LONG), VALUE :: num END SUBROUTINE END INTERFACE CONTAINS Loading Loading @@ -1698,4 +1727,46 @@ END FUNCTION !******************************************************************************* ! JIT !******************************************************************************* !------------------------------------------------------------------------------- !> @brief Get the maximum number of concurrent devices. !> !> @param[in] this @ref graph_context instance. !> @returns The number of devices. !------------------------------------------------------------------------------- FUNCTION graph_context_get_max_concurrency(this) IMPLICIT NONE ! Declare Arguments INTEGER(C_LONG) :: graph_context_get_max_concurrency CLASS(graph_context), INTENT(IN) :: this ! Start of executable. graph_context_get_max_concurrency = & graph_get_max_concurrency(this%c_context) END FUNCTION !------------------------------------------------------------------------------- !> @brief Choose the device number. !> !> @param[in,out] c The graph C context. !> @param[in] num The device number. !------------------------------------------------------------------------------- SUBROUTINE graph_context_set_device_number(this, num) IMPLICIT NONE ! Declare Arguments CLASS(graph_context), INTENT(INOUT) :: this INTEGER(C_LONG), INTENT(IN) :: num ! Start of executable. CALL graph_set_device_number(this%c_context, num) END SUBROUTINE END MODULE
graph_tests/f_binding_test.f90 +8 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading Loading @@ -229,6 +231,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading Loading @@ -324,6 +328,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE Loading Loading @@ -419,6 +425,8 @@ p2 = graph%piecewise_2D(i, 1.0_C_DOUBLE, 0.0_C_DOUBLE, & j, 1.0_C_DOUBLE, 0.0_C_DOUBLE, buffer2D) CALL graph%set_device_number(graph%get_max_concurrency() - 1) DEALLOCATE(graph) END SUBROUTINE