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

HAT feedback 1/26 #4

Merged
merged 5 commits into from
Jan 27, 2021
Merged

Conversation

masonremy
Copy link
Contributor

No description provided.

@masonremy masonremy changed the title Dev/masonremy/hat feedback update 1 26 HAT feedback 1/26 Jan 27, 2021
README.md Outdated

A library in the HAT format typically includes one `.lib` file and one or more `.hat` files. The `.lib` file contains all the compiled object code that implements the library functions. Each `.hat` file contains a combination of standard C function declarations (like a typical `.h` file) and metadata in the TOML markup language. The metadata that accompanies each function declaration describes how the function should be called and how it was implemented. The metadata is intended to be both human-readable and machine-readable, providing structured and systematic documentation and allowing downstream tools to examine the library contents.
A library in the HAT format typically includes one static library file (`.a` or `.lib`) and one or more `.hat` files. The static library contains all the compiled object code that implements the library functions. Each `.hat` file contains a combination of standard C function declarations (like a typical `.h` file) and metadata in the TOML markup language. The metadata that accompanies each function declaration describes how the function should be called and how it was implemented. The metadata is intended to be both human-readable and machine-readable, providing structured and systematic documentation and allowing downstream tools to examine the library contents.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

delineate the 4 possibilities - { Windows, Posix } x { static, dynamic } - give specifics about Windows vs Posix and static vs dynamic. Core concept is all the implementations are in one place.

  • "hat library" -> "hat package" everywhere

  • machine code file

  • binary code file

  • ?

Copy link
Contributor

Choose a reason for hiding this comment

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

with static libraries, the C runtime library used is also important. architecture is also important, but for different reasons between posix and windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these ideas get encapsulated in the "required" and "dependencies" sections of the schema, do you think they should be discussed more in the README?

README.md Outdated
@@ -2,9 +2,9 @@

# HAT file format

HAT is a format for distributing compiled libraries in the C programming language. HAT stands for "h-file Annotated with Toml", and implies that standard C header files are decorated with useful metadata in the [TOML](https://toml.io/) markup language.
HAT is a format for distributing compiled libraries in the C programming language. HAT stands for "C **H**eader **A**nnotated with **T**OML", and implies that standard C header files are decorated with useful metadata in the [TOML](https://toml.io/) markup language.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drop the "C" in the acronym expansion

@@ -5,15 +5,19 @@ comment = "Automatically generated by the RoboCode compiler"
author = "John Doe"
version = "1.2.3.5"
license_url = "https://www.apache.org/licenses/LICENSE-2.0.html"
library_name = "sample_gemm.lib"
library_md5 = "ABCD1234..."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't address windows dynamic case appropriately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unnecessary if the function names are unique - not part of HAT specification

Copy link
Contributor

Choose a reason for hiding this comment

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

all function names HAVE to be unique if this is a C header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, my comment didn't have the necessary context - unique here is in the context of a single function over the course of multiple re-generations of the package. If the function names are given a new GUID every time the package is generated then the package doesn't need any further identifying information since the name of the function is strongly tied to the instance of the generated package, but if the names are constant over multiple re-generations then the producer and consumer of the HAT package need to determine for themselves whether the .hat file and the associated library file are in sync

@@ -5,15 +5,19 @@ comment = "Automatically generated by the RoboCode compiler"
author = "John Doe"
version = "1.2.3.5"
license_url = "https://www.apache.org/licenses/LICENSE-2.0.html"
library_name = "sample_gemm.lib"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

move to dependencies, name it something more specific indicating that this is the file to link against. Also include reference to dll or other files to deploy

'link_target'

Copy link
Contributor

Choose a reason for hiding this comment

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

if we're talking about deployment scenarios, in windows you also need to deploy additional files (like .manifest files)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i added that as a "deploy_files" field. I was mostly thinking of it in the context of .dll files, but manifest files (and surely there are others) are another good example

schema/hat.tosd Outdated
# The calling convention for this function
[types.functionType.calling_convention]
type = "string"
allowedvalues = [ "__stdcall", "__cdecl", "__fastcall", "__vectorcall" ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove leading underscores


[functions]
[functions.GEMM_B94D27B9934D3E08]
name = "GEMM_B94D27B9934D3E08"
description = "CPU Implementation of the GEMM algorithm: C = alpha * (A * B) + beta * C with specific sizes."
calling_convention = "__stdcall"
can_assert = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can't enforce this in C so we can't guarantee that downstream components also hold to this.
change values to "true" vs "unknown" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove can_assert, take as an action item for hat vnext:

  • how do we add a sound/complete set of constraints and validity checks on arguments.
  • can_assert vs "is_checked" vs "can_be_null" etc on individual arguments

{ name = "A", description = "left-hand input matrix", logical_type = "affine_array", declared_type = "const float*", element_type = "float", usage = "input", layout = { affine_array = { shape = [ 512, 256 ], affine_map = [ 256, 1 ], affine_offset = 0 } } },
{ name = "B", description = "right-hand input matrix", logical_type = "affine_array", declared_type = "const float*", element_type = "float", usage = "input", layout = { affine_array = { shape = [ 256, 512 ], affine_map = [ 512, 1 ], affine_offset = 0 } } },
{ name = "C", description = "result accumulation matrix", logical_type = "affine_array", declared_type = "float*", element_type = "float", usage = "input_output", layout = { affine_array = { shape = [ 512, 512 ], affine_map = [ 512, 1 ], affine_offset = 0 } } },
{ name = "A", description = "left-hand input matrix", logical_type = "affine_array", declared_type = "const float*", element_type = "float", usage = "input", shape = [ 512, 256 ], affine_map = [ 256, 1 ], affine_offset = 0 },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hat validator confirming collection of optional keys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(hat TOML schema validator + hat package/library second tier validator that is common utility code provided as part of general hat repo)

@@ -290,9 +292,10 @@ version = "0.0.0.1"
type = "table"
optional = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add gpu cache section, action item to account for controllable L1 vs shared memory

l1_KB = 32
l2_KB = 256
l3_KB = 56320
sizes_KB = [ 32, 256, 56320 ]
Copy link
Contributor Author

@masonremy masonremy Jan 27, 2021

Choose a reason for hiding this comment

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

(for gpu) : max_sizes_KB to address scalable L1 vs shared memory case?

  • continue discussion - is specific hardware target vs hardware characteristics the best option?
  • some users can use specific hardware, but some HAT users might not

l2_KB = 256
l3_KB = 56320
sizes_KB = [ 32, 256, 56320 ]
line_sizes = [ 64, 64, 64 ]

[dependencies]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make notes in samples and schema discussing the difference between dependencies and compiled_with

@masonremy masonremy merged commit 00f21bc into main Jan 27, 2021
@lisaong lisaong deleted the dev/masonremy/hat_feedback_update_1_26 branch January 5, 2022 07:46
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.

2 participants