Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,5 @@
if (CUDA_FOUND OR OpenCL_FOUND)
add_subdirectory(GPURuntime)
endif (CUDA_FOUND OR OpenCL_FOUND)
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)

View File

@@ -0,0 +1,19 @@
set(MODULE TRUE)
set(LLVM_NO_RTTI 1)
add_polly_library(GPURuntime
GPUJIT.c
)
set_target_properties(GPURuntime
PROPERTIES
LINKER_LANGUAGE C
PREFIX "lib"
)
set_property(TARGET GPURuntime PROPERTY C_STANDARD 99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default ")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=all ")
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,123 @@
/******************************************************************************/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois */
/* Open Source License. See LICENSE.TXT for details. */
/* */
/******************************************************************************/
/* */
/* This file defines GPUJIT. */
/* */
/******************************************************************************/
#ifndef GPUJIT_H_
#define GPUJIT_H_
#include "stddef.h"
/*
* The following demostrates how we can use the GPURuntime library to
* execute a GPU kernel.
*
* char KernelString[] = "\n\
* .version 1.4\n\
* .target sm_10, map_f64_to_f32\n\
* .entry _Z8myKernelPi (\n\
* .param .u64 __cudaparm__Z8myKernelPi_data)\n\
* {\n\
* .reg .u16 %rh<4>;\n\
* .reg .u32 %r<5>;\n\
* .reg .u64 %rd<6>;\n\
* cvt.u32.u16 %r1, %tid.x;\n\
* mov.u16 %rh1, %ctaid.x;\n\
* mov.u16 %rh2, %ntid.x;\n\
* mul.wide.u16 %r2, %rh1, %rh2;\n\
* add.u32 %r3, %r1, %r2;\n\
* ld.param.u64 %rd1, [__cudaparm__Z8myKernelPi_data];\n\
* cvt.s64.s32 %rd2, %r3;\n\
* mul.wide.s32 %rd3, %r3, 4;\n\
* add.u64 %rd4, %rd1, %rd3;\n\
* st.global.s32 [%rd4+0], %r3;\n\
* exit;\n\
* }\n\
* ";
*
* const char *Entry = "_Z8myKernelPi";
*
* int main() {
* PollyGPUFunction *Kernel;
* PollyGPUContext *Context;
* PollyGPUDevicePtr *DevArray;
* int *HostData;
* int MemSize;
*
* int GridX = 8;
* int GridY = 8;
*
* int BlockX = 16;
* int BlockY = 16;
* int BlockZ = 1;
*
* MemSize = 256*64*sizeof(int);
* Context = polly_initContext();
* DevArray = polly_allocateMemoryForDevice(MemSize);
* Kernel = polly_getKernel(KernelString, KernelName);
*
* void *Params[1];
* void *DevPtr = polly_getDevicePtr(DevArray)
* Params[0] = &DevPtr;
*
* polly_launchKernel(Kernel, GridX, GridY, BlockX, BlockY, BlockZ, Params);
*
* polly_copyFromDeviceToHost(HostData, DevData, MemSize);
* polly_freeKernel(Kernel);
* polly_freeDeviceMemory(DevArray);
* polly_freeContext(Context);
* }
*
*/
typedef enum PollyGPURuntimeT {
RUNTIME_NONE,
RUNTIME_CUDA,
RUNTIME_CL
} PollyGPURuntime;
typedef struct PollyGPUContextT PollyGPUContext;
typedef struct PollyGPUFunctionT PollyGPUFunction;
typedef struct PollyGPUDevicePtrT PollyGPUDevicePtr;
typedef struct OpenCLContextT OpenCLContext;
typedef struct OpenCLKernelT OpenCLKernel;
typedef struct OpenCLDevicePtrT OpenCLDevicePtr;
typedef struct CUDAContextT CUDAContext;
typedef struct CUDAKernelT CUDAKernel;
typedef struct CUDADevicePtrT CUDADevicePtr;
PollyGPUContext *polly_initContextCUDA();
PollyGPUContext *polly_initContextCL();
PollyGPUFunction *polly_getKernel(const char *BinaryBuffer,
const char *KernelName);
void polly_freeKernel(PollyGPUFunction *Kernel);
void polly_copyFromHostToDevice(void *HostData, PollyGPUDevicePtr *DevData,
long MemSize);
void polly_copyFromDeviceToHost(PollyGPUDevicePtr *DevData, void *HostData,
long MemSize);
void polly_synchronizeDevice();
void polly_launchKernel(PollyGPUFunction *Kernel, unsigned int GridDimX,
unsigned int GridDimY, unsigned int BlockSizeX,
unsigned int BlockSizeY, unsigned int BlockSizeZ,
void **Parameters);
void polly_freeDeviceMemory(PollyGPUDevicePtr *Allocation);
void polly_freeContext(PollyGPUContext *Context);
// Note that polly_{malloc/free}Managed are currently not used by Polly.
// We use them in COSMO by replacing all malloc with polly_mallocManaged and all
// frees with cudaFree, so we can get managed memory "automatically".
// Needless to say, this is a hack.
// Please make sure that this code is not present in Polly when 2018 rolls in.
// If this is still present, ping Siddharth Bhat <siddu.druid@gmail.com>
void *polly_mallocManaged(size_t size);
void polly_freeManaged(void *mem);
#endif /* GPUJIT_H_ */

View File

@@ -0,0 +1,75 @@
==============================================================================
GPURuntime License
==============================================================================
The GPURuntime library is dual licensed under both the University of Illinois
"BSD-Like" license and the MIT license. As a user of this code you may choose
to use it under either license. As a contributor, you agree to allow your code
to be used under both.
Full text of the relevant licenses is included below.
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
All rights reserved.
Developed by:
Polly Team
http://polly.llvm.org
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of the LLVM Team, University of Illinois at
Urbana-Champaign, nor the names of its contributors may be used to
endorse or promote products derived from this Software without specific
prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
==============================================================================
Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.