[533] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | from mapping import * |
---|
| 4 | |
---|
| 5 | ################################################################################## |
---|
| 6 | # file : coproc.py (for the coproc application) |
---|
| 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 | ###################### |
---|
| 24 | def coproc( mapping ): |
---|
| 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 |
---|
| 33 | x = 1 |
---|
| 34 | y = 1 |
---|
| 35 | p = 0 |
---|
| 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 |
---|
| 52 | vspace = mapping.addVspace( name = 'coproc', startname = 'coproc_data' ) |
---|
| 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', |
---|
| 57 | binpath = 'build/coproc/coproc.elf', |
---|
| 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', |
---|
| 63 | binpath = 'build/coproc/coproc.elf', |
---|
| 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 | |
---|
| 71 | # one task on processor[x,y,0] |
---|
| 72 | mapping.addTask( vspace, 'coproc', 0 , x , y , 0 , |
---|
| 73 | 'coproc_stack' , '' , 0 ) |
---|
| 74 | |
---|
| 75 | # extend mapping name |
---|
| 76 | mapping.name += '_coproc' |
---|
| 77 | |
---|
| 78 | return vspace # useful for test |
---|
| 79 | |
---|
| 80 | ################################ test ############################################ |
---|
| 81 | |
---|
| 82 | if __name__ == '__main__': |
---|
| 83 | |
---|
| 84 | vspace = coproc( Mapping( 'test', 2, 2, 4 ) ) |
---|
| 85 | print vspace.xml() |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | # Local Variables: |
---|
| 89 | # tab-width: 4; |
---|
| 90 | # c-basic-offset: 4; |
---|
| 91 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 92 | # indent-tabs-mode: nil; |
---|
| 93 | # End: |
---|
| 94 | # |
---|
| 95 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 96 | |
---|