Added documentation of C++ for OpenCL mode into Clang User Manual and Language Extensions document.
Ok, specific here is as opposite to generic.
In v2.0 drivers this is a manual step. In v2.2 drivers it is expected to be done automatically.
I think IR linker makes them unique i.e. adds a suffix. Although I think the files (including the path) linked are supposed to be unique. Anyway, good point to look into.
No idea about obj linker. We currently don't support this feature.
This is the example I am explaining just below.
Manual is good for examples. Some new developers might find it useful to have the full line even though it's quite simple.
Beside my two comments, I think this looks good.
( -> , (there's no matching closing parenthesis.)
foo() isn't actually called here. You probably meant to write this:
__local C c1; C c2; __constant C c3; c1.foo(); // will resolve to the first foo c2.foo(); // will resolve to the second foo c3.foo(); // error due to mismatching address spaces - can't convert to __local or __generic
Very useful to have all of this documented! Thanks!
I'm tempted to suggest you merge the first two sentences and tone down the claim in the second. "This functionality [...] and C++17, enabling _some_ regular C++ features [...].
s/All/Most/? Stating that all functionality from OpenCL C is available right before stating that the differences will be described feels like a contradiction.
Probably worth adding exceptions to the list.
I would remove this last sentence. Only a very small portion of the libray can be supported anyway.
I would remove the "yet", unless we can refer to an on-going and visible effort.
"Clang extends existing concept" feels like it should be re-worded.
"using sets and overlapping" feels incomplete. Pretending I can't guess: sets of what? What is overlapping what? :)
Why use __generic when generic is equally valid and easier on the eyes? The same comment applies to other mentions of address space keywords.
This is ambiguous. One could read that conversions from __generic to __constant are allowed.
Isn't a conversion explicit if a cast operator is used?
At the time of writing addrspace_cast doesn't seem to exist in trunk and C-style casts seem to work.
Didn't you mean "from __generic to named address spaces"?
Makes me wonder whether const members couldn't be in the constant address space.
the address space?
I would remove the "for example to take advantage of memory bank accesses" or make the example clear.
+1, I was about to make the same comment.
Shouldn't this be C() __generic? Similar comments can be made for the other members.
"such a program" or "such programs"
I would say "must be constructed before the first kernel begins execution" and "may be destroyed once the last kernel has completed its execution". These are requirements for a runtime environment, not functionality provided by Clang. The documentation should only describe the interface with the runtime and the requirements on the runtime.
OpenCL doesn't have an API for this per-se, regardless of the version. The only mechanism currently specified is the SPIR-V Initializer and Finalizer execution modes for entrypoints, either of which currently require an OpenCL 2.2 implementation.
I would say that "applications are required to run all of these initialization kernels before any others if they exist".
This could be managed by the application with a scheme similar to the one you're proposing for constructor functions.
Shouldn't "Clang9" be "Clang 9"? You may even want to spell it out "version 9 of Clang".
"A C++ mode" or "A non-standard C++ language extension" to be more precise?
No plans that we're aware of ;). For all we know, there could be a company/individual working on this. I think conjectures on people's plans don't belong in the documentation.
Everything is relative. I would keep this 100% factual: "there are restrictions". This is not a sales pitch :).
I find -std=c++ confusing/misleading. Maybe we should change the way -cl-std works so we can have -std=clc++ and -cl-std=c++?
Would it be ok if I fix those in a separate commit? I would really like to commit the core part before the release branch is taken.
I'm fine with this as long as we can continue the discussion for open comments in this review. Accepting the revision as I don't seem to be able to go back on my request for another patch.
FYI, this is not part of my change. It was just hard to produce combined diff.
I think it's valuable especially for metaprogramming. I was being asked about it.
I need to understand what needs re-wording
I prefer to use __ for two reasons (1) it's more official in OpenCL docs and tutorials (2) I sometimes omit the noun and just use it as a short term in the text.
It's complicated to explain but basically some cast operators perform implicit conversions of what they are not expected to do because implicit conversions are allowed everywhere even if the operator isn't intended to do the conversion explicitly.
Similar example in C++, most of operators accept converting to const objects.
I think it's ok to document full extension even if it's WIP.
No constant specify memory region but const indicates that object is not changed during lifetime. You can cast away const but you can't convert constant object to any other address space.
Not sure whether you imply any action here.
The Itanium C++ ABIs for destructors are different and we haven't got it working yet for OpenCL. I would leave the description as is for now.
I think it's fair to say few restrictions because the majority of C++ just works in OpenCL.
"For OpenCL it means that implicit conversions are allowed from a named address space except for conversion from the `__constant to the __generic` address space."
I would omit "that is a superset of all others except for `__constant`" as that is already documented in the OpenCL spec and it might confuse readers here. If you want to keep it, I suggest rephrasing it as a separate sentence.
+The+ `__constant` address space
"C-style casts follow"
+the+ `__generic` address space
(also in the next few lines)
+an+ address space qualifier
ithe -> the
Duplicate "to" (to to)
Once a template has been instantiated, regular restrictions for address spaces will apply.
the `__private` address space
some other -> another
it's -> it is
enqueue *a* constructor
Clang9 -> Clang 9 (with space).
I agree with @kpet and also prefer "There are restrictions" instead of an unquantified statement.
I wouldn't say "new" mode as this is part of a persistent user manual.
Again I would avoid "new mode".
"To enable the C++ for OpenCL mode,"
Also: pass *one of* the following command line options when compiling a `.cl`
So in total:
Ok, I don't understand what value does it bring to make information less specific but potentially it's not important enough to continue the argument. The idea of this sentence was indeed to point out that the mode is just very close to C++ with very few restrictions. This isn't a program so it can't have a formal definition for every statement. :P