[533] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | from mapping import * |
---|
| 4 | |
---|
| 5 | ################################################################################## |
---|
[589] | 6 | # file : coproc.py |
---|
[533] | 7 | # date : march 2015 |
---|
| 8 | # author : Alain Greiner |
---|
| 9 | ################################################################################## |
---|
| 10 | # This file describes the mapping of the single thread "coproc" application. |
---|
| 11 | # The main characteristic of this application is to use an hardware coprocessor. |
---|
| 12 | # It can run on any processor of a multi-clusters / multi-processors |
---|
| 13 | # architecture, as long as it exist a coprocessor in the same cluster as the |
---|
| 14 | # calling task. |
---|
| 15 | # This mapping uses 5 platform parameters, (obtained from the "mapping" argument) |
---|
| 16 | # - x_size : number of clusters in a row |
---|
| 17 | # - y_size : number of clusters in a column |
---|
| 18 | # - x_width : number of bits coding x coordinate |
---|
| 19 | # - y_width : number of bits coding y coordinate |
---|
| 20 | # - nprocs : number of processors per cluster |
---|
| 21 | ################################################################################## |
---|
| 22 | |
---|
| 23 | ###################### |
---|
[589] | 24 | def extend( mapping ): |
---|
[533] | 25 | |
---|
| 26 | x_size = mapping.x_size |
---|
| 27 | y_size = mapping.y_size |
---|
| 28 | nprocs = mapping.nprocs |
---|
| 29 | x_width = mapping.x_width |
---|
| 30 | y_width = mapping.y_width |
---|
| 31 | |
---|
| 32 | # define thread placement |
---|
[555] | 33 | x = 0 |
---|
| 34 | y = 0 |
---|
[736] | 35 | p = 0 |
---|
[533] | 36 | |
---|
| 37 | assert( (x < x_size) and (y < y_size) ) |
---|
| 38 | |
---|
| 39 | assert( mapping.clusters[x * y_size + y].procs != 0 ) |
---|
| 40 | |
---|
| 41 | # define vsegs base & size |
---|
| 42 | code_base = 0x10000000 |
---|
| 43 | code_size = 0x00010000 # 64 Kbytes |
---|
| 44 | |
---|
| 45 | data_base = 0x20000000 |
---|
| 46 | data_size = 0x00010000 # 64 Kbytes |
---|
| 47 | |
---|
| 48 | stack_base = 0x40000000 |
---|
| 49 | stack_size = 0x00200000 # 2 Mbytes |
---|
| 50 | |
---|
| 51 | # create vspace |
---|
[779] | 52 | vspace = mapping.addVspace( name = 'coproc', startname = 'coproc_data', active = False ) |
---|
[533] | 53 | |
---|
| 54 | # data vseg in cluster[x,y] |
---|
| 55 | mapping.addVseg( vspace, 'coproc_data', data_base , data_size, |
---|
| 56 | 'C_WU', vtype = 'ELF', x = x, y = y, pseg = 'RAM', |
---|
[610] | 57 | binpath = 'bin/coproc/appli.elf', |
---|
[533] | 58 | local = False ) |
---|
| 59 | |
---|
| 60 | # code vseg in cluster[x,y] |
---|
| 61 | mapping.addVseg( vspace, 'coproc_code', code_base , code_size, |
---|
| 62 | 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM', |
---|
[610] | 63 | binpath = 'bin/coproc/appli.elf', |
---|
[533] | 64 | local = False ) |
---|
| 65 | |
---|
| 66 | # stack vseg in cluster [x,y] |
---|
| 67 | mapping.addVseg( vspace, 'coproc_stack', stack_base, stack_size, |
---|
| 68 | 'C_WU', vtype = 'BUFFER', x = x , y = y , pseg = 'RAM', |
---|
| 69 | local = False, big = True ) |
---|
| 70 | |
---|
[708] | 71 | # one thread on processor[x,y,p] |
---|
| 72 | mapping.addThread( vspace, |
---|
| 73 | 'coproc', |
---|
| 74 | True, # is_main |
---|
| 75 | x, y, p, |
---|
| 76 | 'coproc_stack', |
---|
| 77 | '', # no heap |
---|
| 78 | 0 ) # start_id |
---|
[533] | 79 | |
---|
| 80 | # extend mapping name |
---|
| 81 | mapping.name += '_coproc' |
---|
| 82 | |
---|
| 83 | return vspace # useful for test |
---|
| 84 | |
---|
| 85 | ################################ test ############################################ |
---|
| 86 | |
---|
| 87 | if __name__ == '__main__': |
---|
| 88 | |
---|
[589] | 89 | vspace = extend( Mapping( 'test', 2, 2, 4 ) ) |
---|
[533] | 90 | print vspace.xml() |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | # Local Variables: |
---|
| 94 | # tab-width: 4; |
---|
| 95 | # c-basic-offset: 4; |
---|
| 96 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 97 | # indent-tabs-mode: nil; |
---|
| 98 | # End: |
---|
| 99 | # |
---|
| 100 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 101 | |
---|