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

bli_?setijv accepts void* instead of floating point type #831

Open
ivan-pi opened this issue Nov 16, 2024 · 6 comments
Open

bli_?setijv accepts void* instead of floating point type #831

ivan-pi opened this issue Nov 16, 2024 · 6 comments

Comments

@ivan-pi
Copy link

ivan-pi commented Nov 16, 2024

The routines ?setijv/?getijv and ?setijm/?getijm are not strongly typed.

E.g. if you run gcc -P -C -E path/to/blis.h > blis.h.pp the preprocess header will contain the following prototypes:

__attribute__ ((visibility ("default"))) void bli_ssetijv ( double ar, double ai, dim_t i, void* x, inc_t incx ); 
__attribute__ ((visibility ("default"))) void bli_dsetijv ( double ar, double ai, dim_t i, void* x, inc_t incx ); 
__attribute__ ((visibility ("default"))) void bli_csetijv ( double ar, double ai, dim_t i, void* x, inc_t incx ); 
__attribute__ ((visibility ("default"))) void bli_zsetijv ( double ar, double ai, dim_t i, void* x, inc_t incx );

This originates from

#define GENTPROT( ctype, ch, opname ) \
\
BLIS_EXPORT_BLIS void PASTEMAC(ch,opname) \
( \
double ar, \
double ai, \
dim_t i, \
void* x, inc_t incx \
);
INSERT_GENTPROT_BASIC( setijv )

Could these routines be strongly typed using float/double/scomplex/dcomplex? The reason I'm asking is because the missing type breaks some scripts for generating wrappers.

@fgvanzee
Copy link
Member

Hi @ivan-pi. To what extent do you need strongly typed function prototypes? My first reaction to this was that this is just the tip of the tip of the tip of the iceberg for use of void* pointers in lieu of actual typed pointers in BLIS. Or maybe I'm missing something about your particular application setting? (cc @devinamatthews)

@ivan-pi
Copy link
Author

ivan-pi commented Nov 19, 2024

The application was creating Fortran interfaces from the C prototypes. The current script iterates over the parameter list and creates Fortran interface blocks such as:

interface
   subroutine bli_?setijv(ar,ai,i,x,incx)
      real(c_double), value :: ar, ai
      integer(dim_kind), value :: i
      real(?) :: x(*)  ! void*
      integer(inc_kind), value :: incx
   end subroutine
end interface

Due to the void* x, the interface-generation script I'm writing fails here. I understand it's a hassle and just adds more work to the existing macro machinery.

Upon further thought I think it'll be better if I just introduce a Fortran version so that it can use 1-based indexing and check bounds automatically.

@ivan-pi ivan-pi closed this as completed Nov 19, 2024
@devinamatthews
Copy link
Member

Hi @ivan-pi I'm going to leave this open since you're right, it is an inconsistency. This could also affect C++ users.

@devinamatthews
Copy link
Member

@fgvanzee void* is great for kernels since a) they're internal and b) they're typically being called through a type-erased interface anyways. For user-level typed functions, having strongly typed arguments is definitely helpful.

@ivan-pi
Copy link
Author

ivan-pi commented Nov 19, 2024

In that case I'd just note that void* also appears in the prototypes for ??copysc, ??cast[m|v], ??castnzm, ?fprint[m|v] and ?print[m|v].

@devinamatthews
Copy link
Member

Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants