From f718ab4778d37fa58770ef1f890af744b05b98b0 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 16:10:43 +0200 Subject: [PATCH 1/7] Delete XXX_comp_datatype since it is redundant wrt the call to contraction --- proposal2a.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/proposal2a.md b/proposal2a.md index 7469672..ab5000f 100644 --- a/proposal2a.md +++ b/proposal2a.md @@ -21,13 +21,7 @@ typedef enum ... } XXX_datatype; -typedef enum -{ - XXX_TYPE_F32_F32_ACCUM_F32 = XXX_TYPE_F32, - ... -} XXX_comp_datatype; ``` -Enumerations for the supported storage and computational datatypes. Not all combinations are required to be supported. ```C typedef /* unspecified */ XXX_error; // Should be a trivial type, e.g. "int" From b428611907c1a35063653d592757accb3b777b9f Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 16:11:14 +0200 Subject: [PATCH 2/7] Adapt the ERROR infrastructure modelled after MPI --- proposal2a.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/proposal2a.md b/proposal2a.md index ab5000f..41a1aac 100644 --- a/proposal2a.md +++ b/proposal2a.md @@ -23,14 +23,18 @@ typedef enum ``` -```C -typedef /* unspecified */ XXX_error; // Should be a trivial type, e.g. "int" - -int XXX_error_check(XXX_error err); // return non-zero on error -const char* XXX_error_explain(XXX_error err); - -void XXX_error_clear(XXX_error err); +```C +enum XXX_ERROR { + XXX_SUCCESS, + XXX_FAIL, + // ... more to come +} + +// The error explain function should not allocate the error string itself +// for security concerns. +// Adapted from the function MPI_Error_string +XXX_ERROR XXX_error_explain(XXX_ERROR err, const char* error_string, &error_size); ``` Error handling --- implementation defined. From f5d2af92710698ad4af9c96ec214a00c12ab822a Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 16:30:51 +0200 Subject: [PATCH 3/7] Add missing XXX_MAX_ERROR_STRING --- proposal2a.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proposal2a.md b/proposal2a.md index 41a1aac..77118d3 100644 --- a/proposal2a.md +++ b/proposal2a.md @@ -34,7 +34,10 @@ enum XXX_ERROR { // The error explain function should not allocate the error string itself // for security concerns. // Adapted from the function MPI_Error_string -XXX_ERROR XXX_error_explain(XXX_ERROR err, const char* error_string, &error_size); +XXX_ERROR XXX_error_explain(XXX_ERROR err, char *error_string, int *error_size); + +// Additionally one has to define as in MPI a MAX_ERROR_STRING +#define XXX_MAX_ERROR_STRING 512 /* implementation dependent */ ``` Error handling --- implementation defined. From 2509bc829ca96b9b6a249681f62d180645d6195e Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 16:31:26 +0200 Subject: [PATCH 4/7] Add some cosmetic changes --- proposal2a.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/proposal2a.md b/proposal2a.md index 77118d3..2c605ec 100644 --- a/proposal2a.md +++ b/proposal2a.md @@ -45,24 +45,38 @@ Error handling --- implementation defined. typedef /* unspecified */ XXX_attr; // Requires initialization. E.g. "struct XXX_attr_internal*" typedef int32_t XXX_key; // Some values should be reserved for standardization -XXX_error XXX_attr_init(XXX_attr* attr); +XXX_ERROR XXX_attr_init(XXX_attr *attr); -XXX_error XXX_attr_destroy(XXX_attr* attr); +XXX_ERROR XXX_attr_destroy(XXX_attr *attr); -XXX_error XXX_attr_set(XXX_attr* attr, XXX_key, void* value); +XXX_ERROR XXX_attr_set(XXX_attr *attr, XXX_key key, void *value); -XXX_error XXX_attr_get(XXX_attr* attr, XXX_key, void** value); +XXX_ERROR XXX_attr_get(XXX_attr *attr, XXX_key key, void **value); -XXX_error XXX_attr_clear(XXX_attr* attr, XXX_key); +XXX_ERROR XXX_attr_clear(XXX_attr *attr, XXX_key key); ``` + + Implementation defined (and maybe some standard) attributes, loosely based on MPI. +## Contract operation + +- The datatype of the $\alpha$ might be different than the one of the tensor A + to allow for mixed precision algorithms, or complex-real products. + +- +```C + A["abcd"] = B["ab"] * C["cd"] + int nmode_A = 4; + XXX_entent idx_A[4] = {'a', 'b', 'c', 'd'}; +``` + ```C // Unary and binary element-wise operations (transpose, scale, norm, reduction, etc.) should also be defined! // Compute D_{idx_D} = alpha * A_{idx_A} * B_{idx_B} + beta * C_{idx_C} -XXX_error +XXX_ERROR XXX_contract(const void* alpha, XXX_datatype type_alpha, const void* A, From 036d2ad3034fe193c9f74cbae671735eb294cd09 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 16:31:38 +0200 Subject: [PATCH 5/7] Change attr in contract call to be passed by reference The XXX_atr implementation defined structure might be a very big object and we don't want to incurr in copy overheads --- proposal2a.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposal2a.md b/proposal2a.md index 2c605ec..81391b7 100644 --- a/proposal2a.md +++ b/proposal2a.md @@ -105,7 +105,7 @@ XXX_contract(const void* alpha, const XXX_extent* shape_D, const XXX_stride* stride_D, const XXX_index* idx_D, - XXX_comp_datatype comp_type, - XXX_attr attr); + XXX_datatype comp_type, + XXX_attr* attr); ``` From efff48a9f67ee07acd2cdad71d384b726bae2903 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 17:04:10 +0200 Subject: [PATCH 6/7] Document further and standarize the contract@proposal2a --- proposal2a.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/proposal2a.md b/proposal2a.md index 81391b7..5782c70 100644 --- a/proposal2a.md +++ b/proposal2a.md @@ -64,13 +64,28 @@ Implementation defined (and maybe some standard) attributes, loosely based on MP - The datatype of the $\alpha$ might be different than the one of the tensor A to allow for mixed precision algorithms, or complex-real products. -- +- Example: ```C A["abcd"] = B["ab"] * C["cd"] int nmode_A = 4; XXX_entent idx_A[4] = {'a', 'b', 'c', 'd'}; ``` +1. When `C` is `NULL`, the standard specifies that it should not do the sum. +2. Allow for aliasing of `C` and `D` pointers **if** `idx_C` and `idx_D` are equal. +3. Allow for `A` and `B` **at the same time** to be `NULL`, provided `C` is not `NULL`. + In this case, the operation should be interpreted as a scaling of `C`. + In particular, the transpose operation is also implementable like this. + + Example: + ```C++ + // Scaling + D["ijij"] = 2 * C["ijij"] + + // transposition (C → D) + D["ij"] = C["ji"] + ``` + ```C // Unary and binary element-wise operations (transpose, scale, norm, reduction, etc.) should also be defined! From e2afaddd11b08a716cbb57aadf21e459d560b03e Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Thu, 23 May 2024 17:04:29 +0200 Subject: [PATCH 7/7] Add additional notes --- notes-23-05-2024.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 notes-23-05-2024.md diff --git a/notes-23-05-2024.md b/notes-23-05-2024.md new file mode 100644 index 0000000..7657121 --- /dev/null +++ b/notes-23-05-2024.md @@ -0,0 +1,14 @@ +# Notes on the past proposals +- Alexander Heinecke +- Oguz Kaya +- Paul Kelly +- Justin Turney +- Lucas Visscher +- Alejandro Gallo + +## Proposal 2b + +We decided that proposal 2b because there is no need to expose +this level of detail to the user. We can use the 2a `contract` +call in order to call implementation dependent routines of the form +of 2b.