8161ebb915
Commented and flattened binary search sample. Change-Id: Ib783292207c956d16003195924a3bcfbbde5039f
38 linhas
896 B
Plaintext
Ficheiro executável
38 linhas
896 B
Plaintext
Ficheiro executável
module &m:1:0:$full:$large:$default;
|
|
extension "amd:gcn";
|
|
extension "IMAGE";
|
|
|
|
decl prog function &abort()();
|
|
|
|
|
|
/* This function takes in 2 memory locations, one storing a number of
|
|
iterations to execute, and the other a place to store a result.
|
|
The function iterates through a loop "iteration" times, and stores
|
|
the number of iterations executed in the "results" location.
|
|
A successful run is when the value stored in %iteration is the
|
|
same as the value store in %results.
|
|
*/
|
|
|
|
prog kernel &__simple_kernel(
|
|
kernarg_u64 %iteration,
|
|
kernarg_u64 %results)
|
|
{
|
|
ret;
|
|
ld_kernarg_align(8)_width(all)_u64 $d1, [%iteration];
|
|
ld_kernarg_align(8)_width(all)_u64 $d2, [%results];
|
|
|
|
ld_global_u32 $s1, [$d1];
|
|
mov_u32 $s2, 0;
|
|
|
|
|
|
@loop:
|
|
add_u32 $s2, $s2, 1;
|
|
cmp_lt_b1_u32 $c0, $s2, $s1;
|
|
cbr_b1 $c0, @loop;
|
|
|
|
st_global_u32 $s2, [$d2];
|
|
|
|
ret;
|
|
};
|
|
|