summaryrefslogtreecommitdiff
path: root/polly/lib/CodeGen/PPCGCodeGeneration.cpp
AgeCommit message (Collapse)Author
2016-09-15GPGPU: Do not assume arrays start at 0Tobias Grosser
Our alias checks precisely check that the minimal and maximal accessed elements do not overlap in a kernel. Hence, we must ensure that our host <-> device transfers do not touch additional memory locations that are not covered in the alias check. To ensure this, we make sure that the data we copy for a given array is only the data from the smallest element accessed to the largest element accessed. We also adjust the size of the array according to the offset at which the array is actually accessed. An interesting result of this is: In case array are accessed with negative subscripts ,e.g., A[-100], we automatically allocate and transfer _more_ data to cover the full array. This is important as such code indeed exists in the wild. llvm-svn: 281611
2016-09-13GPGPU: Use const_cast to avoid compiler warning [NFC]Tobias Grosser
llvm-svn: 281333
2016-09-13GPGPU: Allow region statementsTobias Grosser
llvm-svn: 281305
2016-09-13GPGPU: Extend types when array sizes have smaller typesTobias Grosser
This prevents a compiler crash. llvm-svn: 281303
2016-09-12Store the size of the outermost dimension in case of newly created arrays ↵Roman Gareev
that require memory allocation. We do not need the size of the outermost dimension in most cases, but if we allocate memory for newly created arrays, that size is needed. Reviewed-by: Michael Kruse <llvm@meinersbur.de> Differential Revision: https://reviews.llvm.org/D23991 llvm-svn: 281234
2016-09-12GPGPU: Bail out gracefully in case of invalid IRTobias Grosser
Instead of aborting, we now bail out gracefully in case the kernel IR we generate is invalid. This can currently happen in case the SCoP stores pointer values, which we model as arrays, as data values into other arrays. In this case, the original pointer value is not available on the device and can consequently not be stored. As detecting this ahead of time is not so easy, we detect these situations after the invalid IR has been generated and bail out. llvm-svn: 281193
2016-09-11GPGPU: Do not fail in case of arrays never accessedTobias Grosser
If these arrays have never been accessed we failed to derive an upper bound of the accesses and consequently a size for the outermost dimension. We now explicitly check for empty access sets and then just use zero as size for the outermost dimension. llvm-svn: 281165
2016-08-10[GPGPU] Ensure arrays where only parts are modified are copied to GPUTobias Grosser
To do so we change the way array exents are computed. Instead of the precise set of memory locations accessed, we now compute the extent as the range between minimal and maximal address in the first dimension and the full extent defined by the sizes of the inner array dimensions. We also move the computation of the may_persist region after the construction of the arrays, as it relies on array information. Without arrays being constructed no useful information is computed at all. llvm-svn: 278212
2016-08-09[GPGPU] Support PHI nodes used in GPU kernelTobias Grosser
Ensure the right scalar allocations are used as the host location of data transfers. For the device code, we clear the allocation cache before device code generation to be able to generate new device-specific allocation and we need to make sure to add back the old host allocations as soon as the device code generation is finished. llvm-svn: 278126
2016-08-09[GPGPU] Use separate basic block for GPU initialization codeTobias Grosser
This increases the readability of the IR and also clarifies that the GPU inititialization is executed _after_ the scalar initialization which needs to before the code of the transformed scop is executed. Besides increased readability, the IR should not change. Specifically, I do not expect any changes in program semantics due to this patch. llvm-svn: 278125
2016-08-09[GPGPU] Pass parameters always by using their own typeTobias Grosser
llvm-svn: 278100
2016-08-08[GPGPU] Support Values referenced from both isl expr and llvm instructionsTobias Grosser
When adding code that avoids to pass values used in isl expressions and LLVM instructions twice, we forgot to make single variable passed to the kernel available in the ValueMap that makes it usable for instructions that are not replaced with isl ast expressions. This change adds the variable that is passed to the kernel to the ValueMap to ensure it is available for such use cases as well. llvm-svn: 278039
2016-08-08[GPGPU] Create code to verify run-time conditionsTobias Grosser
llvm-svn: 278026
2016-08-05GPGPU: Sort dimension sizes of multi-dimensional shared memory arrays correctlyTobias Grosser
Before this commit we generated the array type in reverse order and we also added the outermost dimension size to the new array declaration, which is incorrect as Polly additionally assumed an additional unsized outermost dimension, such that we had an off-by-one error in the linearization of access expressions. llvm-svn: 277802
2016-08-05GPGPU: Add cuda annotations to specify maximal number of threads per blockTobias Grosser
These annotations ensure that the NVIDIA PTX assembler limits the number of registers used such that we can be certain the resulting kernel can be executed for the number of threads in a thread block that we are planning to use. llvm-svn: 277799
2016-08-04GPGPU: Support scalars that are mapped to shared memoryTobias Grosser
llvm-svn: 277726
2016-08-04GPGPU: Disable verbose debug outputTobias Grosser
llvm-svn: 277724
2016-08-04Remove leftover debug outputTobias Grosser
llvm-svn: 277723
2016-08-04GPGPU: Add private memory supportTobias Grosser
llvm-svn: 277722
2016-08-04GPGPU: Add support for shared memoryTobias Grosser
llvm-svn: 277721
2016-08-04GPGPU: Handle scalar array referencesTobias Grosser
Pass the content of scalar array references to the alloca on the kernel side and do not pass them additional as normal LLVM scalar value. llvm-svn: 277699
2016-08-04GPGPU: Pass subtree values correctly to the kernelTobias Grosser
llvm-svn: 277697
2016-08-03GPGPU: Mark kernel functions as polly.skipTobias Grosser
Otherwise, we would try to re-optimize them with Polly-ACC and possibly even generate kernels that try to offload themselves, which does not work as the GPURuntime is not available on the accelerator and also does not make any sense. llvm-svn: 277589
2016-07-30Extend the jscop interface to allow the user to declare new arrays and to ↵Roman Gareev
reference these arrays from access expressions Extend the jscop interface to allow the user to export arrays. It is required that already existing arrays of the list of arrays correspond to arrays of the SCoP. Each array that is appended to the list will be newly created. Furthermore, we allow the user to modify access expressions to reference any array in case it has the same element type. Reviewed-by: Tobias Grosser <tobias@grosser.es> Differential Revision: https://reviews.llvm.org/D22828 llvm-svn: 277263
2016-07-28GPGPU: Pass context parameters to GPU kernelTobias Grosser
llvm-svn: 276963
2016-07-28GPGPU: Pass host iterators to kernelTobias Grosser
llvm-svn: 276962
2016-07-28GPGPU: use current 'Index' to find slot in parameter arrayTobias Grosser
Before this change we used the array index, which would result in us accessing the parameter array out-of-bounds. This bug was visible for test cases where not all arrays in a scop are passed to a given kernel. llvm-svn: 276961
2016-07-28GPGPU: Generate kernel parameter allocation with right sizeTobias Grosser
Before this change we miscounted the number of function parameters. llvm-svn: 276960
2016-07-27GPGPU: Add basic support for kernel launchesTobias Grosser
llvm-svn: 276863
2016-07-25GPGPU: Load GPU kernelsTobias Grosser
We embed the PTX code into the host IR as a global variable and compile it at run-time into a GPU kernel. llvm-svn: 276645
2016-07-25GPGPU: Emit data-transfer codeTobias Grosser
Also factor out getArraySize() to avoid code dupliciation and reorder some function arguments to indicate the direction into which data is transferred. llvm-svn: 276636
2016-07-25GPGPU: Complete code to allocate and free device arraysTobias Grosser
At the beginning of each SCoP, we allocate device arrays for all arrays used on the GPU and we free such arrays after the SCoP has been executed. llvm-svn: 276635
2016-07-25GPGPU: initialize GPU context and simplify the corresponding GPURuntime ↵Tobias Grosser
interface. There is no need to expose the selected device at the moment. We also pass back pointers as return values, as this simplifies the interface. llvm-svn: 276623
2016-07-25IslNodeBuilder: Make finalize() virtualTobias Grosser
This allows the finalization routine of the IslNodeBuilder to be overwritten by derived classes. Being here, we also drop the unnecessary 'Scop' postfix and the unnecessary 'Scop' parameter. llvm-svn: 276622
2016-07-24GPGPU: Optimize kernel IR before generating assembly codeTobias Grosser
We optimize the kernel _after_ dumping the IR we generate to make the IR we dump easier readable and independent of possible changes in the general purpose LLVM optimizers. llvm-svn: 276551
2016-07-24GPGPU: Verify kernel IR before generating assemblyTobias Grosser
llvm-svn: 276550
2016-07-22GPGPU: Generate PTX assembly code for the kernel modulesTobias Grosser
Run the NVPTX backend over the GPUModule IR and write the resulting assembly code in a string. To work correctly, it is important to invalidate analysis results that still reference the IR in the kernel module. Hence, this change clears all references to dominators, loop info, and scalar evolution. Finally, the NVPTX backend has troubles to generate code for various special floating point types (not surprising), but also for uncommon integer types. This commit does not resolve these issues, but pulls out problematic test cases into separate files to XFAIL them individually and resolve them in future (not immediate) changes one by one. llvm-svn: 276396
2016-07-21GPGPU: generate code for ScopStatementsTobias Grosser
This change introduces the actual compute code in the GPU kernels. To ensure all values referenced from the statements in the GPU kernel are indeed available we scan all ScopStmts in the GPU kernel for references to llvm::Values that are not yet covered by already modeled outer loop iterators, parameters, or array base pointers and also pass these additional llvm::Values to the GPU kernel. For arrays used in the GPU kernel we introduce a new ScopArrayInfo object, which is referenced by the newly generated access functions within the GPU kernel and which is used to help with code generation. llvm-svn: 276270
2016-07-19GPGPU: Bail out of scops with hoisted invariant loadsTobias Grosser
This is currently not supported and will only be added later. Also update the test cases to ensure no invariant code hoisting is applied. llvm-svn: 275987
2016-07-19GPGPU: Emit in-kernel synchronization statementsTobias Grosser
We use this opportunity to further classify the different user statements that can arise and add TODOs for the ones not yet implemented. llvm-svn: 275957
2016-07-19GPGPU: generate control flow within the kernelTobias Grosser
llvm-svn: 275956
2016-07-19GPGPU: add scop parameters to kernel argumentsTobias Grosser
llvm-svn: 275955
2016-07-19GPGPU: add host iterators to kernel argumentsTobias Grosser
llvm-svn: 275954
2016-07-19GPGPU: add intrinsic functions to obtain a kernels thread and block idsTobias Grosser
llvm-svn: 275953
2016-07-19GPGPU: create kernel function skeletonTobias Grosser
Create for each kernel a separate LLVM-IR module containing a single function marked as kernel function and taking one pointer for each array referenced by this kernel. Add debugging output to verify the kernels are generated correctly. llvm-svn: 275952
2016-07-18GPGPU: collect array referencesTobias Grosser
Initialize the list of references to a GPU array to ensure that the arrays that need to be passed to kernel calls are computed correctly. Furthermore, the very same information is also necessary to compute synchronization correctly. As the functionality to compute these references is already available, what is left for us to do is only to connect the necessary functionality to compute array reference information. llvm-svn: 275798
2016-07-18GPGPU: Pull implementation out of class definitionTobias Grosser
This will allow us to see the full class definition even after we add non-trivial implementations of the different member functions. llvm-svn: 275797
2016-07-18GPGPU: Create host control flowTobias Grosser
Create LLVM-IR for all host-side control flow of a given GPU AST. We implement this by introducing a new GPUNodeBuilder class derived from IslNodeBuilder. The IslNodeBuilder will take care of generating all general-purpose ast nodes, but we provide our own createUser implementation to handle the different GPU specific user statements. For now, we just skip any user statement and only generate a host-code sceleton, but in subsequent commits we will add handling of normal ScopStmt's performing computations, kernel calls, as well as host-device data transfers. We will also introduce run-time check generation and LICM in subsequent commits. llvm-svn: 275783
2016-07-15GPGPU: Format statements scheduled on the host ourselvesTobias Grosser
Otherwise ppcg would try to call into pet functionality that this not available, which obviously will cause trouble. As we can easily print these statements ourselves, we just do so. llvm-svn: 275579
2016-07-15GPGPU: Use schedule whole components for schedulerTobias Grosser
This option increases the scalability of the scheduler and allows us to remove the 'gisting' workaround we introduced in r275565 to handle a more complicated test case. Another benefit of using this option is also that the generated code looks a lot more streamlined. Thanks to Sven Verdoolaege for reminding me of this option. llvm-svn: 275573