Changeset 555 for soft/giet_vm/applications/coproc
- Timestamp:
- Apr 13, 2015, 5:21:18 PM (10 years ago)
- Location:
- soft/giet_vm/applications/coproc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/coproc/coproc.py
r533 r555 31 31 32 32 # define thread placement 33 x = 134 y = 133 x = 0 34 y = 0 35 35 p = 0 36 36 -
soft/giet_vm/applications/coproc/main.c
r533 r555 1 /////////////////////////////////////////////////////////////////////////////////////// 2 // file : main.c (for coproc application) 3 // date : avril 2015 4 // author : Alain Greiner 5 /////////////////////////////////////////////////////////////////////////////////////// 6 // This file describes the single thread "coproc" application. 7 // It uses the embedded GCD (Greater Common Divider) coprocessor to make 8 // the GCD computation between two vectors of 32 bits integers. 9 // The vectors size is defined by the VECTOR_SIZE parameter. 10 /////////////////////////////////////////////////////////////////////////////////////// 11 12 1 13 #include "stdio.h" 2 14 #include "mapping_info.h" // for coprocessors types an modes 3 15 4 #define VECTOR_SIZE 3216 #define VECTOR_SIZE 128 5 17 6 #define VERBOSE 1 18 #define DMA_MODE MODE_DMA_IRQ 19 20 #define VERBOSE 1 7 21 8 22 // Memory buffers for coprocessor … … 32 46 } 33 47 34 // request a GCD coprocessor35 48 unsigned int coproc_info; 36 unsigned int cluster_xy;37 49 38 giet_coproc_alloc( MWR_SUBTYPE_GCD, 39 &coproc_info, 40 &cluster_xy ); 50 /////////////////////// request a GCD coprocessor 51 giet_coproc_alloc( MWR_SUBTYPE_GCD, &coproc_info ); 41 52 42 53 // check coprocessor ports … … 45 56 unsigned int nb_config = (coproc_info>>16) & 0xFF; 46 57 unsigned int nb_status = (coproc_info>>24) & 0xFF; 47 48 58 giet_assert( ((nb_to_coproc == 2) && 49 59 (nb_from_coproc == 1) && … … 52 62 "wrong GCD coprocessor interface" ); 53 63 54 if ( VERBOSE ) 55 giet_shr_printf("\n*** get GCD coprocessor at cycle %d\n", 56 giet_proctime() ); 64 if ( VERBOSE ) 65 giet_shr_printf("\n*** get GCD coprocessor at cycle %d\n", giet_proctime() ); 57 66 58 // initializes communication channels 59 giet_coproc_channel_t desc; 67 //////////////////////// initializes channel for OPA 68 giet_coproc_channel_t opa_desc; 69 opa_desc.channel_mode = DMA_MODE; 70 opa_desc.buffer_size = VECTOR_SIZE<<2; 71 opa_desc.buffer_vaddr = (unsigned int)opa; 72 giet_coproc_channel_init( 0 , &opa_desc ); 73 74 //////////////////////// initializes channel for OPB 75 giet_coproc_channel_t opb_desc; 76 opb_desc.channel_mode = DMA_MODE; 77 opb_desc.buffer_size = VECTOR_SIZE<<2; 78 opb_desc.buffer_vaddr = (unsigned int)opb; 79 giet_coproc_channel_init( 1 , &opb_desc ); 80 81 //////////////////////// initializes channel for RES 82 giet_coproc_channel_t res_desc; 83 res_desc.channel_mode = DMA_MODE; 84 res_desc.buffer_size = VECTOR_SIZE<<2; 85 res_desc.buffer_vaddr = (unsigned int)res; 86 giet_coproc_channel_init( 2 , &res_desc ); 87 88 if ( VERBOSE ) 89 giet_shr_printf("\n*** channels initialized at cycle %d\n", giet_proctime() ); 60 90 61 desc.channel_mode = MODE_DMA_NO_IRQ; 62 desc.buffer_size = VECTOR_SIZE<<2; 63 desc.buffer_vaddr = (unsigned int)opa; 91 /////////////////////// starts communication channels 92 giet_coproc_run( 0 ); 64 93 65 giet_coproc_channel_init( cluster_xy , 0 , &desc ); 66 67 desc.channel_mode = MODE_DMA_NO_IRQ; 68 desc.buffer_size = VECTOR_SIZE<<2; 69 desc.buffer_vaddr = (unsigned int)opb; 94 if ( VERBOSE ) 95 giet_shr_printf("\n*** start GCD coprocessor at cycle %d\n", giet_proctime() ); 70 96 71 giet_coproc_channel_init( cluster_xy , 1 , &desc );72 73 desc.channel_mode = MODE_DMA_IRQ;74 desc.buffer_size = VECTOR_SIZE<<2;75 desc.buffer_vaddr = (unsigned int)res;97 /////////////////////// wait coprocessor completion 98 if ( DMA_MODE == MODE_DMA_NO_IRQ ) 99 { 100 giet_coproc_completed( ); 101 } 76 102 77 giet_coproc_channel_init( cluster_xy , 2 , &desc ); 78 79 if ( VERBOSE ) 80 giet_shr_printf("\n*** initialise coomunication channels at cycle %d\n", 81 giet_proctime() ); 82 83 // starts communication channels 84 giet_coproc_channel_start( cluster_xy , 0 ); 85 giet_coproc_channel_start( cluster_xy , 1 ); 86 giet_coproc_channel_start( cluster_xy , 2 ); 87 88 if ( VERBOSE ) 89 giet_shr_printf("\n*** start communication channels at cycle %d\n", 90 giet_proctime() ); 91 92 // starts GCD coprocessor 93 giet_coproc_register_set( cluster_xy , 0 , 1 ); 94 95 if ( VERBOSE ) 96 giet_shr_printf("\n*** start GCD coprocessor at cycle %d\n", 97 giet_proctime() ); 98 99 // wait coprocessor completion 100 giet_coproc_completed( cluster_xy ); 101 102 if ( VERBOSE ) 103 giet_shr_printf("\n*** GCD computation completed at cycle %d\n", 104 giet_proctime() ); 103 if ( VERBOSE ) 104 giet_shr_printf("\n*** GCD computation completed at cycle %d\n", giet_proctime() ); 105 105 106 106 // display result … … 111 111 } 112 112 113 ////////////////////// release GCD coprocessor 114 giet_coproc_release( 0 ); 115 113 116 giet_exit("completed"); 114 117
Note: See TracChangeset
for help on using the changeset viewer.