Earlier quoted context omitted.
It does make sense that ChatGPT can beat gcc (or any compiler really); the compiler is forced to optimise code so that it still appears to work as if it's the source you wrote. Most importantly, if there are observable side-effects, compilers must preserve them, even though you know you don't actually care about them. An AI is not bound to preserve those, and can semantically change what you wrote, so long as the one…
It seems like compilers should have an interactive mode where it suggests code that is very similar but not technically perfectly the same that is more efficient and the can accept or decline the alternate version.
Large Language Models for Compiler Optimization
41–50 of 119 posts
Re: Large Language Models for Compiler Optimization
#42Earlier quoted context omitted.
Do you know why that policy is in place? Is it fear that the llm provider will steal company trade knowledge?
It's probably both that is leaking your source out and the risk of it being a copyright violation if it spits out some GPL source verbatim and you check it in.
Does that ever actually happen? I've only heard of it happening to people who forced the AI's hand by including the comments for said code in the prompt.
Re: Large Language Models for Compiler Optimization
#43Chatgpt4 can do source to source optimization which is pretty cool. I got it to beat gcc at -03 on simple small toy problems. and it can do similar things with python also. But it threw its hands up when I gave it a longer piece of code to optimize.
Re: Large Language Models for Compiler Optimization
#44Earlier quoted context omitted.
It's probably both that is leaking your source out and the risk of it being a copyright violation if it spits out some GPL source verbatim and you check it in.
> if it spits out some GPL source verbatim Does that ever actually happen? I've only heard of it happening to people who forced the AI's hand by including the comments for said code in the prompt.
Re: Large Language Models for Compiler Optimization
#45Earlier quoted context omitted.
It's probably both that is leaking your source out and the risk of it being a copyright violation if it spits out some GPL source verbatim and you check it in.
> if it spits out some GPL source verbatim Does that ever actually happen? I've only heard of it happening to people who forced the AI's hand by including the comments for said code in the prompt.
Re: Large Language Models for Compiler Optimization
#46⸻
1. Although I also find myself thinking about my kids as they were developing language where they initially correctly conjugated some common irregular verbs, then they started conjugating them as if they were regular and then finally returned to correctly conjugating them, which might be what’s happening with ChatGPT and math.
Re: Large Language Models for Compiler Optimization
#47“generating compilable code 91% of the time” which means that almost ten percent of the time, it doesn’t generate compilable code. Given the fact that ChatGPT has gotten worse at math over time,¹ I’m wondering if this too will get worse. ⸻ 1. Although I also find myself thinking about my kids as they were developing language where they initially correctly conjugated some common irregular verbs, then they started conj…
Re: Large Language Models for Compiler Optimization
#48Chatgpt4 can do source to source optimization which is pretty cool. I got it to beat gcc at -03 on simple small toy problems. and it can do similar things with python also. But it threw its hands up when I gave it a longer piece of code to optimize.
#include
int main(void) {
int i;
int a[2000] ;
for(i = 0; i
This program initializes an array `a` of size 2000, populates it with integers from 0 to 1999, and then prints the value at index 5, which is 5.Just as with the Python program, we can optimize this program significantly. Given that we're only interested in the sixth element (index 5) of the array, we don't need to construct and populate the entire array.
Here's an optimized version of the code:
#include
int main(void) {
printf("%d\n", 5);
}Re: Large Language Models for Compiler Optimization
#49Earlier quoted context omitted.
It seems like a poor fit to me precisely because correctness is boolean, difficult to measure and getting it wrong is very bad. I do think there's a place for AI here but it's probably not LLMs in their current form.
They are not using LLM to directly produce the result code, but as tool that lists which optimisations should be done and in which order, which is fairly complex problem to solve. But if optimisation passes are implemented correctly (which is anyway required for a functioning optimising compiler), it cannot produce incorrect code, maybe only suboptimal compared to default heuristics used.
Re: Large Language Models for Compiler Optimization
#50Chatgpt4 can do source to source optimization which is pretty cool. I got it to beat gcc at -03 on simple small toy problems. and it can do similar things with python also. But it threw its hands up when I gave it a longer piece of code to optimize.
The toy example for those curious: #include int main(void) { int i; int a[2000] ; for(i = 0; i This program initializes an array `a` of size 2000, populates it with integers from 0 to 1999, and then prints the value at index 5, which is 5. Just as with the Python program, we can optimize this program significantly. Given that we're only interested in the sixth element (index 5) of the array, we don't need to construc…