Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
22843fb9
Commit
22843fb9
authored
5 years ago
by
Akash Kothari
Browse files
Options
Downloads
Patches
Plain Diff
Update DFG2LLVM for NVPTX with changes to allocas and API for getting and insertion of functions
parent
3a61f317
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hpvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
+14
-14
14 additions, 14 deletions
hpvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
with
14 additions
and
14 deletions
hpvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp
+
14
−
14
View file @
22843fb9
...
@@ -202,7 +202,7 @@ private:
...
@@ -202,7 +202,7 @@ private:
public
:
public
:
// Constructor
// Constructor
CGT_NVPTX
(
Module
&
_M
,
BuildDFG
&
_DFG
)
:
CodeGenTraversal
(
_M
,
_DFG
),
KernelM
(
CloneModule
(
&
_M
))
{
CGT_NVPTX
(
Module
&
_M
,
BuildDFG
&
_DFG
)
:
CodeGenTraversal
(
_M
,
_DFG
),
KernelM
(
CloneModule
(
_M
))
{
init
();
init
();
initRuntimeAPI
();
initRuntimeAPI
();
errs
()
<<
"Old module pointer: "
<<
&
_M
<<
"
\n
"
;
errs
()
<<
"Old module pointer: "
<<
&
_M
<<
"
\n
"
;
...
@@ -527,7 +527,7 @@ void CGT_NVPTX::insertRuntimeCalls(DFInternalNode* N, Kernel* K, const Twine& Fi
...
@@ -527,7 +527,7 @@ void CGT_NVPTX::insertRuntimeCalls(DFInternalNode* N, Kernel* K, const Twine& Fi
// Scalar Input
// Scalar Input
// Store the scalar value on stack and then pass the pointer to its
// Store the scalar value on stack and then pass the pointer to its
// location
// location
AllocaInst
*
inputValPtr
=
new
AllocaInst
(
inputVal
->
getType
(),
inputVal
->
getName
()
+
".ptr"
,
RI
);
AllocaInst
*
inputValPtr
=
new
AllocaInst
(
inputVal
->
getType
(),
0
,
inputVal
->
getName
()
+
".ptr"
,
RI
);
StoreInst
*
SI
=
new
StoreInst
(
inputVal
,
inputValPtr
,
RI
);
StoreInst
*
SI
=
new
StoreInst
(
inputVal
,
inputValPtr
,
RI
);
Value
*
inputValI8Ptr
=
CastInst
::
CreatePointerCast
(
inputValPtr
,
Value
*
inputValI8Ptr
=
CastInst
::
CreatePointerCast
(
inputValPtr
,
...
@@ -580,7 +580,7 @@ void CGT_NVPTX::insertRuntimeCalls(DFInternalNode* N, Kernel* K, const Twine& Fi
...
@@ -580,7 +580,7 @@ void CGT_NVPTX::insertRuntimeCalls(DFInternalNode* N, Kernel* K, const Twine& Fi
switchToTimer
(
visc_TimerID_COPY_SCALAR
,
RI
);
switchToTimer
(
visc_TimerID_COPY_SCALAR
,
RI
);
// Store the scalar value on stack and then pass the pointer to its
// Store the scalar value on stack and then pass the pointer to its
// location
// location
AllocaInst
*
allocSizePtr
=
new
AllocaInst
(
allocSize
->
getType
(),
AllocaInst
*
allocSizePtr
=
new
AllocaInst
(
allocSize
->
getType
(),
0
,
allocSize
->
getName
()
+
".sharedMem.ptr"
,
RI
);
allocSize
->
getName
()
+
".sharedMem.ptr"
,
RI
);
StoreInst
*
SI
=
new
StoreInst
(
allocSize
,
allocSizePtr
,
RI
);
StoreInst
*
SI
=
new
StoreInst
(
allocSize
,
allocSizePtr
,
RI
);
...
@@ -638,7 +638,7 @@ void CGT_NVPTX::insertRuntimeCalls(DFInternalNode* N, Kernel* K, const Twine& Fi
...
@@ -638,7 +638,7 @@ void CGT_NVPTX::insertRuntimeCalls(DFInternalNode* N, Kernel* K, const Twine& Fi
switchToTimer
(
visc_TimerID_COPY_SCALAR
,
RI
);
switchToTimer
(
visc_TimerID_COPY_SCALAR
,
RI
);
// Store the scalar value on stack and then pass the pointer to its
// Store the scalar value on stack and then pass the pointer to its
// location
// location
AllocaInst
*
allocSizePtr
=
new
AllocaInst
(
allocSize
->
getType
(),
AllocaInst
*
allocSizePtr
=
new
AllocaInst
(
allocSize
->
getType
(),
0
,
allocSize
->
getName
()
+
".sharedMem.ptr"
,
RI
);
allocSize
->
getName
()
+
".sharedMem.ptr"
,
RI
);
StoreInst
*
SI
=
new
StoreInst
(
allocSize
,
allocSizePtr
,
RI
);
StoreInst
*
SI
=
new
StoreInst
(
allocSize
,
allocSizePtr
,
RI
);
...
@@ -1032,8 +1032,8 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
...
@@ -1032,8 +1032,8 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
N
->
addGenFunc
(
F_nvptx
,
visc
::
GPU_TARGET
,
false
);
N
->
addGenFunc
(
F_nvptx
,
visc
::
GPU_TARGET
,
false
);
DEBUG
(
errs
()
<<
"Removing all attributes from Kernel Function and adding nounwind
\n
"
);
DEBUG
(
errs
()
<<
"Removing all attributes from Kernel Function and adding nounwind
\n
"
);
F_nvptx
->
removeAttributes
(
Attribute
Se
t
::
FunctionIndex
,
F_nvptx
->
getAttributes
().
getFnAttributes
());
F_nvptx
->
removeAttributes
(
Attribute
Lis
t
::
FunctionIndex
,
F_nvptx
->
getAttributes
().
getFnAttributes
());
F_nvptx
->
addAttribute
(
Attribute
Se
t
::
FunctionIndex
,
Attribute
::
NoUnwind
);
F_nvptx
->
addAttribute
(
Attribute
Lis
t
::
FunctionIndex
,
Attribute
::
NoUnwind
);
//FIXME: For now, assume only one allocation node
//FIXME: For now, assume only one allocation node
kernel
->
AllocationNode
=
NULL
;
kernel
->
AllocationNode
=
NULL
;
...
@@ -1230,19 +1230,19 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
...
@@ -1230,19 +1230,19 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
DEBUG
(
errs
()
<<
"Substitute with get_global_id()
\n
"
);
DEBUG
(
errs
()
<<
"Substitute with get_global_id()
\n
"
);
DEBUG
(
errs
()
<<
*
II
<<
"
\n
"
);
DEBUG
(
errs
()
<<
*
II
<<
"
\n
"
);
OpenCLFunction
=
cast
<
Function
>
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_global_id"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_global_id"
),
FT
))
.
getCallee
())
;
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
)
{
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
)
{
//DEBUG(errs() << "Here inside cond 2\n");
//DEBUG(errs() << "Here inside cond 2\n");
// We are asking for this node's id with respect to its parent
// We are asking for this node's id with respect to its parent
// this is a local id call
// this is a local id call
OpenCLFunction
=
cast
<
Function
>
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_local_id"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_local_id"
),
FT
))
.
getCallee
())
;
//DEBUG(errs() << "exiting condition 2\n");
//DEBUG(errs() << "exiting condition 2\n");
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
->
getParent
())
{
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
->
getParent
())
{
// We are asking for this node's parent's id with respect to its
// We are asking for this node's parent's id with respect to its
// parent: this is a group id call
// parent: this is a group id call
OpenCLFunction
=
cast
<
Function
>
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_group_id"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_group_id"
),
FT
))
.
getCallee
())
;
}
else
{
}
else
{
errs
()
<<
N
->
getFuncPointer
()
->
getName
()
<<
"
\n
"
;
errs
()
<<
N
->
getFuncPointer
()
->
getName
()
<<
"
\n
"
;
errs
()
<<
N
->
getParent
()
->
getFuncPointer
()
->
getName
()
<<
"
\n
"
;
errs
()
<<
N
->
getParent
()
->
getFuncPointer
()
->
getName
()
<<
"
\n
"
;
...
@@ -1308,17 +1308,17 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
...
@@ -1308,17 +1308,17 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
// replicated. This indicates that the parent node is the kernel
// replicated. This indicates that the parent node is the kernel
// launch, so the instances are global_size (gridDim x blockDim)
// launch, so the instances are global_size (gridDim x blockDim)
OpenCLFunction
=
cast
<
Function
>
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_global_size"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_global_size"
),
FT
))
.
getCallee
())
;
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
)
{
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
)
{
// We are asking for this node's instances
// We are asking for this node's instances
// this is a local size (block dim) call
// this is a local size (block dim) call
OpenCLFunction
=
cast
<
Function
>
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_local_size"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_local_size"
),
FT
))
.
getCallee
())
;
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
->
getParent
())
{
}
else
if
(
Leaf_HandleToDFNodeMap
[
ArgII
]
==
N
->
getParent
())
{
// We are asking for this node's parent's instances
// We are asking for this node's parent's instances
// this is a (global_size/local_size) (grid dim) call
// this is a (global_size/local_size) (grid dim) call
OpenCLFunction
=
cast
<
Function
>
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_num_groups"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"get_num_groups"
),
FT
))
.
getCallee
())
;
}
else
{
}
else
{
assert
(
false
&&
"Unable to translate getNumNodeInstances intrinsic"
);
assert
(
false
&&
"Unable to translate getNumNodeInstances intrinsic"
);
}
}
...
@@ -1340,7 +1340,7 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
...
@@ -1340,7 +1340,7 @@ void CGT_NVPTX::codeGen(DFLeafNode* N) {
std
::
vector
<
Type
*>
(
1
,
Type
::
getInt32Ty
(
KernelM
->
getContext
())),
std
::
vector
<
Type
*>
(
1
,
Type
::
getInt32Ty
(
KernelM
->
getContext
())),
false
);
false
);
Function
*
OpenCLFunction
=
cast
<
Function
>
Function
*
OpenCLFunction
=
cast
<
Function
>
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"barrier"
),
FT
));
(
(
KernelM
->
getOrInsertFunction
(
StringRef
(
"barrier"
),
FT
))
.
getCallee
())
;
CallInst
*
CI
=
CallInst
::
Create
(
OpenCLFunction
,
CallInst
*
CI
=
CallInst
::
Create
(
OpenCLFunction
,
ArrayRef
<
Value
*>
(
ConstantInt
::
get
(
Type
::
getInt32Ty
(
KernelM
->
getContext
()),
1
)),
ArrayRef
<
Value
*>
(
ConstantInt
::
get
(
Type
::
getInt32Ty
(
KernelM
->
getContext
()),
1
)),
""
,
II
);
""
,
II
);
...
@@ -1891,7 +1891,7 @@ static Value* genWorkGroupPtr(Module &M, std::vector<Value*> WGSize, ValueToValu
...
@@ -1891,7 +1891,7 @@ static Value* genWorkGroupPtr(Module &M, std::vector<Value*> WGSize, ValueToValu
Type
*
WGTy
=
ArrayType
::
get
(
Int64Ty
,
WGSize
.
size
());
Type
*
WGTy
=
ArrayType
::
get
(
Int64Ty
,
WGSize
.
size
());
// Allocate space of Global work group data on stack and get pointer to
// Allocate space of Global work group data on stack and get pointer to
// first element.
// first element.
AllocaInst
*
WG
=
new
AllocaInst
(
WGTy
,
WGName
,
IB
);
AllocaInst
*
WG
=
new
AllocaInst
(
WGTy
,
0
,
WGName
,
IB
);
WGPtr
=
BitCastInst
::
CreatePointerCast
(
WG
,
Int64Ty
->
getPointerTo
(),
WG
->
getName
()
+
".0"
,
IB
);
WGPtr
=
BitCastInst
::
CreatePointerCast
(
WG
,
Int64Ty
->
getPointerTo
(),
WG
->
getName
()
+
".0"
,
IB
);
Value
*
nextDim
=
WGPtr
;
Value
*
nextDim
=
WGPtr
;
DEBUG
(
errs
()
<<
*
WGPtr
<<
"
\n
"
);
DEBUG
(
errs
()
<<
*
WGPtr
<<
"
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment