-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVM Polly optimizer support #864
Conversation
LLVM 10 uses C++14, yes, but since we're mapping only the C API, it shouldn't affect anything JavaCPP is doing. Where do we need C++14? Is it just for If LLVMParseCommandLineOptions() is the way to access Polly's functionality from the C API, that looks fine to me. BTW, instead of using JNA, we could use JavaCPP to map that function pointer. We could also create presets for libffi itself, which unlike JNA we could manage with JavaCPP. It's a pretty small library. /cc @Neiko2002 |
Yes. polly/LinkAllPasses.h includes C++14 header files.
Is it possible without libffi or do I need to port libffi? |
Yes, with Since we're defining a new |
I see. This is the solution yukoba@114bdbc . |
Yes, that works. I don't think it's complicated, but let's put both versions? :) Maybe someone else will find this complicated and that will motivate them in helping making this easier to use... What do you think? |
I just have read the changes without compiling them. For me the version without JNA looks better since it is adding some type-safety when calling MatMulFunction. It might be nice to have a static function in the MatMulFunction class which handles the instantiation and storing of the pointer. public static MatMulFunction create(Pointer address) {
MatMulFunction func = new MatMulFunction();
func.put(address);
return func;
} |
If I use |
No, it's not possible. That's what a library like libffi is for. I find it surprising that LLVM itself doesn't offer this kind of functionality, but it doesn't. |
BTW, the reason why your benchmark is slower than natively compiled code with clang is probably because of JNA and libffi. Those are known to be very slow. Since your goal is to increase performance, you shouldn't try to use libraries like libffi and JNA, and compile everything with a C++ compiler. That's why JavaCPP does that, it's for performance reasons. |
Thank you!
Then, if I do not use JNA, you need the JavaCPP building environment to run this sample. I think most people do not prepare the JavaCPP building environment and impossible to run.
However, I have to add By
but this optimization is impossible on my sample code. However, I think this optimization part is using Intel AVX-512. |
Maybe we just need to enable some option for AVX-512 support? Did you look?
|
That functionality may be missing from the C API: https://stackoverflow.com/questions/38738123/determining-and-setting-host-target-triple-and-instruction-extensions-in-llvm-c/38801586 |
Thank you for merging.
I solved the optimization problem. I will use this personally for a week, and if there is no problem I want to send a pull request. |
Thanks! Please consider contributing this to the C API upstream though. |
I know it's hard to contribute new code to LLVM, so if you're not able to, please do send a pull request to have this patch added to the presets here at least. Thanks! |
This is a pull request for LLVM Polly optimizer.
This pull request depends on bytedeco/javacpp#389 .
LLVM 10 uses C++14.
After many trials, I decided not to add Java API.
For my opinion, the public API of Polly is only command line arguments.
Many important variables are in the file scope and cannot write from outside.
Therefore, I control through LLVMParseCommandLineOptions.
LLVM uses dynamic loading on UNIX and static loading on Windows.
So I added
-DLLVM_POLLY_LINK_INTO_TOOLS=ON
to the Windows build option.Also I added polly/LinkAllPasses.h . This is necessary to avoid the compiler elimination.
I tested Linux and Windows, but I have not tested on macOS and ARM.
Please see samples/MatMulBenchmark/MatMulBenchmark.java for the usage.
As I want to add pom.xml for MatMulBenchmark,
I created samples/Fac/ and samples/Clang/ and moved sample codes to there.