Commit c19c6a79 authored by Jean-Matthieu Gallard's avatar Jean-Matthieu Gallard
Browse files

KernelGen - minor Matmul macro improvements: remove 0 shift

parent 93b9dad7
......@@ -23,6 +23,16 @@
{# /**************************************
**** Set up helper template values ****
**************************************/ #}
{# replace 0 with '0' #}
{% if A_shift == 0 %}
{% set A_shift = '0' %}
{% endif %}
{% if B_shift == 0 %}
{% set B_shift = '0' %}
{% endif %}
{% if C_shift == 0 %}
{% set C_shift = '0' %}
{% endif %}
{% set conf = matmulConfigs[matmulKey] %}
{% if overrideUseLibxsmm is not defined or overrideUseLibxsmm == "BoolNotDefined" %}
{% set overrideUseLibxsmm = useLibxsmm %}{# if no override then take the current value #}
......@@ -78,12 +88,14 @@ volatile {{fpFormat}} doNotOptimizeAway_{{B}} = {{B}}[0]; //used to prevent the
#}
{% elif useEigen %}
{# old direct mapper #}
{#{
{#
{
Eigen::Map<Eigen::Matrix<{{fpFormat}},{{conf.M}},{{conf.K}}>, Eigen::{{"Aligned"if conf.alignment_A == 1 else "Unaligned"}}, Eigen::OuterStride<{{conf.LDA}}> > {{Ap}}_m({{A}}{% if A_shift != '0' %}+{{A_shift}}{% endif %}); //A = {{A}}
Eigen::Map<Eigen::Matrix<{{fpFormat}},{{conf.K}},{{conf.N}}>, Eigen::Aligned, Eigen::OuterStride<{{conf.LDB}}> > {{Bp}}_m({{trueB}}{% if B_shift != '0' %}+{{B_shift}}{% endif %}); //B = {{B}}, assume it is aligned
Eigen::Map<Eigen::Matrix<{{fpFormat}},{{conf.M}},{{conf.N}}>, Eigen::{{"Aligned"if conf.alignment_C == 1 else "Unaligned"}}, Eigen::OuterStride<{{conf.LDC}}> > {{Cp}}_m({{C}}{% if C_shift != '0' %}+{{C_shift}}{% endif %}); //C = {{C}}
{{Cp}}_m.noalias() {{ '+' if conf.beta == 1 }}= {{ '-' if conf.alpha == -1 }}{{Ap}}_m * {{Bp}}_m {% if (useTrueB and not forceCoeffMatrix) %}* {{trueAlpha}}{% endif %};
}#}
}
#}
#pragma forceinline recursive
{
new (&{{conf.baseroutinename}}_A_map) Eigen::Map<Eigen::Matrix<{{fpFormat}},{{conf.M}},{{conf.K}}>, Eigen::{{"Aligned"if conf.alignment_A == 1 else "Unaligned"}}, Eigen::OuterStride<{{conf.LDA}}> >({{A}}{% if A_shift != '0' %}+{{A_shift}}{% endif %}); //{{conf.baseroutinename}}_A_map = {{A}}
......@@ -111,7 +123,7 @@ for (int it = 0; it < {{conf.LDB*conf.K}}; it++) {
for (int it_1 = 0; it_1 < {{conf.N}}; it_1++) {
#pragma omp simd aligned({{Cp}}:ALIGNMENT)
for (int it_3 = 0; it_3 < {{conf.M}}; it_3++) {
{{C}}[{{C_shift}}+it_1*{{conf.LDC}}+it_3] = 0.;
{{C}}[{% if C_shift != '0' %}{{C_shift}}+{% endif %}it_1*{{conf.LDC}}+it_3] = 0.;
}
}
{% endif %}
......@@ -119,7 +131,7 @@ for (int it_1 = 0; it_1 < {{conf.N}}; it_1++) {
for (int it_2 = 0; it_2 < {{conf.K}}; it_2++) {
#pragma omp simd aligned({{Cp}},{{Ap}},{{trueBp}}:ALIGNMENT)
for (int it_3 = 0; it_3 < {{conf.M}}; it_3++) {
{{C}}[{{C_shift}}+it_1*{{conf.LDC}}+it_3] {{ '+' if conf.alpha == 1 else '-' }}= {{A}}[{{A_shift}}+it_2*{{conf.LDA}}+it_3] * {% if (useTrueB and not forceCoeffMatrix) %}{{trueAlpha}}* {% endif %}{{trueB}}[{% if B_shift != '0' %}{{B_shift}}+{% endif %}it_1*{{conf.LDB}}+it_2];
{{C}}[{% if C_shift != '0' %}{{C_shift}}+{% endif %}it_1*{{conf.LDC}}+it_3] {{ '+' if conf.alpha == 1 else '-' }}= {{A}}[{% if A_shift != '0' %}{{A_shift}}+{% endif %}it_2*{{conf.LDA}}+it_3] * {% if (useTrueB and not forceCoeffMatrix) %}{{trueAlpha}}* {% endif %}{{trueB}}[{% if B_shift != '0' %}{{B_shift}}+{% endif %}it_1*{{conf.LDB}}+it_2];
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment