You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is of course true that problemtools can't check for every possible footgun one can set up, but this particular one is very common, and I think a warning would be useful.
I've already discussed this with Fredrik and I'm kinda torn about it.
On one hand, yeah, this is a huge source of failing installs and forward incompatability.
On the other hand, when we design a problem, it's mainly for the contest at hand, where we want to ensure that our test data and time limit do not allow participants to trivially cheese the problem with the SIMD available on the judge. To do this, we write "trivial" SIMD solutions and ensure they do not get more points than they should.
So I would personally be slightly annoyed to get warnings, when I have proper tooling to check whether we have done the necessary workarounds to avoid compile errors for Kattis. However, since I've already made the plunge into having a custom fork of Problemtools, I wouldn't mind simply implementing the checks for checking whether it will work in Kattis there.
So yeah, I would be fine with it. And I do not think that we should bloat problemtools with flags such as --ignore-pragma-warnings, or --stip-pragmas.
Summoning @Tagl since you care about constant factor optimization and use problemtools a lot. If you're fine with it, I'll probably create a PR.
Generally the code will compile with these settings but running it will result in a SIGILL (Illegal Instruction).
We could have recommendations with examples on how to achieve this in different ways for the trivial and advanced cases.
I think the best thing to do would be to encourage people to write the solutions with function multiversioning or manual runtime dispatch coding.
I don't think it's that simple, though. For example, you really want to enable avx2 before including bitset.
We could encourage this pattern
#ifdef __AVX2__
#pragma GCC target("avx2")
#endif
But even that is not entirely sufficient because Kattis' GCC version has a compiler bug, and will cause a compile error when compiling bits/allocator.h even when avx2 should be supported.
I think for now, the simplest approach is just to add a warning for each submission that uses these architecture specific targeting.
Have you tested that pattern out? I'm fairly certain that the target statement is equivalent to the -mavx2 flag which is exactly what will define __AVX2__, therefore meaning you rely on circular logic.
Kattis has actually updated GCC version this week, so bits/allocator.h should no longer be an issue. I will do some testing, but surely there is a way to safely use the #pragma GCC target("avx2")...
I think the safe way to do it is runtime detection, but that means parts of the standard library won't get the features.
If you find a way to do it at compile time then I'm all for it.
Can also use -march=native in problemtools compiler flags, but this will introduce variance for task authors using different machines (maybe the good kind of variance).
Activity
Matistjati commentedon Apr 5, 2026
I've already discussed this with Fredrik and I'm kinda torn about it.
On one hand, yeah, this is a huge source of failing installs and forward incompatability.
On the other hand, when we design a problem, it's mainly for the contest at hand, where we want to ensure that our test data and time limit do not allow participants to trivially cheese the problem with the SIMD available on the judge. To do this, we write "trivial" SIMD solutions and ensure they do not get more points than they should.
So I would personally be slightly annoyed to get warnings, when I have proper tooling to check whether we have done the necessary workarounds to avoid compile errors for Kattis. However, since I've already made the plunge into having a custom fork of Problemtools, I wouldn't mind simply implementing the checks for checking whether it will work in Kattis there.
So yeah, I would be fine with it. And I do not think that we should bloat problemtools with flags such as
--ignore-pragma-warnings, or--stip-pragmas.Summoning @Tagl since you care about constant factor optimization and use problemtools a lot. If you're fine with it, I'll probably create a PR.
Tagl commentedon Jul 13, 2026
Generally the code will compile with these settings but running it will result in a SIGILL (Illegal Instruction).
We could have recommendations with examples on how to achieve this in different ways for the trivial and advanced cases.
I think the best thing to do would be to encourage people to write the solutions with function multiversioning or manual runtime dispatch coding.
See: https://web.archive.org/web/20200804021412/extensa.tech/blog/migrating-multiversioning/
Matistjati commentedon Jul 13, 2026
I don't think it's that simple, though. For example, you really want to enable avx2 before including bitset.
We could encourage this pattern
But even that is not entirely sufficient because Kattis' GCC version has a compiler bug, and will cause a compile error when compiling bits/allocator.h even when avx2 should be supported.
Tagl commentedon Jul 13, 2026
I think for now, the simplest approach is just to add a warning for each submission that uses these architecture specific targeting.
Have you tested that pattern out? I'm fairly certain that the target statement is equivalent to the -mavx2 flag which is exactly what will define
__AVX2__, therefore meaning you rely on circular logic.Matistjati commentedon Jul 13, 2026
Kattis has actually updated GCC version this week, so bits/allocator.h should no longer be an issue. I will do some testing, but surely there is a way to safely use the #pragma GCC target("avx2")...
Tagl commentedon Jul 13, 2026
I think the safe way to do it is runtime detection, but that means parts of the standard library won't get the features.
If you find a way to do it at compile time then I'm all for it.
Tagl commentedon Jul 13, 2026
Can also use -march=native in problemtools compiler flags, but this will introduce variance for task authors using different machines (maybe the good kind of variance).