kpu/intgemm

Can't include callbacks.h before kernels.h.

Closed this issue · 1 comments

kpu commented

Try writing a file that does

#include "callbacks.h"

You'll get

In file included from /home/kpu/intgemm/callbacks/sse2.h:4,
                 from /home/kpu/intgemm/callbacks.h:6,
                 from /home/kpu/intgemm/multiply.h:7,
                 from /home/kpu/intgemm/prepare_bias_print.cc:2:
/home/kpu/intgemm/callbacks/implementations.inl:19:4: error: #error "Only SSE2, AVX2 and AVX512BW are supported"
   19 |   #error "Only SSE2, AVX2 and AVX512BW are supported"
      |    ^~~~~

Which is really confusing.

What's going on is that

#define THIS_IS_SSE2
defines THIS_IS_SSE2 as you'd expect.
Then we get into callbacks/implementations.inl which does this
#include "kernels.h"

including kernels.h. Internally, kernels.h includes kernels/sse2.h which defines THIS_IS_SSE2 then undefines THIS_IS_SSE2
#undef THIS_IS_SSE2

So #include "kernels.h" undefines THIS_IS_SSE2 which leaves https://github.com/kpu/intgemm/blob/master/callbacks/implementations.inl without the macro to use. But only if kernels.h was not included already.

I think we can fix it in two ways: make separated defines names for callbacks and kernels or add some checks and undefining only if we define name in the same file. But I think the first approach is better. I'll make a commit for a moment.