Skip to content

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

Open

Description

@ivan-pi

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.

Activity

  1. fgvanzee commented on Nov 18, 2024

    @fgvanzee
    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)

  2. ivan-pi commented on Nov 19, 2024

    @ivan-pi
    Author

    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.

  3. devinamatthews commented on Nov 19, 2024

    @devinamatthews
    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.

  4. devinamatthews commented on Nov 19, 2024

    @devinamatthews
    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.

  5. ivan-pi commented on Nov 19, 2024

    @ivan-pi
    Author

    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].

  6. devinamatthews commented on Nov 19, 2024

    @devinamatthews
    Member

    Thx

  7. EylonKrause commented on Jun 24, 2026

    @EylonKrause
    Contributor

    Confirming this is still the case on master: bli_?setijv/bli_?getijv (and the ?setijm/?getijm matrix variants) take void* x and double ar, double ai rather than typed pointers/scalars (frame/base/bli_setgetijv.h).

    Strongly typing them would change the public prototypes, which is a breaking ABI/API change, so it's really a maintainer call on the preferred approach (e.g. introducing typed variants vs. changing the existing signatures, and whether to also type the ar/ai scalars). If you'd welcome a PR along those lines, I'm happy to put one together.

  8. devinamatthews commented on Jun 24, 2026

    @devinamatthews
    Member

    A PR is welcome for inclusion in a future version :).

  9. devinamatthews commented on Jul 7, 2026

    @devinamatthews
    Member

    Adding a checklist for function families which need strong types:

    • bli_?getijm/bli_?setijm
    • bli_?getijv/bli_?setijv
    • bli_?copysc
    • bli_?castm
    • bli_?castv
    • bli_?castnzm
    • bli_?printm
    • bli_?printv
    • bli_?fprintm
    • bli_?fprintv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions