-
Notifications
You must be signed in to change notification settings - Fork 118
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
MSVC does not support statement expressions #234
Comments
Oh, looks like [nvcc, msvc?] on windows doesn't have support for statement expressions? Maybe we can achieve the same functionality using C++ lambdas. I am guessing that the quasi-quotation library won't support that though, so this could be tricky. |
Any ETA for being able to tell if that would actually be tricky? We are quite concerned about running accelerate on windows. |
I am a bit swamped at the moment... As a stop-gap solution, you could always revert the specific commit that introduced those changes. Although the change was made for correctness & performance reasons, it will at least get things compiling for you ... |
To add to @tmcdonell's comment, we are really all Mac/Linux people here. We would like Accelerate to work well on Windows, but we don't have the resources or experience with Windows development to provide proper Windows support. So, this is an area, where we do depend on help from the wider community of Accelerate users. As a side note concerning this specific issue, I believe NVIDIA just announced a new CUDA version with many compiler improvements. It might be worth having a look whether statement expression are supported in that new version. |
Statement expressions are not supported in CUDA 7 for Windows either. NVIDIA supports Visual C only on Windows, which does not support statement expressions anyway. The good thing on Windows is that NVIDIA drivers work out of the box without any problems on any NVIDIA hardware (Optimus included), while the problems on Linux are numerous and I fear will last forever. I've already spend hours and days fighting with NVIDIA-related things suddenly stopping working under Linux and it is simply a breath of fresh air to switch to Windows which just works. Except the new Accelerate 0.15 does not work anymore. I was able to patch Accelerate 0.14 to make it generate correct code with no statement expressions, but in Accelerate 0.15 they are used ubiquitously. Is it such a big problem to get rid of statement expressions in Accelerate code generator? |
@awson Statement expressions often do make code generation quite a lot simpler as they allow you to declare local variables for intermediate values. |
Yes. And how big is the task to keep expression trees unflatten (==inline them all)? I've made this for 0.14 but intermediate constants usage was contained there, and this is not so in 0.15 AFAIUI. |
@awson instead of the code generator being based on generating C expressions, we need to move towards outputting C statements at every step. This is a bit tricky. An example of the problems with 0.14: I'm happy to look for other approaches that also work on windows. But, as I said above, I don't have a lot of spare cycles at the moment, and I will need some assistance getting up to speed on windows as I do not have a lot of experience here. |
That should really be |
I think the ticket name is misleading. Not only a host code (compiled with Visual C++) suffers from this incompatibility, but (and this is much more important) a device code (compiled with cuda front end) also can't be compiled on Windows. NVidia Cuda front end uses EDG C++ front end both on Linux and Windows but in different compatibility modes -- GCC on Linux and Visual C++ on Windows. |
Hi! The lambda-expressions should be relatively similar in form to the statement expressions, ie. ({
const Int32 v0 = 0;
;
arrIn0_0[v0];
}) should be equivalent to: [&]{
const Int32 v0 = 0;
;
return arrIn0_0[v0];
}() Perhaps in the worst case the pretty-printer of the kernel code itself could be hacked to print expression statements as lambdas — if fixing the quasi-quotation library is too troublesome? |
I haven't looked at the implementation of the quasi quoting library, |
Hi, thank you for the reply! However, I am unable to confirm whether such hack works, as There are two doubts related to this approach:
Still, having the |
It seems that this hack works on Linux out-of-the-box. I didn't need to pass any additional options to nvcc. |
I wonder how this changes the generated code (PTX). In particular we should check whether it adversely affects performance. But, since it seems like a way forward, then you might want to push this through with |
@tmcdonell Would you be able to see how the replacing expression statement with lambda-call affects the generated code? I already submitted a WIP pull request to Having a separate pretty printer… does not seem easy to me, at least without writing much of duplicated code or revamping the pretty printing mechanisms on the side of |
I think that the most conclusive way would be to look at the generated PTX code. You are right and it should be possible for the compiler to inline them so that there is no or little difference, but maybe they are lifted out into separate function calls. Checking other metrics like register usage, instruction count, or just performance, could also be indicative before diving straight into the PTX. |
I have published changes needed to use the proposed lambda-expressions support from Before mainland/language-c-quote/pull/53 goes through, mine fork of |
Closing as |
When running some accelerate code on windows there are problems with nvcc.
The log:
The mentioned kernel:
I will try and extract the exact haskell code that generates this kernel, although it's a part of a much larger project and it might take me a bit.
The text was updated successfully, but these errors were encountered: