From 549413abcaeb7033deb9ecfb10189a3aefb340ea Mon Sep 17 00:00:00 2001 From: Francois Coppens Date: Fri, 27 Jan 2023 15:24:52 +0100 Subject: [PATCH] Pulled out kernel template range so it can be set at the top, instead of at 8 different places throughout the code. --- org/qmckl_sherman_morrison_woodbury.org | 33 ++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/org/qmckl_sherman_morrison_woodbury.org b/org/qmckl_sherman_morrison_woodbury.org index a6d48fc..e0d14a0 100644 --- a/org/qmckl_sherman_morrison_woodbury.org +++ b/org/qmckl_sherman_morrison_woodbury.org @@ -26,6 +26,11 @@ int main() { qmckl_exit_code rc; #+end_src + #+NAME:kernel_generator_range + #+begin_src python :noweb yes :exports none +range(2, 22) + #+end_src + * Naïve Sherman-Morrison ** ~qmckl_sherman_morrison_naive~ @@ -280,13 +285,13 @@ static inline qmckl_exit_code qmckl_sherman_morrison_naive_{Dim}( - #+NAME:naive_template_generator + #+NAME:naive_kernel_generator #+begin_src python :noweb yes :exports none text=""" <> """ result = [] -for Dim in range(2, 22): +for Dim in <>: Dim=str(Dim) result.append(text.replace("{Dim}",Dim) ) @@ -297,7 +302,7 @@ return '\n'.join(result) - #+NAME:naive_switch_generator + #+NAME:naive_switch-case_generator #+begin_src python :noweb yes :exports none text=""" case {Dim}: @@ -310,7 +315,7 @@ case {Dim}: determinant); """ result = [] -for Dim in range(2, 22): +for Dim in <>: Dim=str(Dim) result.append(text.replace("{Dim}",Dim) ) @@ -322,7 +327,7 @@ return '\n'.join(result) #+begin_src c :tangle (eval c) :comments org :noweb yes -<> +<> qmckl_exit_code qmckl_sherman_morrison_naive(const qmckl_context context, const uint64_t LDS, @@ -343,7 +348,7 @@ qmckl_exit_code qmckl_sherman_morrison_naive(const qmckl_context context, if (LDS == (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH) { // Most cases switch (Dim) { - <> + <> } } else { // When SIMD_LENGTH > 1, called with LDS == Dim AND Dim != (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH) @@ -617,7 +622,7 @@ qmckl_exit_code qmckl_woodbury_2x2_hpc(const qmckl_context context, - #+NAME:woodbury_2x2_template_code + #+NAME:woodbury_2x2_kernel_template #+begin_src c static inline qmckl_exit_code qmckl_woodbury_2x2_{Dim}( const qmckl_context context, @@ -705,13 +710,13 @@ static inline qmckl_exit_code qmckl_woodbury_2x2_{Dim}( - #+NAME:woodbury_2x2_template_generator + #+NAME:woodbury_2x2_kernel_generator #+begin_src python :noweb yes :exports none text=""" -<> +<> """ result = [] -for Dim in range(2, 22): +for Dim in <>: Dim=str(Dim) result.append(text.replace("{Dim}",Dim) ) @@ -720,7 +725,7 @@ return '\n'.join(result) - #+NAME:woodbury_2x2_switch_generator + #+NAME:woodbury_2x2_switch-case_generator #+begin_src python :noweb yes :exports none text=""" case {Dim}: @@ -732,7 +737,7 @@ case {Dim}: determinant); """ result = [] -for Dim in range(2, 22): +for Dim in <>: Dim=str(Dim) result.append(text.replace("{Dim}",Dim) ) @@ -743,7 +748,7 @@ return '\n'.join(result) #+begin_src c :tangle (eval c) :comments org :noweb yes -<> +<> qmckl_exit_code qmckl_woodbury_2x2(const qmckl_context context, const uint64_t LDS, @@ -763,7 +768,7 @@ qmckl_exit_code qmckl_woodbury_2x2(const qmckl_context context, if (LDS == (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH) { // Most cases switch (Dim) { - <> + <> } } else { // When SIMD_LENGTH > 1, called with LDS == Dim AND Dim != (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH)