Skip to content

Implement proposed new function pointer fields for obj_t.#527

Merged
devinamatthews merged 4 commits intomasterfrom
obj_t_makeover
Aug 14, 2021
Merged

Implement proposed new function pointer fields for obj_t.#527
devinamatthews merged 4 commits intomasterfrom
obj_t_makeover

Conversation

@devinamatthews
Copy link
Copy Markdown
Member

@devinamatthews devinamatthews commented Aug 11, 2021

The added fields:

  1. pack_t schema: storing the pack schema on the object allows the macrokernel to act accordingly without side-channel information from the rntm_t and cntx_t. The pack schema and "pack_[ab]" fields could be removed from those structs.
  2. void* user_data: this field can be used to store any sort of additional information provided by the user. The pointer is propagated to submatrix objects and copies, but is otherwise ignored by the framework and the default implementations of the following three fields. User-specified pack, kernel, or ukr functions can do whatever they want with the data, and the user is 100% responsible for allocating, assigning, and freeing this buffer.
  3. obj_pack_fn_t pack: the function called when a matrix is packed. This functions receives the expected arguments, as well as a mdim_t and mem_t* as memory must be allocated inside this function, and behavior may differ based on which matrix is being backed (i.e. transposition for B). This could also be achieved by passing a desired pack schema, but this would require additional information to travel down the control tree.
  4. obj_ker_fn_t ker: the function called when we get to the "second loop", or the macro-kernel. Behavior may depend on the pack schemas of the input matrices. The default implementation would perform the inner two loops around the ukr, and then call either the default ukr or a user-supplied one (next field).
  5. obj_ukr_fn_t ukr: the function called by the default macrokernel. This would replace the various current "virtual" microkernels, and could also be used to supply user-defined behavior. Users could supply both a custom kernel (above) and microkernel, although the user-specified kernel does not necessarily have to call the ukr function specified on the obj_t.

Note that no macros or functions for accessing these new fields have been defined yet. That is next once these are finalized. Addresses https://github.com/flame/blis/projects/1#card-62357687.

@devinamatthews
Copy link
Copy Markdown
Member Author

I guess I should have made sure it build first :). I'll force-push a working version.

The added fields:
1. `pack_t schema`: storing the pack schema on the object allows the macrokernel to act accordingly without side-channel information from the rntm_t and cntx_t. The pack schema and "pack_[ab]" fields could be removed from those structs.
2. `void* user_data`: this field can be used to store any sort of additional information provided by the user. The pointer is propagated to submatrix objects and copies, but is otherwise ignored by the framework and the default implementations of the following three fields. User-specified pack, kernel, or ukr functions can do whatever they want with the data, and the user is 100% responsible for allocating, assigning, and freeing this buffer.
3. `obj_pack_fn_t pack`: the function called when a matrix is packed. This functions receives the expected arguments, as well as a mdim_t and mem_t* as memory must be allocated inside this function, and behavior may differ based on which matrix is being backed (i.e. transposition for B). This could also be achieved by passing a desired pack schema, but this would require additional information to travel down the control tree.
4. `obj_ker_fn_t ker`: the function called when we get to the "second loop", or the macro-kernel. Behavior may depend on the pack schemas of the input matrices. The default implementation would perform the inner two loops around the ukr, and then call either the default ukr or a user-supplied one (next field).
5. `obj_ukr_fn_t ukr`: the function called by the default macrokernel. This would replace the various current "virtual" microkernels, and could also be used to supply user-defined behavior. Users could supply both a custom kernel (above) and microkernel, although the user-specified kernel does **not** necessarily have to call the ukr function specified on the obj_t.

Note that no macros or functions for accessing these new fields have been defined yet. That is next once these are finalized. Addresses https://github.com/flame/blis/projects/1#card-62357687.
@devinamatthews devinamatthews marked this pull request as ready for review August 13, 2021 19:46
@devinamatthews
Copy link
Copy Markdown
Member Author

@fgvanzee I've made the changes we discussed. Ready for you to check formatting.

struct obj_s;
struct cntx_s;
struct rntm_s;
struct thrinfo_s;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I didn't notice these during our Zoom review. Is this part of resolving the circular dependency?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are they needed? What would happen if you removed them?

I feel like in past situations like this, I was able to get by without them, though I defer to you as to explaining why that might have been.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

struct obj_s is definitely needed. The others are also needed unless you want to change the order in which the headers are included in blis.h.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, in C maybe you can omit them? I am used to C++ where there is an actual type system :).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

When you remove them you get:

include/haswell/blis.h:1880:14: warning: declaration of 'struct obj_s' will not be visible outside of this function [-Wvisibility]
      struct obj_s* a,
             ^

which isn't technically an error but doesn't sound good.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed, we should leave them in. I was just curious.

@devinamatthews
Copy link
Copy Markdown
Member Author

@fgvanzee are you ready for merge after the whitespace tweaks?

@fgvanzee
Copy link
Copy Markdown
Member

@fgvanzee are you ready for merge after the whitespace tweaks?

Yarrr.

@devinamatthews devinamatthews merged commit 2c0b415 into master Aug 14, 2021
fgvanzee added a commit that referenced this pull request Aug 20, 2021
Details:
- Moved miscellaneous language-related definitions, including defs
  related to the handling of the 'restrict' keyword, from the top half
  of bli_macro_defs.h into a new file, bli_lang_defs.h, which is now
  #included immediately after "bli_system.h" in blis.h. This change is
  an attempt to fix a report of recent breakage of C++ compilers due
  to the recent introduction of 'restrict' in bli_type_defs.h (which
  previously was being included *before* bli_macro_defs.h and its
  restrict handling therein. Thanks to Ivan Korostelev for reporting
  this issue in #527.
- CREDITS file update.
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.

3 participants