1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 20:42:50 +01:00

Pulled out kernel template range so it can be set at the top,

instead of at 8 different places throughout the code.
This commit is contained in:
Francois Coppens 2023-01-27 15:24:52 +01:00
parent c58cf3c7f6
commit 549413abca

View File

@ -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="""
<<naive_template_code>>
"""
result = []
for Dim in range(2, 22):
for Dim in <<kernel_generator_range>>:
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 <<kernel_generator_range>>:
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
<<naive_template_generator()>>
<<naive_kernel_generator()>>
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) {
<<naive_switch_generator()>>
<<naive_switch-case_generator()>>
}
}
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="""
<<woodbury_2x2_template_code>>
<<woodbury_2x2_kernel_template>>
"""
result = []
for Dim in range(2, 22):
for Dim in <<kernel_generator_range>>:
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 <<kernel_generator_range>>:
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
<<woodbury_2x2_template_generator()>>
<<woodbury_2x2_kernel_generator()>>
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) {
<<woodbury_2x2_switch_generator()>>
<<woodbury_2x2_switch-case_generator()>>
}
}
else { // When SIMD_LENGTH > 1, called with LDS == Dim AND Dim != (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH)