mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-22 12:23:56 +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:
parent
c58cf3c7f6
commit
549413abca
@ -26,6 +26,11 @@ int main() {
|
|||||||
qmckl_exit_code rc;
|
qmckl_exit_code rc;
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+NAME:kernel_generator_range
|
||||||
|
#+begin_src python :noweb yes :exports none
|
||||||
|
range(2, 22)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Naïve Sherman-Morrison
|
* Naïve Sherman-Morrison
|
||||||
|
|
||||||
** ~qmckl_sherman_morrison_naive~
|
** ~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
|
#+begin_src python :noweb yes :exports none
|
||||||
text="""
|
text="""
|
||||||
<<naive_template_code>>
|
<<naive_template_code>>
|
||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
for Dim in range(2, 22):
|
for Dim in <<kernel_generator_range>>:
|
||||||
Dim=str(Dim)
|
Dim=str(Dim)
|
||||||
result.append(text.replace("{Dim}",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
|
#+begin_src python :noweb yes :exports none
|
||||||
text="""
|
text="""
|
||||||
case {Dim}:
|
case {Dim}:
|
||||||
@ -310,7 +315,7 @@ case {Dim}:
|
|||||||
determinant);
|
determinant);
|
||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
for Dim in range(2, 22):
|
for Dim in <<kernel_generator_range>>:
|
||||||
Dim=str(Dim)
|
Dim=str(Dim)
|
||||||
result.append(text.replace("{Dim}",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
|
#+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,
|
qmckl_exit_code qmckl_sherman_morrison_naive(const qmckl_context context,
|
||||||
const uint64_t LDS,
|
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
|
if (LDS == (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH) { // Most cases
|
||||||
switch (Dim) {
|
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)
|
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
|
#+begin_src c
|
||||||
static inline qmckl_exit_code qmckl_woodbury_2x2_{Dim}(
|
static inline qmckl_exit_code qmckl_woodbury_2x2_{Dim}(
|
||||||
const qmckl_context context,
|
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
|
#+begin_src python :noweb yes :exports none
|
||||||
text="""
|
text="""
|
||||||
<<woodbury_2x2_template_code>>
|
<<woodbury_2x2_kernel_template>>
|
||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
for Dim in range(2, 22):
|
for Dim in <<kernel_generator_range>>:
|
||||||
Dim=str(Dim)
|
Dim=str(Dim)
|
||||||
result.append(text.replace("{Dim}",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
|
#+begin_src python :noweb yes :exports none
|
||||||
text="""
|
text="""
|
||||||
case {Dim}:
|
case {Dim}:
|
||||||
@ -732,7 +737,7 @@ case {Dim}:
|
|||||||
determinant);
|
determinant);
|
||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
for Dim in range(2, 22):
|
for Dim in <<kernel_generator_range>>:
|
||||||
Dim=str(Dim)
|
Dim=str(Dim)
|
||||||
result.append(text.replace("{Dim}",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
|
#+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,
|
qmckl_exit_code qmckl_woodbury_2x2(const qmckl_context context,
|
||||||
const uint64_t LDS,
|
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
|
if (LDS == (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH) { // Most cases
|
||||||
switch (Dim) {
|
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)
|
else { // When SIMD_LENGTH > 1, called with LDS == Dim AND Dim != (1+(Dim-1)/SIMD_LENGTH)*SIMD_LENGTH)
|
||||||
|
Loading…
Reference in New Issue
Block a user