-
Notifications
You must be signed in to change notification settings - Fork 375
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
PR/BatchedBackend #1330
PR/BatchedBackend #1330
Conversation
Hi, Alex, you're the CLA manager for Intel, but you still need to click the link it shows in the comment above (just this first time) to kind of register yourself as the user. There's surely no sensible human reason why the CLA manager themselves, if they add themselves as an authorized user, should need this extra step to then register as the user. But that's computers for you. |
…nts the same set of functionality as BackendLLVM does, except it's implementation and many of it's methods handle wide data type (for symbols identified as varying (is_uniform()==false). Many methods exist for (re)use by batched_llvm_gen and batched_llvm_instance.cpp. A common theme is additional "bool is_uniform" parameter to identify if the operation we are generated code for is uniform or not. We cannot rely on the Symbol itself, as an operation will be varying if just 1 of its inputs is varying. This means that when uniform symbols are loaded as arguments, they will need to be widened/broadcast to partcipate in the varying operation. Additionally "bool index_is_uniform" is used to generate gather/scatters vs. a wide load when symbols are varying. Please remember the underlying "wide" data types are Structure of Arrays (SOA) and all address calculations have been modified inside BatchedBackendLLVM to work with SOA's. Introduce helper class FuncSpec to encapsulate building function names that include a batch width and target ISA along with uniform and varying parameters. Introduce TargetLibraryHelper interface and factory method to construct a Concrete TargetLibraryHelper that provides a prefex string that all function calls will be prefixed with and correctly initialize a function map for the shading system with the functions from the target ISA library. Intent is batch size and target ISA specific shared libaries will be built and the correct on be loaded based on host machine. Introduce TempScope. Any calls to getOrAllocateTemp during the lifetime of a TempScope will be associated with the latest TempScope on the stack and when that TempScope's lifetime ends, any temp allocations will be marked unused and will be available for reuse by the next call to getOrAllocateTemp. Introduce liboslexec/wide/define_opname_macros.h to define macros to consistently build OSL library function names including batch width, target isa, 0 to 5 arguments, and optionally masking. Added builtindecl_wide_xmacro.h which is the equivalent of builtindecl.h for identifying the function names and signatures of OSL library functions that exist in batch size and target ISA specific shared libraries. Signed-off-by: Alex M. Wells <[email protected]>
Added friend declaration for ConcreteTargetLibraryHelper to use private base class TargetLibraryHelper Signed-off-by: Alex M. Wells <[email protected]>
00f5f0e
to
471bb28
Compare
Closing and reopening to force recheck by the EasyCLA system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a couple of minor hints about fixes if you can before we merge.
Readers: If this review seems light on comments, it's because Alex and I walked through it in some over a conference call ahead of time.
llvm::Value* arrind = t.simpletype().arraylen ? ll.constant(a) | ||
: NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this setting of arrind can be made part of the outer loop over num_elements instead of the inner loop numDeriv?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it can.
/* | ||
Copyright (c) 2009-2018 Sony Pictures Imageworks Inc., et al. | ||
All Rights Reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of Sony Pictures Imageworks nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to replicate this copyright boilerplate in every file. The convention is just to lead with this:
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, those files had been here for a while and hadn't been updated.
/* | ||
Copyright (c) 2009-2018 Sony Pictures Imageworks Inc., et al. | ||
All Rights Reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of Sony Pictures Imageworks nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
Moved llvm::Value* arrind assignment in batched_backendllvm.cpp from innerloop. Signed-off-by: Alex M. Wells <[email protected]>
Add implementation for BatchedBackendLLVM. BatchedBackendLLVM implements the same set of functionality as BackendLLVM does, except it's implementation and many of it's methods handle wide data type (for symbols identified as varying. Many methods exist for (re)use by batched_llvm_gen and batched_llvm_instance.cpp. A common theme is additional "bool is_uniform" parameter to identify if the operation we are generated code for is uniform or not. We cannot rely on the Symbol itself, as an operation will be varying if just 1 of its inputs is varying. This means that when uniform symbols are loaded as arguments, they will need to be widened/broadcast to participate in the varying operation. Additionally "bool index_is_uniform" is used to generate gather/scatters vs. a wide load when symbols are varying. Please remember the underlying "wide" data types are Structure of Arrays (SOA) and all address calculations have been modified inside BatchedBackendLLVM to work with SOA's.
Introduce helper class FuncSpec to encapsulate building function names that include a batch width and target ISA along with uniform and varying parameters.
Introduce TargetLibraryHelper interface and factory method to construct a Concrete TargetLibraryHelper
that provides a prefex string that all function calls will be prefixed with
and correctly initialize a function map for the shading system with
the functions from the target ISA library. Intent is batch size and target ISA specific shared libaries will be built and the correct one be loaded based on host machine.
Introduce TempScope. Any calls to getOrAllocateTemp during the lifetime of a TempScope will be associated with the latest TempScope on the stack and when that TempScope's lifetime ends, any temp allocations will be marked unused and will be available for reuse by the next call to getOrAllocateTemp.
Introduce liboslexec/wide/define_opname_macros.h to define macros to consistently build OSL library function names including batch width, target isa, 0 to 5 arguments, and optionally masking.
Added builtindecl_wide_xmacro.h which is the equivalent of builtindecl.h for identifying the function names and signatures of OSL library functions that exist in batch size and target ISA specific shared libraries.
Description
Tests
Checklist: