Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
48847a29
"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "74d5607e994f4ca6b4ee8b7645c390a4b20bd68b"
Commit
48847a29
authored
Aug 29, 2018
by
mei-ye
Browse files
merge
parent
57511a21
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
39 deletions
+24
-39
CMakeLists.txt
CMakeLists.txt
+2
-1
src/include/migraph/operators.hpp
src/include/migraph/operators.hpp
+1
-1
src/opt/common_header.hpp
src/opt/common_header.hpp
+0
-1
src/opt/memory_coloring_impl.cpp
src/opt/memory_coloring_impl.cpp
+15
-15
src/opt/memory_coloring_impl.hpp
src/opt/memory_coloring_impl.hpp
+6
-21
No files found.
CMakeLists.txt
View file @
48847a29
...
@@ -18,7 +18,8 @@ else()
...
@@ -18,7 +18,8 @@ else()
set
(
MIGRAPH_ENABLE_GPU Off CACHE BOOL
""
)
set
(
MIGRAPH_ENABLE_GPU Off CACHE BOOL
""
)
endif
()
endif
()
add_compile_options
(
-std=c++14 -g -O0
)
#add_compile_options(-std=c++14 -g -O0)
add_compile_options
(
-std=c++14
)
list
(
APPEND CMAKE_MODULE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake
)
list
(
APPEND CMAKE_MODULE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake
)
include
(
EnableCompilerWarnings
)
include
(
EnableCompilerWarnings
)
...
...
src/include/migraph/operators.hpp
View file @
48847a29
...
@@ -551,7 +551,7 @@ struct write_literal
...
@@ -551,7 +551,7 @@ struct write_literal
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
at
(
2
);
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
return
inputs
.
at
(
2
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
{
assert
(
false
);
MIGRAPH_THROW
(
"not computable"
);
}
}
};
};
...
...
src/opt/common_header.hpp
View file @
48847a29
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#include <migraph/instruction.hpp>
#include <migraph/instruction.hpp>
#include <migraph/operators.hpp>
#include <migraph/operators.hpp>
#include <migraph/iterator_for.hpp>
#include <migraph/iterator_for.hpp>
#include <migraph/manage_ptr.hpp>
#include <set>
#include <set>
#include <list>
#include <list>
...
...
src/opt/memory_coloring_impl.cpp
View file @
48847a29
...
@@ -93,6 +93,7 @@ void memory_coloring_impl::build()
...
@@ -93,6 +93,7 @@ void memory_coloring_impl::build()
std
::
vector
<
instruction_ref
>
dead_instrs
;
std
::
vector
<
instruction_ref
>
dead_instrs
;
std
::
set
<
int
>
live_set
;
std
::
set
<
int
>
live_set
;
// Build live intervals.
// Build live intervals.
live_intervals
.
resize
(
num_of_instrs
);
do
do
{
{
const
instruction
*
p_iter
=
&
(
*
iter
);
const
instruction
*
p_iter
=
&
(
*
iter
);
...
@@ -143,7 +144,7 @@ void memory_coloring_impl::build()
...
@@ -143,7 +144,7 @@ void memory_coloring_impl::build()
{
{
// First time see a use, create a live interval.
// First time see a use, create a live interval.
int
id
=
num_of_lives
++
;
int
id
=
num_of_lives
++
;
interval_ptr
interval
(
new
live_interval
()
);
interval_ptr
interval
=
&
(
live_interval
s
[
id
]
);
interval
->
id
=
id
;
interval
->
id
=
id
;
interval
->
segment
.
end
=
cur_points
;
interval
->
segment
.
end
=
cur_points
;
interval
->
segment
.
vn
=
++
max_value_number
;
interval
->
segment
.
vn
=
++
max_value_number
;
...
@@ -151,7 +152,6 @@ void memory_coloring_impl::build()
...
@@ -151,7 +152,6 @@ void memory_coloring_impl::build()
instr2_live
[
p_arg
]
=
interval
;
instr2_live
[
p_arg
]
=
interval
;
add_conflicts
(
live_set
,
max_value_number
);
add_conflicts
(
live_set
,
max_value_number
);
live_set
.
insert
(
max_value_number
);
live_set
.
insert
(
max_value_number
);
live_intervals
[
id
]
=
interval
;
live_ranges
[
max_value_number
]
=
&
(
interval
->
segment
);
live_ranges
[
max_value_number
]
=
&
(
interval
->
segment
);
}
}
else
else
...
@@ -220,8 +220,8 @@ void memory_coloring_impl::dump_intervals()
...
@@ -220,8 +220,8 @@ void memory_coloring_impl::dump_intervals()
std
::
cout
<<
"---live intervals ---"
<<
std
::
endl
;
std
::
cout
<<
"---live intervals ---"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
num_of_lives
;
++
i
)
for
(
int
i
=
0
;
i
<
num_of_lives
;
++
i
)
{
{
interval
_ptr
interval
=
live_intervals
[
i
];
live_
interval
&
interval
=
live_intervals
[
i
];
interval
->
dump
();
interval
.
dump
();
}
}
std
::
cout
<<
"---conflict table---"
<<
std
::
endl
;
std
::
cout
<<
"---conflict table---"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<=
max_value_number
;
++
i
)
for
(
int
i
=
0
;
i
<=
max_value_number
;
++
i
)
...
@@ -244,8 +244,8 @@ void memory_coloring_impl::verify()
...
@@ -244,8 +244,8 @@ void memory_coloring_impl::verify()
{
{
for
(
int
i
=
0
;
i
<
num_of_lives
;
++
i
)
for
(
int
i
=
0
;
i
<
num_of_lives
;
++
i
)
{
{
interval
_ptr
interval
=
live_intervals
[
i
];
live_
interval
&
interval
=
live_intervals
[
i
];
live_range
&
segment
=
interval
->
segment
;
live_range
&
segment
=
interval
.
segment
;
if
(
segment
.
offset
==
InvalidOffset
)
if
(
segment
.
offset
==
InvalidOffset
)
continue
;
continue
;
int
vn
=
segment
.
vn
;
int
vn
=
segment
.
vn
;
...
@@ -265,7 +265,7 @@ void memory_coloring_impl::verify()
...
@@ -265,7 +265,7 @@ void memory_coloring_impl::verify()
}
}
}
}
#define GET_INS_ENUM(x) (
((x) > 0) ? (((x) >> 1) - 1) : InvalidOffset)
#define GET_INS_ENUM(x) (((x) > 0) ? (((x) >> 1) - 1) : InvalidOffset)
void
live_range
::
dump
()
void
live_range
::
dump
()
{
{
...
...
src/opt/memory_coloring_impl.hpp
View file @
48847a29
...
@@ -20,13 +20,11 @@ struct live_range
...
@@ -20,13 +20,11 @@ struct live_range
struct
live_interval
struct
live_interval
{
{
live_interval
()
live_interval
()
:
segment
({
-
1
,
-
1
,
InvalidOffset
,
-
1
,
0
})
{
{
id
=
-
1
;
id
=
-
1
;
is_literal
=
false
;
is_literal
=
false
;
segment
=
{
-
1
,
-
1
,
InvalidOffset
,
-
1
,
0
};
}
}
~
live_interval
()
{}
void
add_use
(
int
use
)
{
use_points
.
push_front
(
use
);
}
void
add_use
(
int
use
)
{
use_points
.
push_front
(
use
);
}
int
get_begin
()
const
{
return
segment
.
begin
;
}
int
get_begin
()
const
{
return
segment
.
begin
;
}
...
@@ -44,23 +42,14 @@ struct live_interval
...
@@ -44,23 +42,14 @@ struct live_interval
bool
is_literal
;
bool
is_literal
;
};
};
// #define unique_interval_ptr std::unique_ptr<live_interval>
#define interval_ptr live_interval*
#define interval_ptr live_interval*
struct
memory_coloring_impl
struct
memory_coloring_impl
{
{
memory_coloring_impl
()
{
init
();
}
memory_coloring_impl
(
program
*
p
)
:
p_program
(
p
)
{
init
();
}
memory_coloring_impl
(
program
*
p
)
:
p_program
(
p
)
void
init
(
)
{
{
init
();
}
~
memory_coloring_impl
()
{
for
(
int
i
=
0
;
i
<
num_of_lives
;
++
i
)
free
(
live_intervals
[
i
]);
}
void
init
()
{
instr2_live
.
clear
();
instr2_live
.
clear
();
live_intervals
.
clear
();
live_ranges
.
clear
();
live_ranges
.
clear
();
conflict_table
.
clear
();
conflict_table
.
clear
();
num_of_lives
=
0
;
num_of_lives
=
0
;
...
@@ -86,10 +75,6 @@ struct memory_coloring_impl
...
@@ -86,10 +75,6 @@ struct memory_coloring_impl
{
{
return
is_param
(
ins
)
&&
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
==
"output"
;
return
is_param
(
ins
)
&&
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
==
"output"
;
}
}
bool
is_scratch_param
(
const
instruction_ref
ins
)
{
return
is_param
(
ins
)
&&
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
==
"scratch"
;
}
bool
is_allocate
(
const
instruction_ref
ins
)
{
return
ins
->
op
.
name
()
==
"hip::allocate"
;
}
bool
is_allocate
(
const
instruction_ref
ins
)
{
return
ins
->
op
.
name
()
==
"hip::allocate"
;
}
bool
is_outline
(
const
instruction_ref
ins
)
{
return
ins
->
op
.
name
()
==
"@outline"
;
}
bool
is_outline
(
const
instruction_ref
ins
)
{
return
ins
->
op
.
name
()
==
"@outline"
;
}
bool
is_literal
(
const
instruction_ref
ins
)
{
return
ins
->
op
.
name
()
==
"@literal"
;
}
bool
is_literal
(
const
instruction_ref
ins
)
{
return
ins
->
op
.
name
()
==
"@literal"
;
}
...
@@ -148,8 +133,8 @@ struct memory_coloring_impl
...
@@ -148,8 +133,8 @@ struct memory_coloring_impl
};
};
program
*
p_program
;
program
*
p_program
;
std
::
unordered_map
<
const
instruction
*
,
interval_ptr
>
instr2_live
;
std
::
unordered_map
<
const
instruction
*
,
interval_ptr
>
instr2_live
;
//
Map live interval Id to
live interval.
//
universe of
live interval
s
.
std
::
unordered_map
<
int
,
interval
_ptr
>
live_intervals
;
std
::
vector
<
live_
interval
>
live_intervals
;
// Map live range value number to live range.
// Map live range value number to live range.
std
::
unordered_map
<
int
,
live_range
*>
live_ranges
;
std
::
unordered_map
<
int
,
live_range
*>
live_ranges
;
// Map live range value number to a set of conflicting live ranges' value numbers.
// Map live range value number to a set of conflicting live ranges' value numbers.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment