Is LLVM our answer??

Hey everyone, I'm new to LLVM and am conducting LLVM R&D as CTO for some new technology in our company products. I've done a basic review of all the major components and have walked through the Kaleidoscope tutorial in order to get a feel for LLVM since it seems to address the needs we're looking to fill. Separately, congrats to all the LLVM developers for making LLVM grow to be more and more central in Apple's tool chain roadmap!

Anyway, so I was hoping that one or more LLVM gurus here could point me in the right direction... Our newest products currently use embedded CPython in chorus with callbacks into our C/C++ engine. Unfortunately, CPython's poor performance has become an increasing liability while our Python code is generally basic and could be represented in a more strictly-typed language. Because our software operates in realtime, performance matters so we're accessing the viability of converting our python code to vanilla C++ (or something else) and using LLVM/JIT during runtime to compile and run our code. The compiled code would be linked with callback glue and be invoked by calling the entry point (and execution would pass to the newly compiled code, occasionally returning back to app procs as callbacks occur). In other words, we're considering migrating the language our content is authored from Python to C++ (or some other JIT-compatible language) in order to get a major performance boost.

From what I understand of LLVM, this would seem to be well supported. That said, our customers are very non-technical, so all the LLVM components we'd have to use would *have* to live inside our app binary and app resource dirs (so installing any extra components into the system is would be off limits). Also, we target both OS X and Windows, but I'm not getting the feeling there's support for MS Visual Studio. I see minGW support not but no MSVS support, is that correct? What are the implications of this for a commercial developer who can't just scrap their MSVS environment for minGW?

So, in short, a list of LLVM subcomponents and tutorials for me to concentrate on would really help us since the LLVM universe seems so massive to this newcomer!

If you're curious about what we make that this all relates to, check out soundspectrum.com and our newest product Aeon. When you run Aeon, you'll see a slideshow of realtime, high-performance and fun graphics content. Our engine is 8 years worth of high-performance C++ that drives Direct3D and OpenGL (depending on the platform) and uses embedded Python to run scripts that make batch-style drawing calls back into the C++ engine for execution. The result is rich content authored relatively easily and succinctly that gets good fps and native quality graphics. But CPython's performance has been a nightmare, and using LLVM in the way we're hoping would be as exciting for the LLVM community (I hope!) as it would be for us! I'd love for SoundSpectrum to show off the awesomeness of LLVM!!

Thanks in advance for your insight and time!

Andy

"Andy O'Meara" <andrew.omeara@soundspectrum.com> writes:

[snip]

so we're accessing the viability of converting our python code to
vanilla C++ (or something else) and using LLVM/JIT during runtime to
compile and run our code. The compiled code would be linked with
callback glue and be invoked by calling the entry point (and execution
would pass to the newly compiled code, occasionally returning back to
app procs as call backs occur). In other words, we're considering
migrating the language our content is authored from Python to C++ (or
some other JIT-compatible language) in order to get a major performan!
ce boost.

From what I understand of LLVM, this would seem to be well supported.

You will need a C++ compiler that supports JIT compiling. Maybe Clang
already supports this. I think that CERN's CINT C++ interpreter is
following that route too.

In general, C++ is not an easily embeddable language. If you care about
performance and not so much about C++, there are better options. If your
language requirements are simple enough maybe you could create your own
language.

For an incomplete, possibly outdated list of projects using LLVM see

http://www.llvm.org/releases/2.8/docs/ReleaseNotes.html#externalproj

That said, our customers are very non-technical, so all the LLVM
components we'd have to use would *have* to live inside our app binary
and app resource dirs (so installing any extra components into the
system is would be off limits).

If you are afraid of having to install runtimes similar to .Net or Mono,
there is no such problem with LLVM. It is just a set of C++ libraries
that you link into your application.

Also, we target both OS X and
Windows, but I'm not getting the feeling there's support for MS Visual
Studio. I see minGW support not but no MSVS support, is that correct?

Visual Studio is supported. See

http://www.llvm.org/docs/GettingStartedVS.html

[snip]

So, in short, a list of LLVM subcomponents and tutorials for me to
concentrate on would really help us since the LLVM universe seems so
massive to this newcomer!

If you want to see how JITting works, take a look at the examples
distributed with LLVM, specifically Fibonacci and HowToUseJit. Reading
the documentation is also highly advised.

I also create commercial software for Windows with VS. My applications
are written on a custom language that works with a C++ runtime,
interacting with C and C++ libraries. It supports JITting with LLVM and
the performance is the same as C++ would provide. However, LLVM is not
enabled by default because LLVM is very slow at JITting for large chunks
of code (I'm usually generating more than 1 MB of native code.) If you
work with small code snippets (measured on the KBs of produced native
code) there should be no problem.

[snip]