Commit fee00e55 authored by Yifan Zhao's avatar Yifan Zhao
Browse files

NVPTX -> OpenCL

parent a750f6e8
......@@ -5,7 +5,7 @@ Compilation of an HPVM program involves the following steps:
2. `opt` takes (`main.ll`) and invoke the GenHPVM pass on it, which converts the HPVM-C function calls to HPVM intrinsics. This generates the HPVM textual representation (`main.hpvm.ll`).
3. `opt` takes the HPVM textual representation (`main.hpvm.ll`) and invokes the following passes in sequence:
* BuildDFG: Converts the textual representation to the internal HPVM representation.
* LocalMem and DFG2LLVM_NVPTX: Invoked only when GPU target is selected. Generates the kernel module (`main.kernels.ll`) and the portion of the host code that invokes the kernel into the host module (`main.host.ll`).
* LocalMem and DFG2LLVM_OpenCL: Invoked only when GPU target is selected. Generates the kernel module (`main.kernels.ll`) and the portion of the host code that invokes the kernel into the host module (`main.host.ll`).
* DFG2LLVM_CPU: Generates either all, or the remainder of the host module (`main.host.ll`) depending on the chosen target.
* ClearDFG: Deletes the internal HPVM representation from memory.
4. `clang` is used to to compile any remaining project files that would be later linked with the host module.
......
add_subdirectory(BuildDFG)
add_subdirectory(ClearDFG)
add_subdirectory(DFG2LLVM_NVPTX)
add_subdirectory(DFG2LLVM_OpenCL)
add_subdirectory(DFG2LLVM_CPU)
add_subdirectory(GenHPVM)
add_subdirectory(LocalMem)
......@@ -1426,7 +1426,7 @@ void CGT_CPU::codeGen(DFLeafNode *N) {
switch (N->getTag()) {
case hpvm::GPU_TARGET:
// A leaf node should not have an cpu function for GPU
// by design of DFG2LLVM_NVPTX backend
// by design of DFG2LLVM_OpenCL backend
assert(!(N->hasCPUGenFuncForTarget(hpvm::GPU_TARGET)) &&
"Leaf node not expected to have GPU GenFunc");
break;
......
......@@ -4,9 +4,9 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_BUILD_DIR=${PROJECT_BINARY_DIR}")
add_llvm_library( LLVMDFG2LLVM_NVPTX
add_llvm_library( LLVMDFG2LLVM_OpenCL
MODULE
DFG2LLVM_NVPTX.cpp
DFG2LLVM_OpenCL.cpp
DEPENDS
intrinsics_gen
......
;===- ./lib/Transforms/DFG2LLVM_NVPTX/LLVMBuild.txt ------------*- Conf -*--===;
;===- ./lib/Transforms/DFG2LLVM_OpenCL/LLVMBuild.txt ------------*- Conf -*--===;
;
; The LLVM Compiler Infrastructure
;
......@@ -17,5 +17,5 @@
[component_0]
type = Library
name = DFG2LLVM_NVPTX
name = DFG2LLVM_OpenCL
parent = Transforms
......@@ -65,7 +65,7 @@ ifeq ($(TARGET),seq)
HPVM_OPTFLAGS += -hpvm-timers-cpu
else
DEVICE = GPU_TARGET
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS += -hpvm-timers-cpu -hpvm-timers-ptx
endif
TESTGEN_OPTFLAGS += -hpvm-timers-gen
......
......@@ -22,7 +22,7 @@ ifeq ($(TARGET),seq)
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -dfg2llvm-cpu -clearDFG
else
DEVICE = GPU_TARGET
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
endif
CFLAGS += -DDEVICE=$(DEVICE)
......
......@@ -52,7 +52,7 @@ ifeq ($(TARGET),seq)
HPVM_OPTFLAGS += -hpvm-timers-cpu
else
DEVICE = GPU_TARGET
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS += -hpvm-timers-cpu -hpvm-timers-ptx
endif
TESTGEN_OPTFLAGS += -hpvm-timers-gen
......
......@@ -56,7 +56,7 @@ ifeq ($(TARGET),seq)
HPVM_OPTFLAGS += -hpvm-timers-cpu
else
DEVICE = GPU_TARGET
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -load LLVMDFG2LLVM_CPU.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-cpu -clearDFG
HPVM_OPTFLAGS += -hpvm-timers-cpu -hpvm-timers-ptx
endif
TESTGEN_OPTFLAGS += -hpvm-timers-gen
......
; RUN: opt -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -S -localmem -dfg2llvm-nvptx < %s | FileCheck %s
; RUN: opt -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -S -localmem -dfg2llvm-nvptx < %s | FileCheck %s
; ModuleID = 'ThreeLevel.atomic.ll'
source_filename = "ThreeLevel.constmem.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
......
; RUN: opt -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -S -localmem -dfg2llvm-nvptx < %s | FileCheck %s
; RUN: opt -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -S -localmem -dfg2llvm-nvptx < %s | FileCheck %s
; ModuleID = 'ThreeLevel.ll'
source_filename = "ThreeLevel.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
......
; RUN: opt -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -S -localmem -dfg2llvm-nvptx < %s | FileCheck %s
; RUN: opt -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_OpenCL.so -S -localmem -dfg2llvm-nvptx < %s | FileCheck %s
; ModuleID = 'ThreeLevel.opt.ll'
source_filename = "ThreeLevel.opt.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment