llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

Use VLAs when possible

Open Rhialto opened this issue 1 year ago • 1 comments

Regarding https://github.com/ggerganov/llama.cpp/pull/918#issuecomment-1505633286 , and https://github.com/ggerganov/llama.cpp/pull/918#issuecomment-1505599905 and #881, here is another way: use VLAs instead of alloca, when possible.

It uses __STDC_NO_VLA__ to detect if VLAs are unavailable, in which case it falls back to alloca. In that case the program is still not a strictly conforming C program, and the -std=c11 argument to gcc may evoke warnings, but on the other hand, gcc is quite likely to support VLAs in practice.

Rhialto avatar Apr 12 '23 18:04 Rhialto

Well, like I mentioned before: another option is to stop claiming the program is Standard C (as expressed by -std=c11 and -std=c++11) and instead admit it isn't: -std=gnu11 and -std=gnu++11. Whichever is more important to you.

Rhialto avatar Apr 17 '23 20:04 Rhialto