Skip to content
Snippets Groups Projects
Commit 98754cd3 authored by Stephan Schulz's avatar Stephan Schulz
Browse files

add gamma setter and getter (#18)

parent eb76c2a9
No related branches found
No related tags found
1 merge request!8Refactor
...@@ -67,6 +67,11 @@ void all_finalize_c(ALL::ALL<double, double> *all_obj) { ...@@ -67,6 +67,11 @@ void all_finalize_c(ALL::ALL<double, double> *all_obj) {
// todo(s.schulz): does this throw if all_obj is already deleted? can we detect it? // todo(s.schulz): does this throw if all_obj is already deleted? can we detect it?
} }
void all_set_gamma_c(ALL::ALL<double, double> *all_obj, double gamma) {
ALL_try
all_obj->setGamma(gamma);
ALL_catch
}
// set grid parameters // set grid parameters
void all_set_proc_grid_params_c(ALL::ALL<double, double> *all_obj, int nloc, void all_set_proc_grid_params_c(ALL::ALL<double, double> *all_obj, int nloc,
...@@ -149,6 +154,8 @@ void all_balance_c(ALL::ALL<double, double> *all_obj) { ...@@ -149,6 +154,8 @@ void all_balance_c(ALL::ALL<double, double> *all_obj) {
ALL_catch ALL_catch
} }
double all_get_gamma_c(ALL::ALL<double, double> *all_obj) { return all_obj->getGamma(); }
// wrapper to get number of new vertices // wrapper to get number of new vertices
void all_get_number_of_vertices_c(ALL::ALL<double, double> *all_obj, int *n_vertices) { void all_get_number_of_vertices_c(ALL::ALL<double, double> *all_obj, int *n_vertices) {
ALL_try ALL_try
......
...@@ -72,6 +72,11 @@ module ALL_module ...@@ -72,6 +72,11 @@ module ALL_module
use iso_c_binding use iso_c_binding
type(c_ptr), value :: obj type(c_ptr), value :: obj
end subroutine end subroutine
subroutine all_set_gamma_c(obj, gamma) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
real(c_double), value :: gamma
end subroutine
subroutine ALL_set_proc_grid_params_c(obj, nloc, loc, nsize, size) bind(C) subroutine ALL_set_proc_grid_params_c(obj, nloc, loc, nsize, size) bind(C)
use iso_c_binding use iso_c_binding
type(c_ptr), value :: obj type(c_ptr), value :: obj
...@@ -116,6 +121,11 @@ module ALL_module ...@@ -116,6 +121,11 @@ module ALL_module
use iso_c_binding use iso_c_binding
type(c_ptr), value :: obj type(c_ptr), value :: obj
end subroutine end subroutine
function all_get_gamma_c(obj) result(gamma) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
real(c_double) :: gamma
end function
subroutine all_get_number_of_vertices_c(obj, n) bind(C) subroutine all_get_number_of_vertices_c(obj, n) bind(C)
use iso_c_binding use iso_c_binding
type(c_ptr), value :: obj type(c_ptr), value :: obj
...@@ -163,6 +173,7 @@ module ALL_module ...@@ -163,6 +173,7 @@ module ALL_module
contains contains
procedure :: init => ALL_init procedure :: init => ALL_init
procedure :: finalize => ALL_finalize procedure :: finalize => ALL_finalize
procedure :: set_gamma => ALL_set_gamma
procedure :: set_proc_grid_params => ALL_set_proc_grid_params procedure :: set_proc_grid_params => ALL_set_proc_grid_params
procedure :: set_proc_tag => ALL_set_proc_tag procedure :: set_proc_tag => ALL_set_proc_tag
procedure :: set_min_domain_size => ALL_set_min_domain_size procedure :: set_min_domain_size => ALL_set_min_domain_size
...@@ -175,6 +186,7 @@ module ALL_module ...@@ -175,6 +186,7 @@ module ALL_module
#endif #endif
procedure :: setup => ALL_setup procedure :: setup => ALL_setup
procedure :: balance => ALL_balance procedure :: balance => ALL_balance
procedure :: get_gamma => ALL_get_gamma
procedure :: get_number_of_vertices => ALL_get_number_of_vertices procedure :: get_number_of_vertices => ALL_get_number_of_vertices
procedure :: get_vertices => ALL_get_vertices procedure :: get_vertices => ALL_get_vertices
procedure :: get_vertices_alloc => ALL_get_vertices_alloc procedure :: get_vertices_alloc => ALL_get_vertices_alloc
...@@ -186,6 +198,7 @@ module ALL_module ...@@ -186,6 +198,7 @@ module ALL_module
! This is the old, but still supported API of separate functions ! This is the old, but still supported API of separate functions
public :: ALL_init public :: ALL_init
public :: ALL_finalize public :: ALL_finalize
public :: ALL_set_gamma
public :: ALL_set_proc_grid_params public :: ALL_set_proc_grid_params
public :: ALL_set_proc_tag public :: ALL_set_proc_tag
public :: ALL_set_min_domain_size public :: ALL_set_min_domain_size
...@@ -194,6 +207,7 @@ module ALL_module ...@@ -194,6 +207,7 @@ module ALL_module
public :: ALL_set_communicator public :: ALL_set_communicator
public :: ALL_setup public :: ALL_setup
public :: ALL_balance public :: ALL_balance
public :: ALL_get_gamma
public :: ALL_get_number_of_vertices public :: ALL_get_number_of_vertices
public :: ALL_get_vertices public :: ALL_get_vertices
public :: ALL_get_vertices_alloc public :: ALL_get_vertices_alloc
...@@ -225,6 +239,12 @@ contains ...@@ -225,6 +239,12 @@ contains
class(ALL_t), intent(in) :: this class(ALL_t), intent(in) :: this
call ALL_finalize_c(this%object) call ALL_finalize_c(this%object)
end subroutine end subroutine
!> Set gamma value for load balancer
subroutine ALL_set_gamma(this, gamma)
class(ALL_t), intent(in) :: this
real(c_double), intent(in) :: gamma
call all_set_gamma_c(this%object, gamma)
end subroutine
!> Set the grid parameters for this process !> Set the grid parameters for this process
subroutine ALL_set_proc_grid_params(this, loc, ranks) subroutine ALL_set_proc_grid_params(this, loc, ranks)
class(ALL_t), intent(in) :: this class(ALL_t), intent(in) :: this
...@@ -289,6 +309,12 @@ contains ...@@ -289,6 +309,12 @@ contains
class(ALL_t), intent(in) :: this class(ALL_t), intent(in) :: this
call ALL_balance_c(this%object) call ALL_balance_c(this%object)
end subroutine end subroutine
!> Retrieve currently set gamma value of balancer
function ALL_get_gamma(this) result(gamma)
class(ALL_t), intent(in) :: this
real(c_double) :: gamma
gamma = all_get_gamma_c(this%object)
end function
!> Retrieve number of vertices for current vertices !> Retrieve number of vertices for current vertices
subroutine ALL_get_number_of_vertices(this, n) subroutine ALL_get_number_of_vertices(this, n)
class(ALL_t), intent(in) :: this class(ALL_t), intent(in) :: this
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment