Re: Question About GPU-Powered Parallel Compilation in GCC

2025-05-13 Thread Richard Biener via Gcc
On Tue, May 13, 2025 at 12:51 PM Andrew Stubbs  wrote:
>
> On 12/05/2025 15:27, Nikhil Patil via Gcc wrote:
> > Hi Richard,
> >
> > Thank you so much for the reply!
> >
> > You're absolutely right about using CPU threads. I’m just really curious
> > about whether GPU acceleration could somehow be explored for compilation,
> > even if it’s not traditionally well-suited. I know it might not be
> > practical, but I wanted to understand *why* it’s considered inefficient and
> > learn through experimentation.
>
> To run fast on a GPU it's not enough to be able to parallelize the code,
> you need to *vectorize* it. Not much of a compiler vectorizes well.

data-flow analysis would be one theoretical target, but data structures
involved are currently not at all GPU friendly and I fear there's much
divergence in control flow for effective GPU parallelization even for
those theoretically "parallelizable" algorithms.

And there's of course the setup/tear-down cost, which for common
workload sizes would be prohibitive.

Richard.

> Andrew
>
>


Re: Question About GPU-Powered Parallel Compilation in GCC

2025-05-13 Thread Andrew Stubbs

On 12/05/2025 15:27, Nikhil Patil via Gcc wrote:

Hi Richard,

Thank you so much for the reply!

You're absolutely right about using CPU threads. I’m just really curious
about whether GPU acceleration could somehow be explored for compilation,
even if it’s not traditionally well-suited. I know it might not be
practical, but I wanted to understand *why* it’s considered inefficient and
learn through experimentation.


To run fast on a GPU it's not enough to be able to parallelize the code, 
you need to *vectorize* it. Not much of a compiler vectorizes well.


Andrew




Generating compile_commands.json for GCC source code

2025-05-13 Thread Yuao Ma via Gcc
Hello GCC developers,
I am trying to generate a compile_commands.json file for the GCC source code. 
This file is very useful for various development tools and IDE integrations.
Since GCC uses a Makefile-based build system, I attempted to use bear 
(https://github.com/rizsotto/Bear) to capture the compilation commands. My 
workflow was as follows:

../configure --enable-languages=c,c++,fortran --disable-bootstrap 
--disable-multilib
bear -- make -j$(nproc)


However, this approach did not produce the expected compile_commands.json file 
with the correct compilation commands for the source files.
Could you please advise on the recommended way to generate 
compile_commands.json for the GCC source tree? Is this something commonly done 
by developers working on GCC, and if so, what is the typical method?
Thank you for your time and assistance.
Best regards,
Yuao



Re: Generating compile_commands.json for GCC source code

2025-05-13 Thread Yuao Ma via Gcc
Hi Sam,
Thank you for your suggestions!
Regarding the bear tool, I am currently using version 3.1.3, which is the one 
provided with Ubuntu 24.04. I will proceed with trying to upgrade bear to a 
newer version as a next step.
Separately, I've noticed something unexpected with the generated compilation 
database (the JSON file). It seems that files located within the GCC directory, 
such as fold-const-call.cc, are not included. This is curious because these 
specific files are not typically compiled directly by xgcc or xg++, yet one 
might expect them to be captured if they are part of the overall build process 
being tracked by bear. For now I only have less than 50 lines.
Best regards,
Yuao


From: Sam James 
Sent: Wednesday, May 14, 2025 10:32
To: Yuao Ma via Gcc 
Cc: Yuao Ma 
Subject: Re: Generating compile_commands.json for GCC source code

Yuao Ma via Gcc  writes:

> Hello GCC developers,
> I am trying to generate a compile_commands.json file for the GCC source code. 
> This file is very useful for various development tools and IDE integrations.
> Since GCC uses a Makefile-based build system, I attempted to use bear 
> (https://github.com/rizsotto/Bear) to capture the compilation commands. My 
> workflow was as follows:

What version of bear did you use? You'll need >=3.1.6 as that contains
https://github.com/rizsotto/Bear/commit/c18c8eef1e74bd253302d57dbcf908394566d93b.

>
> ../configure --enable-languages=c,c++,fortran --disable-bootstrap 
> --disable-multilib
> bear -- make -j$(nproc)
>
>
> However, this approach did not produce the expected compile_commands.json 
> file with the correct compilation commands for the source files.

Did you get one generated at all? If so, what was missing, or what was
wrong with it?



Re: Generating compile_commands.json for GCC source code

2025-05-13 Thread Sam James via Gcc
Yuao Ma via Gcc  writes:

> Hello GCC developers,
> I am trying to generate a compile_commands.json file for the GCC source code. 
> This file is very useful for various development tools and IDE integrations.
> Since GCC uses a Makefile-based build system, I attempted to use bear 
> (https://github.com/rizsotto/Bear) to capture the compilation commands. My 
> workflow was as follows:

What version of bear did you use? You'll need >=3.1.6 as that contains
https://github.com/rizsotto/Bear/commit/c18c8eef1e74bd253302d57dbcf908394566d93b.

>
> ../configure --enable-languages=c,c++,fortran --disable-bootstrap 
> --disable-multilib
> bear -- make -j$(nproc)
>
>
> However, this approach did not produce the expected compile_commands.json 
> file with the correct compilation commands for the source files.

Did you get one generated at all? If so, what was missing, or what was
wrong with it?