google / souper

A superoptimizer for LLVM IR
Apache License 2.0
2.13k stars 169 forks source link

Parallel inferring #792

Open Jacarte opened 4 years ago

Jacarte commented 4 years ago

Hi all

I would like to ask if it's possible to have parallel inferring. Right now the candidates inferring is done in a serial process. However, I think it can go faster if more than one candidate is treated at once. Specifically at this place, but, maybe I am missing something.

Thanks in advance.

regehr commented 4 years ago

I think you'd want to be pretty careful with the parallelism strategy here since when Souper is used as an LLVM plugin you don't want to modify the IR concurrently.

we've not pursued anything like this since there are generally easier forms of parallelism available. when compiling, there's often a lot of parallelism at the level of the build system, for example. we also like to harvest LHSs into Souper's cache and then infer these in parallel, this works very well, the cache_infer program has support for this. there's also potential for parallelism in the enumerative synthesizer but we've not explored that at all seriously.

Jacarte commented 4 years ago

Thank @regehr for the quick and always useful answer.

I agree about having a red light doing parallel IR modifications. I was thinking more about the enumerative synthesis and solver querying part as you mentioned. To create the proof of concept of [CROW](), we modified Souper here creating a forked process (to some extent using semaphore) for each candidate looking for valid replacements, it seems to work.

Sorry for the sloppy CPP code :)