Index

MoYe.@tileMacro
@tile x::MoYeArray threadgroup_shape::Tile threadgroup_coord::Tuple

Partition x with threadgroup_shape. Return the view of the entries of x that the thread group at threadgroup_coord will work on.

Examples

julia> a = MoYeArray(pointer([i for i in 1:48]), @Layout((6,8)))
6×8 MoYeArray{Int64, 2, ViewEngine{Int64, Ptr{Int64}}, Layout{2, Tuple{Static.StaticInt{6}, Static.StaticInt{8}}, Tuple{Static.StaticInt{1}, Static.StaticInt{6}}}} with indices _1:_6×_1:_8:
 1   7  13  19  25  31  37  43
 2   8  14  20  26  32  38  44
 3   9  15  21  27  33  39  45
 4  10  16  22  28  34  40  46
 5  11  17  23  29  35  41  47
 6  12  18  24  30  36  42  48

julia> @tile a (_2, _2) (1, 1)
2×2 MoYeArray{Int64, 2, ViewEngine{Int64, Ptr{Int64}}, Layout{2, Tuple{StaticInt{2}, StaticInt{2}}, Tuple{StaticInt{1}, StaticInt{6}}}}:
 1  7
 2  8
source
MoYe.@parallelizeMacro
@parallelize x::MoYeArray threadgroup_layout::Layout thread_idx::Int

Partition x with size(threadgroup_layout) threads, and return the view of the entries that the thread at thread_idx will work on.

Examples

Say we have a MoYeArray x of shape (6, 8) and 4 threads of shape (2, 2). We would like to partition x with the 4 threads and get a view of the entries that the first thread will work on. We can do this by calling @parallelize(x, (2, 2), 1).

julia> a = MoYeArray(pointer([i for i in 1:48]), @Layout((6,8)))
6×8 MoYeArray{Int64, 2, ViewEngine{Int64, Ptr{Int64}}, Layout{2, Tuple{Static.StaticInt{6}, Static.StaticInt{8}}, Tuple{Static.StaticInt{1}, Static.StaticInt{6}}}}:
 1   7  13  19  25  31  37  43
 2   8  14  20  26  32  38  44
 3   9  15  21  27  33  39  45
 4  10  16  22  28  34  40  46
 5  11  17  23  29  35  41  47
 6  12  18  24  30  36  42  48

julia> @parallelize a (_2, _2) (1, 1)
3×4 MoYeArray{Int64, 2, ViewEngine{Int64, Ptr{Int64}}, Layout{2, Tuple{Static.StaticInt{3}, Static.StaticInt{4}}, Tuple{Static.StaticInt{2}, Static.StaticInt{12}}}}:
 1  13  25  37
 3  15  27  39
 5  17  29  41

You can also pass in a thread layout and a thread id to get the tile:

julia> @parallelize a @Layout((2,2), (1, 2)) 2
3×4 MoYeArray{Int64, 2, ViewEngine{Int64, Ptr{Int64}}, Layout{2, Tuple{StaticInt{3}, StaticInt{4}}, Tuple{StaticInt{2}, StaticInt{12}}}}:
 2  14  26  38
 4  16  28  40
 6  18  30  42

julia> @parallelize a @Layout((2,2), (2, 1)) 2
3×4 MoYeArray{Int64, 2, ViewEngine{Int64, Ptr{Int64}}, Layout{2, Tuple{StaticInt{3}, StaticInt{4}}, Tuple{StaticInt{2}, StaticInt{12}}}}:
  7  19  31  43
  9  21  33  45
 11  23  35  47
source