-
Notifications
You must be signed in to change notification settings - Fork 12.2k
ggml : fix MIN / MAX macros #6904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ggml-ci
Hi Georgi, This patch just made me notice that your MIN/MAX macros are defined without a preliminary copy so that one term is evaluated twice:
I had a quick look at the code and overall it looks safe (i.e. no "x++" there), though there are a few occurrences of function calls, which I think are not in fast paths. This can be something newcomers will not necessarily notice and some might get trapped however. How about using the more robust compound expressions instead, typically something like this:
|
Yes, would you like to submit a PR? |
If that really saves you time I'll do it, but just not right now. If it's painless enough for you to copy-paste these few lines and commit them yourself, that's way faster for me, no need to even credit me, I don't care. I'm terribly bad with github, every tiny operation in it takes me one hour. However I would definitely go through it for larger patches. |
No worries - it's easier for me to push the change myself. Thanks |
|
Yeah, with clang I get these errors:
So looks like it's not very portable unfortunately as proposed |
@slaren which ones do you have in mind ? I'm using this on fairly old gcc 3.4+ for example, but admittedly I'm not using compilers found on non-unix systems. |
From what I can tell, |
Ah it didn't take long :-( Stange, for me clang-13 on linux supports it. |
So just for the record, for me on my local tests it's OK from gcc-3.4 to gcc-13.2, and on clang-3.8 and clang-13, both C and C++. It's possible that it's blocked by one of the build options (and I understand that you may not want to adjust them for portability reasons, e.g. if it's not available on windows for example). There are probably other approaches such as using "auto" on recent compilers, not sure if these would work here. |
OK, bad idea, "type defaults to int" says gcc-13.2. Let's leave this at rest for now, I really need to finish other stuff. Sorry for not having better to propose for now. |
No problem - at the very least I will be more careful what I put in the MIN/MAX arguments from now on :) |
No description provided.