Improve handling of psi_c_diffadd and psb_sizeof_XX

split_sum
Salvatore Filippone 3 years ago
parent adbae358e4
commit 727a99e376

@ -1,29 +1,9 @@
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include "psb_internals.h"
#ifdef LowerUnderscore
#define psi_c_diffadd psi_c_diffadd_
#endif
#ifdef LowerDoubleUnderscore
#define psi_c_diffadd psi_c_diffadd__
#endif
#ifdef LowerCase
#define psi_c_diffadd psi_c_diffadd
#endif
#ifdef UpperUnderscore
#define psi_c_diffadd PSI_C_DIFFADD_
#endif
#ifdef UpperDoubleUnderscore
#define psi_c_diffadd PSI_C_DIFFADD__
#endif
#ifdef UpperCase
#define psi_c_diffadd PSI_C_DIFFADD
#endif
void psi_c_diffadd(char *p1, char *p2, int *ret)
void psi_c_diffadd(void *p1, void *p2, int *ret)
{
*ret = (int)(p2-p1);
*ret = (int)((char *)p2-(char *)p1);
return;
}

@ -696,21 +696,32 @@ contains
subroutine psi_get_sizes()
use psb_const_mod
real(psb_dpk_) :: dv(2)
real(psb_spk_) :: sv(2)
integer(psb_i2pk_):: i2v(2)
integer(psb_mpk_) :: mv(2)
integer(psb_ipk_) :: iv(2)
integer(psb_lpk_) :: lv(2)
integer(psb_epk_) :: ev(2)
call psi_c_diffadd(sv(1),sv(2),psb_sizeof_sp)
call psi_c_diffadd(dv(1),dv(2),psb_sizeof_dp)
call psi_c_diffadd(i2v(1),i2v(2),psb_sizeof_i2p)
call psi_c_diffadd(mv(1),mv(2),psb_sizeof_mp)
call psi_c_diffadd(iv(1),iv(2),psb_sizeof_ip)
call psi_c_diffadd(lv(1),lv(2),psb_sizeof_lp)
call psi_c_diffadd(ev(1),ev(2),psb_sizeof_ep)
use iso_c_binding
real(psb_dpk_), target :: dv(2)
real(psb_spk_), target :: sv(2)
integer(psb_i2pk_), target :: i2v(2)
integer(psb_mpk_), target :: mv(2)
integer(psb_ipk_), target :: iv(2)
integer(psb_lpk_), target :: lv(2)
integer(psb_epk_), target :: ev(2)
interface
subroutine psi_c_diffadd(p1, p2, val) &
& bind(c,name="psi_c_diffadd")
use iso_c_binding
import :: psb_mpk_
type(c_ptr), value :: p1, p2
integer(psb_mpk_) :: val
end subroutine psi_c_diffadd
end interface
call psi_c_diffadd(c_loc(sv(1)),c_loc(sv(2)),psb_sizeof_sp)
call psi_c_diffadd(c_loc(dv(1)),c_loc(dv(2)),psb_sizeof_dp)
call psi_c_diffadd(c_loc(i2v(1)),c_loc(i2v(2)),psb_sizeof_i2p)
call psi_c_diffadd(c_loc(mv(1)),c_loc(mv(2)),psb_sizeof_mp)
call psi_c_diffadd(c_loc(iv(1)),c_loc(iv(2)),psb_sizeof_ip)
call psi_c_diffadd(c_loc(lv(1)),c_loc(lv(2)),psb_sizeof_lp)
call psi_c_diffadd(c_loc(ev(1)),c_loc(ev(2)),psb_sizeof_ep)
end subroutine psi_get_sizes

@ -101,24 +101,24 @@ module psb_const_mod
integer, parameter :: psb_lpk_ = -1
#endif
integer(psb_ipk_), save :: psb_sizeof_sp
integer(psb_ipk_), save :: psb_sizeof_dp
integer(psb_ipk_), save :: psb_sizeof_i2p = 2
integer(psb_ipk_), save :: psb_sizeof_mp = 4
integer(psb_ipk_), save :: psb_sizeof_ep = 8
integer(psb_mpk_), save :: psb_sizeof_sp
integer(psb_mpk_), save :: psb_sizeof_dp
integer(psb_mpk_), save :: psb_sizeof_i2p = 2
integer(psb_mpk_), save :: psb_sizeof_mp = 4
integer(psb_mpk_), save :: psb_sizeof_ep = 8
#if defined(IPK4) && defined(LPK4)
integer(psb_ipk_), save :: psb_sizeof_ip = 4
integer(psb_ipk_), save :: psb_sizeof_lp = 4
integer(psb_mpk_), save :: psb_sizeof_ip = 4
integer(psb_mpk_), save :: psb_sizeof_lp = 4
#elif defined(IPK4) && defined(LPK8)
integer(psb_ipk_), save :: psb_sizeof_ip = 4
integer(psb_ipk_), save :: psb_sizeof_lp = 8
integer(psb_mpk_), save :: psb_sizeof_ip = 4
integer(psb_mpk_), save :: psb_sizeof_lp = 8
#elif defined(IPK8) && defined(LPK8)
integer(psb_ipk_), save :: psb_sizeof_ip = 8
integer(psb_ipk_), save :: psb_sizeof_lp = 8
integer(psb_mpk_), save :: psb_sizeof_ip = 8
integer(psb_mpk_), save :: psb_sizeof_lp = 8
#else
integer(psb_ipk_), save :: psb_sizeof_ip = -1
integer(psb_ipk_), save :: psb_sizeof_lp = -1
integer(psb_mpk_), save :: psb_sizeof_ip = -1
integer(psb_mpk_), save :: psb_sizeof_lp = -1
#endif
!

Loading…
Cancel
Save