Skip to content

Use void* datatypes in kernel APIs.#727

Merged
fgvanzee merged 8 commits intomasterfrom
void_kernel_apis
Feb 22, 2023
Merged

Use void* datatypes in kernel APIs.#727
fgvanzee merged 8 commits intomasterfrom
void_kernel_apis

Conversation

@fgvanzee
Copy link
Copy Markdown
Member

@fgvanzee fgvanzee commented Feb 20, 2023

Details:

  • Migrated all kernel APIs to use void* pointers instead of float*, double*, scomplex*, and dcomplex* pointers. This allows us to define many fewer kernel function pointer types, which also makes it much easier to know which function pointer type to use at any given time. (For example, whereas before there was ?axpyv_ker_ft, ?axpyv_ker_vft, and axpyv_ker_vft, now there is just axpyv_ker_ft, which is equivalent so what axpyv_ker_vft used to be.)
  • Refactored how kernel function prototypes and kernel function types are defined so as to reduce redundant code. Specifically, the function signatures (excluding cntx_t* and, in the case of level-3 microkernels, auxinfo_t*) are defined in new headers named, for example, bli_l1v_ker_params.h. Those signatures are reused via macro instantiation when defining both kernel prototypes and kernel function types. This will hopefully make it a little easier to update, add, and manage kernel APIs going forward.
  • Updated all reference kernels according to the aforementioned switch to void* pointers.
  • Updated all optimized kernels according to the aforementioned switch to void* pointers. This sometimes required renaming variables, inserting typecasting so that pointer arithmetic could continue to function as intended, and related tweaks.
  • Updated sandbox/gemmlike according to the aforementioned switch to void* pointers.
  • Renamed (to better align with naming of neighboring files):
    • frame/1/bli_l1v_ft_ker.h -> frame/1/bli_l1v_ker_ft.h
    • frame/1f/bli_l1f_ft_ker.h -> frame/1f/bli_l1f_ker_ft.h
    • frame/1m/bli_l1m_ft_ker.h -> frame/1m/bli_l1m_ker_ft.h
    • frame/3/bli_l1m_ft_ukr.h -> frame/3/bli_l1m_ukr_ft.h
    • frame/3/bli_l3_sup_ft_ker.h -> frame/3/bli_l3_sup_ker_ft.h
  • Added the missing void* params argument to bli_?packm_struc_cxk() in frame/1m/packm/bli_packm_struc_cxk.c. This argument is being passed into the function from bli_packm_blk_var1(), but wasn't being "caught" by the function definition itself. The function prototype for bli_?packm_struc_cxk() also needed updating.
  • Reordered the last two parameters in bli_?packm_struc_cxk(). (Previously, the void* params was passed in after the const cntx_t* cntx, although because of the above bug the params argument wasn't actually present in the function definition.)

cc: @devinamatthews Here's phase 2 of #722.

Details:
- Migrated all kernel APIs to use void* pointers instead of float*,
  double*, scomplex*, and dcomplex* pointers. This allows us to define
  many fewer kernel function pointer types, which also makes it much
  easier to know which function pointer type to use at any given time.
  (For example, whereas before there was ?axpyv_ker_ft, ?axpyv_ker_vft,
  and axpyv_ker_vft, now there is just axpyv_ker_ft, which is equivalent
  so what axpyv_ker_vft used to be.)
- Refactored how kernel function prototypes and kernel function types
  are defined so as to reduce redundant code. Specifically, the
  function signatures (excluding cntx_t*) are defined in new headers
  named, for example, bli_l1v_ker_params.h. Those signatures are reused
  via macro instantiation when defining both kernel prototypes and
  kernel function types. This will hopefully make it a little easier to
  update, add, and manage kernel APIs going forward.
- Updated all reference kernels according to the aforementioned switch
  to void* pointers.
- Updated all optimzied kernels according to the aforementioned switch
  to void* pointers. This sometimes required renaming variables,
  inserting typecasting so that pointer arithmetic could continue to
  function as intended, and related tweaks.
- Updated sandbox/gemmlike according to the aforementioned switch to
  void* pointers.
- Renamed:
  - frame/1/bli_l1v_ft_ker.h    -> frame/1/bli_l1v_ker_ft.h
  - frame/1f/bli_l1f_ft_ker.h   -> frame/1f/bli_l1f_ker_ft.h
  - frame/1m/bli_l1m_ft_ker.h   -> frame/1m/bli_l1m_ker_ft.h
  - frame/3/bli_l1m_ft_ukr.h    -> frame/3/bli_l1m_ukr_ft.h
  - frame/3/bli_l3_sup_ft_ker.h -> frame/3/bli_l3_sup_ker_ft.h
  to better align with naming of neighboring files.
- Added the missing "void* params" argument to bli_?packm_struc_cxk() in
  frame/1m/packm/bli_packm_struc_cxk.c. This argument is being passed
  into the function from bli_packm_blk_var1(), but wasn't being "caught"
  by the function definition itself. The function prototype for
  bli_?packm_struc_cxk() also needed updating.
- Reordered the last two parameters in bli_?packm_struc_cxk().
  (Previously, the "void* params" was passed in after the
  "const cntx_t* cntx", although because of the above bug the params
  argument wasn't actually present in the function definition.)
@fgvanzee fgvanzee self-assigned this Feb 20, 2023
@fgvanzee
Copy link
Copy Markdown
Member Author

fgvanzee commented Feb 20, 2023

@nisanthmp Like you did with #722, could you please test out the changes in this commit PR on the power microarchitectures? Thanks so much.

@fgvanzee
Copy link
Copy Markdown
Member Author

@xrq-phys Would you mind similarly reviewing/testing the arm kernels? Travis CI does some checks already, but given the extent of the changes a human touch would be appreciated. 😄

Copy link
Copy Markdown
Collaborator

@xrq-phys xrq-phys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem seem to exist in code itself.

Running one additional test on NEON SUP.

@xrq-phys
Copy link
Copy Markdown
Collaborator

Check passed. :D

@nisanthmp
Copy link
Copy Markdown
Contributor

@fgvanzee compiles and checks fine on power (power9 and power10) :-)

@fgvanzee
Copy link
Copy Markdown
Member Author

fgvanzee commented Feb 22, 2023

@fgvanzee compiles and checks fine on power (power9 and power10) :-)

@nisanthmp Glad to hear. Thank you for your assistance!

Details:
- Added cpp guards to _prot.h headers for level-1, -1f, -1m, -3 and
  -3_sup kernels.
- Removed duplicate sup _params macro defined in bli_l3_ukr_prot.h.
- Whitespace changes.
@jeffhammond
Copy link
Copy Markdown
Member

Or you could just use C++ internally, while not using any C++ features that would require the runtime library, and not have to play games with void pointers.

@devinamatthews
Copy link
Copy Markdown
Member

@jeffhammond you're preaching to the choir but there's apparently not a C++ toolchain at all on enough platforms to make a difference. How this is possible I don't know.

@jeffhammond
Copy link
Copy Markdown
Member

I've programmed some really crazy even imaginary hardware in my career and the C++ required for this worked on all of it, even with the IBM XL C++ compiler on 32-bit Blue Gene.

I would argue that the vendors who build garbage that can handle this should pay you for the maintenance cost associated with their stupidity.

It isn't my area but I think people use the aforementioned C++ subset on microcontrollers and other lightweight platforms.

@leekillough
Copy link
Copy Markdown
Collaborator

@jeffhammond : LOL

@fgvanzee fgvanzee merged commit fab18dc into master Feb 22, 2023
@fgvanzee fgvanzee deleted the void_kernel_apis branch February 22, 2023 22:50
angsch added a commit to angsch/blis that referenced this pull request Feb 24, 2023
angsch added a commit to angsch/blis that referenced this pull request Mar 25, 2023
ct-clmsn pushed a commit to ct-clmsn/blis that referenced this pull request Jul 29, 2023
Details:
- Migrated all kernel APIs to use void* pointers instead of float*,
  double*, scomplex*, and dcomplex* pointers. This allows us to define
  many fewer kernel function pointer types, which also makes it much
  easier to know which function pointer type to use at any given time.
  (For example, whereas before there was ?axpyv_ker_ft, ?axpyv_ker_vft,
  and axpyv_ker_vft, now there is just axpyv_ker_ft, which is equivalent
  so what axpyv_ker_vft used to be.)
- Refactored how kernel function prototypes and kernel function types
  are defined so as to reduce redundant code. Specifically, the
  function signatures (excluding cntx_t* and, in the case of level-3
  microkernels, auxinfo_t*) are defined in new headers named, for 
  example, bli_l1v_ker_params.h. Those signatures are reused via macro 
  instantiation when defining both kernel prototypes and kernel function 
  types. This will hopefully make it a little easier to update, add, and 
  manage kernel APIs going forward.
- Updated all reference kernels according to the aforementioned switch
  to void* pointers.
- Updated all optimzied kernels according to the aforementioned switch
  to void* pointers. This sometimes required renaming variables,
  inserting typecasting so that pointer arithmetic could continue to
  function as intended, and related tweaks.
- Updated sandbox/gemmlike according to the aforementioned switch to
  void* pointers.
- Renamed:
  - frame/1/bli_l1v_ft_ker.h    -> frame/1/bli_l1v_ker_ft.h
  - frame/1f/bli_l1f_ft_ker.h   -> frame/1f/bli_l1f_ker_ft.h
  - frame/1m/bli_l1m_ft_ker.h   -> frame/1m/bli_l1m_ker_ft.h
  - frame/3/bli_l1m_ft_ukr.h    -> frame/3/bli_l1m_ukr_ft.h
  - frame/3/bli_l3_sup_ft_ker.h -> frame/3/bli_l3_sup_ker_ft.h
  to better align with naming of neighboring files.
- Added the missing "void* params" argument to bli_?packm_struc_cxk() in
  frame/1m/packm/bli_packm_struc_cxk.c. This argument is being passed
  into the function from bli_packm_blk_var1(), but wasn't being "caught"
  by the function definition itself. The function prototype for
  bli_?packm_struc_cxk() also needed updating.
- Reordered the last two parameters in bli_?packm_struc_cxk().
  (Previously, the "void* params" was passed in after the
  "const cntx_t* cntx", although because of the above bug the params
  argument wasn't actually present in the function definition.)
fgvanzee added a commit that referenced this pull request May 21, 2024
Details:
- Updated common.mk so that when --disable-shared option is given to
  configure:
  1. The -fPIC compiler flag is omitted from the individual
     configuration family members' CPICFLAGS variables (which are
     initialized in each subconfig's make_defs.mk file); and
  2. The BUILD_SYMFLAGS variable, which contains compiler flags needed
     to control the symbol export behavior, is left blank.
- The net result of these changes is that flags specific to shared
  library builds are only used when a shared library is actually
  scheduled to be built. Thanks to Nick Knight for reporting this issue.
- CREDITS file update.
- (cherry picked from commit 5f84130)

Updated configure to pass all shellcheck checks. (#729)

Details:
- Modified configure so that it passes all 'shellcheck' checks,
  disabling ones which we violate but which are just stylistic, or are
  special cases in our code.
- Miscellaneous other minor changes, such as rearranged redirections in
  long sed/perl pipes to look more natural.
- Whitespace tweaks.
- (cherry picked from 72c37eb)

Fixed bugs in scal2v ref kernel when alpha == 1. (#728)

Details:
- Fixed a typo bug in ref_kernels/1/bli_scal2v_ref.c where the
  conditional that was supposed to be checking for cases when alpha is
  equal to 1.0 (so that copyv could be used instead of scal2v) was
  instead erroneously comparing alpha against 0.0.
- Fixed another bug in the same function whereby BLIS_NO_CONJUGATE was
  erroneously being passed into copyv instead of the kernel's conjx
  parameter. This second bug was inert, however, due to the first bug
  since the "alpha == 0.0" case was already being handled, resulting in
  the code block never executing.
- (cherry picked from 60f3634)

Use 'void*' datatypes in kernel APIs. (#727)

Details:
- Migrated all kernel APIs to use void* pointers instead of float*,
  double*, scomplex*, and dcomplex* pointers. This allows us to define
  many fewer kernel function pointer types, which also makes it much
  easier to know which function pointer type to use at any given time.
  (For example, whereas before there was ?axpyv_ker_ft, ?axpyv_ker_vft,
  and axpyv_ker_vft, now there is just axpyv_ker_ft, which is equivalent
  so what axpyv_ker_vft used to be.)
- Refactored how kernel function prototypes and kernel function types
  are defined so as to reduce redundant code. Specifically, the
  function signatures (excluding cntx_t* and, in the case of level-3
  microkernels, auxinfo_t*) are defined in new headers named, for
  example, bli_l1v_ker_params.h. Those signatures are reused via macro
  instantiation when defining both kernel prototypes and kernel function
  types. This will hopefully make it a little easier to update, add, and
  manage kernel APIs going forward.
- Updated all reference kernels according to the aforementioned switch
  to void* pointers.
- Updated all optimzied kernels according to the aforementioned switch
  to void* pointers. This sometimes required renaming variables,
  inserting typecasting so that pointer arithmetic could continue to
  function as intended, and related tweaks.
- Updated sandbox/gemmlike according to the aforementioned switch to
  void* pointers.
- Renamed:
  - frame/1/bli_l1v_ft_ker.h    -> frame/1/bli_l1v_ker_ft.h
  - frame/1f/bli_l1f_ft_ker.h   -> frame/1f/bli_l1f_ker_ft.h
  - frame/1m/bli_l1m_ft_ker.h   -> frame/1m/bli_l1m_ker_ft.h
  - frame/3/bli_l1m_ft_ukr.h    -> frame/3/bli_l1m_ukr_ft.h
  - frame/3/bli_l3_sup_ft_ker.h -> frame/3/bli_l3_sup_ker_ft.h
  to better align with naming of neighboring files.
- Added the missing "void* params" argument to bli_?packm_struc_cxk() in
  frame/1m/packm/bli_packm_struc_cxk.c. This argument is being passed
  into the function from bli_packm_blk_var1(), but wasn't being "caught"
  by the function definition itself. The function prototype for
  bli_?packm_struc_cxk() also needed updating.
- Reordered the last two parameters in bli_?packm_struc_cxk().
  (Previously, the "void* params" was passed in after the
  "const cntx_t* cntx", although because of the above bug the params
  argument wasn't actually present in the function definition.)
- (cherry picked from fab18dc)

Use 'const' pointers in kernel APIs. (#722)

Details:
- Qualified all input-only data pointers in the various kernel APIs with
  the 'const' keyword while also removing 'restrict' from those kernel
  APIs. (Use of 'restrict' was maintained in kernel implementations,
  where appropriate.) This affected the function pointer types defined
  for all of the kernels, their prototypes, and the reference and
  optimized kernel definitions' signatures.
- Templatized the definitions of copys_mxn and xpbys_mxn static inline
  functions.
- Minor whitespace and style changes (e.g. combining local variable
  declaration and initialization into a single statement).
- Removed some unused kernel code left in 'old' directories.
- Thanks to Nisanth M P for helping to validate changes to the power10
  microkernels.
- (cherry picked from 93c63d1)
fgvanzee added a commit that referenced this pull request May 22, 2024
Details:
- Updated common.mk so that when --disable-shared option is given to
  configure:
  1. The -fPIC compiler flag is omitted from the individual
     configuration family members' CPICFLAGS variables (which are
     initialized in each subconfig's make_defs.mk file); and
  2. The BUILD_SYMFLAGS variable, which contains compiler flags needed
     to control the symbol export behavior, is left blank.
- The net result of these changes is that flags specific to shared
  library builds are only used when a shared library is actually
  scheduled to be built. Thanks to Nick Knight for reporting this issue.
- CREDITS file update.
- (cherry picked from 5f84130)

Updated configure to pass all shellcheck checks. (#729)

Details:
- Modified configure so that it passes all 'shellcheck' checks,
  disabling ones which we violate but which are just stylistic, or are
  special cases in our code.
- Miscellaneous other minor changes, such as rearranged redirections in
  long sed/perl pipes to look more natural.
- Whitespace tweaks.
- (cherry picked from 72c37eb)

Fixed bugs in scal2v ref kernel when alpha == 1. (#728)

Details:
- Fixed a typo bug in ref_kernels/1/bli_scal2v_ref.c where the
  conditional that was supposed to be checking for cases when alpha is
  equal to 1.0 (so that copyv could be used instead of scal2v) was
  instead erroneously comparing alpha against 0.0.
- Fixed another bug in the same function whereby BLIS_NO_CONJUGATE was
  erroneously being passed into copyv instead of the kernel's conjx
  parameter. This second bug was inert, however, due to the first bug
  since the "alpha == 0.0" case was already being handled, resulting in
  the code block never executing.
- (cherry picked from 60f3634)

Use 'void*' datatypes in kernel APIs. (#727)

Details:
- Migrated all kernel APIs to use void* pointers instead of float*,
  double*, scomplex*, and dcomplex* pointers. This allows us to define
  many fewer kernel function pointer types, which also makes it much
  easier to know which function pointer type to use at any given time.
  (For example, whereas before there was ?axpyv_ker_ft, ?axpyv_ker_vft,
  and axpyv_ker_vft, now there is just axpyv_ker_ft, which is equivalent
  so what axpyv_ker_vft used to be.)
- Refactored how kernel function prototypes and kernel function types
  are defined so as to reduce redundant code. Specifically, the
  function signatures (excluding cntx_t* and, in the case of level-3
  microkernels, auxinfo_t*) are defined in new headers named, for
  example, bli_l1v_ker_params.h. Those signatures are reused via macro
  instantiation when defining both kernel prototypes and kernel function
  types. This will hopefully make it a little easier to update, add, and
  manage kernel APIs going forward.
- Updated all reference kernels according to the aforementioned switch
  to void* pointers.
- Updated all optimzied kernels according to the aforementioned switch
  to void* pointers. This sometimes required renaming variables,
  inserting typecasting so that pointer arithmetic could continue to
  function as intended, and related tweaks.
- Updated sandbox/gemmlike according to the aforementioned switch to
  void* pointers.
- Renamed:
  - frame/1/bli_l1v_ft_ker.h    -> frame/1/bli_l1v_ker_ft.h
  - frame/1f/bli_l1f_ft_ker.h   -> frame/1f/bli_l1f_ker_ft.h
  - frame/1m/bli_l1m_ft_ker.h   -> frame/1m/bli_l1m_ker_ft.h
  - frame/3/bli_l1m_ft_ukr.h    -> frame/3/bli_l1m_ukr_ft.h
  - frame/3/bli_l3_sup_ft_ker.h -> frame/3/bli_l3_sup_ker_ft.h
  to better align with naming of neighboring files.
- Added the missing "void* params" argument to bli_?packm_struc_cxk() in
  frame/1m/packm/bli_packm_struc_cxk.c. This argument is being passed
  into the function from bli_packm_blk_var1(), but wasn't being "caught"
  by the function definition itself. The function prototype for
  bli_?packm_struc_cxk() also needed updating.
- Reordered the last two parameters in bli_?packm_struc_cxk().
  (Previously, the "void* params" was passed in after the
  "const cntx_t* cntx", although because of the above bug the params
  argument wasn't actually present in the function definition.)
- (cherry picked from fab18dc)

Use 'const' pointers in kernel APIs. (#722)

Details:
- Qualified all input-only data pointers in the various kernel APIs with
  the 'const' keyword while also removing 'restrict' from those kernel
  APIs. (Use of 'restrict' was maintained in kernel implementations,
  where appropriate.) This affected the function pointer types defined
  for all of the kernels, their prototypes, and the reference and
  optimized kernel definitions' signatures.
- Templatized the definitions of copys_mxn and xpbys_mxn static inline
  functions.
- Minor whitespace and style changes (e.g. combining local variable
  declaration and initialization into a single statement).
- Removed some unused kernel code left in 'old' directories.
- Thanks to Nisanth M P for helping to validate changes to the power10
  microkernels.
- (cherry picked from 93c63d1)
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

Successfully merging this pull request may close these issues.

6 participants