Changeset 683 for trunk/kernel/libk/remote_barrier.c
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_barrier.c
r671 r683 2 2 * remote_barrier.c - POSIX barrier implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019)4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 84 84 { 85 85 generic_barrier_t * gen_barrier_ptr; // local pointer on generic barrier descriptor 86 void * barrier; // local pointer on implementation barrier descriptor 87 kmem_req_t req; // kmem request 86 void * barrier; // local pointer on impl barrier descriptor 88 87 89 88 // get pointer on local process_descriptor … … 96 95 97 96 // allocate memory for generic barrier descriptor 98 req.type = KMEM_KCM; 99 req.order = bits_log2( sizeof(generic_barrier_t) ); 100 req.flags = AF_ZERO | AF_KERNEL; 101 gen_barrier_ptr = kmem_remote_alloc( ref_cxy , &req ); 102 97 gen_barrier_ptr = kmem_remote_alloc( ref_cxy, 98 bits_log2(sizeof(generic_barrier_t)), 99 AF_KERNEL ); 103 100 if( gen_barrier_ptr == NULL ) 104 101 { … … 108 105 109 106 // create implementation specific barrier descriptor 110 if( attr == NULL ) // simple barrier implementation107 if( attr == NULL ) // simple barrier 111 108 { 112 109 // create simple barrier descriptor 113 110 barrier = simple_barrier_create( count ); 114 115 if( barrier == NULL ) return -1; 116 } 117 else // QDT barrier implementation 111 } 112 else // QDT barrier 118 113 { 119 114 uint32_t x_size = attr->x_size; … … 126 121 printk("\n[ERROR] in %s : count(%d) != x_size(%d) * y_size(%d) * nthreads(%d)\n", 127 122 __FUNCTION__, count, x_size, y_size, nthreads ); 123 kmem_remote_free( ref_cxy, 124 gen_barrier_ptr, 125 bits_log2(sizeof(generic_barrier_t)) ); 128 126 return -1; 129 127 } … … 131 129 // create DQT barrier descriptor 132 130 barrier = dqt_barrier_create( x_size , y_size , nthreads ); 133 134 if( barrier == NULL ) return -1; 131 } 132 133 if( barrier == NULL ) 134 { 135 printk("\n[ERROR] in %s : cannot create impl barrier\n", __FUNCTION__ ); 136 kmem_remote_free( ref_cxy, 137 gen_barrier_ptr, 138 bits_log2(sizeof(generic_barrier_t)) ); 139 return -1; 135 140 } 136 141 … … 157 162 void generic_barrier_destroy( xptr_t gen_barrier_xp ) 158 163 { 159 kmem_req_t req; // kmem request160 161 164 // get pointer on local process_descriptor 162 165 process_t * process = CURRENT_THREAD->process; … … 191 194 remote_busylock_release( lock_xp ); 192 195 193 // release memory allocated to barrier descriptor194 req.type = KMEM_KCM;195 req.ptr = gen_barrier_ptr;196 kmem_remote_free( ref_cxy , &req);196 // release memory allocated to generic barrier descriptor 197 kmem_remote_free( gen_barrier_cxy, 198 gen_barrier_ptr, 199 bits_log2(sizeof(generic_barrier_t)) ); 197 200 198 201 } // end generic_barrier_destroy() … … 246 249 simple_barrier_t * simple_barrier_create( uint32_t count ) 247 250 { 248 kmem_req_t req;249 251 simple_barrier_t * barrier; 250 252 … … 258 260 259 261 // allocate memory for simple barrier descriptor 260 req.type = KMEM_KCM; 261 req.order = bits_log2( sizeof(simple_barrier_t) ); 262 req.flags = AF_ZERO | AF_KERNEL; 263 barrier = kmem_remote_alloc( ref_cxy , &req ); 264 262 barrier = kmem_remote_alloc( ref_cxy, 263 bits_log2(sizeof(simple_barrier_t)), 264 AF_ZERO ); 265 265 if( barrier == NULL ) 266 266 { … … 291 291 void simple_barrier_destroy( xptr_t barrier_xp ) 292 292 { 293 kmem_req_t req;294 295 293 // get barrier cluster and local pointer 296 294 cxy_t barrier_cxy = GET_CXY( barrier_xp ); … … 298 296 299 297 // release memory allocated for barrier descriptor 300 req.type = KMEM_KCM;301 req.ptr = barrier_ptr;302 kmem_remote_free( barrier_cxy , &req);298 kmem_remote_free( barrier_cxy, 299 barrier_ptr, 300 bits_log2(sizeof(simple_barrier_t)) ); 303 301 304 302 #if DEBUG_BARRIER_DESTROY … … 471 469 uint32_t y; // Y coordinate in QDT mesh 472 470 uint32_t l; // level coordinate 473 kmem_req_t req; // kmem request474 471 475 472 // compute number of DQT levels, depending on the mesh size … … 478 475 479 476 // check x_size and y_size arguments 480 assert( __FUNCTION__, (z <= 16) , "DQT mesh size larger than (16*16)\n"); 477 assert( __FUNCTION__, (z <= 16), 478 "DQT mesh size larger than (16*16)\n"); 481 479 482 480 // check size of an array of 5 DQT nodes 483 assert( __FUNCTION__, (sizeof(dqt_node_t) * 5 <= 512 ), "array of DQT nodes larger than 512 bytes\n"); 481 assert( __FUNCTION__, (sizeof(dqt_node_t) * 5 <= 512 ), 482 "array of DQT nodes larger than 512 bytes\n"); 484 483 485 484 // check size of DQT barrier descriptor 486 assert( __FUNCTION__, (sizeof(dqt_barrier_t) <= 0x4000 ), "DQT barrier descriptor larger than 4 pages\n"); 485 assert( __FUNCTION__, (sizeof(dqt_barrier_t) <= 0x4000 ), 486 "DQT barrier descriptor larger than 4 pages\n"); 487 487 488 488 // get pointer on client thread and process descriptors … … 502 502 503 503 // 1. allocate 4 small pages for the DQT barrier descriptor in reference cluster 504 req.type = KMEM_PPM; 505 req.order = 2; // 4 small pages == 16 Kbytes 506 req.flags = AF_ZERO | AF_KERNEL; 507 barrier = kmem_remote_alloc( ref_cxy , &req ); 508 504 barrier = kmem_remote_alloc( ref_cxy, 505 CONFIG_PPM_PAGE_ORDER + 2, // 4 small pages 506 AF_ZERO ); 509 507 if( barrier == NULL ) 510 508 { … … 536 534 { 537 535 cxy_t cxy = HAL_CXY_FROM_XY( x , y ); // target cluster identifier 538 xptr_t local_array_xp; // xptr o fnodes array in cluster cxy536 xptr_t local_array_xp; // xptr on nodes array in cluster cxy 539 537 540 538 // allocate memory in existing clusters only 541 539 if( LOCAL_CLUSTER->cluster_info[x][y] ) 542 540 { 543 req.type = KMEM_KCM; 544 req.order = 9; // 512 bytes 545 req.flags = AF_ZERO | AF_KERNEL; 546 547 void * ptr = kmem_remote_alloc( cxy , &req ); 541 void * ptr = kmem_remote_alloc( cxy , 9 , AF_ZERO ); // 512 bytes 548 542 549 543 if( ptr == NULL ) … … 729 723 void dqt_barrier_destroy( xptr_t barrier_xp ) 730 724 { 731 kmem_req_t req; // kmem request732 725 uint32_t x; 733 726 uint32_t y; 734 735 727 736 728 // get DQT barrier descriptor cluster and local pointer … … 767 759 void * buf = GET_PTR( buf_xp ); 768 760 769 assert( __FUNCTION__, (cxy == GET_CXY(buf_xp)) , "bad extended pointer on dqt_nodes array\n" ); 770 771 req.type = KMEM_KCM; 772 req.ptr = buf; 773 kmem_remote_free( cxy , &req ); 761 kmem_remote_free( cxy , buf , 9 ); // 512 bytes 774 762 775 763 #if DEBUG_BARRIER_DESTROY … … 785 773 786 774 // 2. release memory allocated for barrier descriptor in ref cluster 787 req.type = KMEM_PPM;788 req.ptr = barrier_ptr;789 kmem_remote_free( barrier_cxy , &req );775 kmem_remote_free( barrier_cxy, 776 barrier_ptr, 777 CONFIG_PPM_PAGE_ORDER + 2 ); // 4 small pages 790 778 791 779 #if DEBUG_BARRIER_DESTROY
Note: See TracChangeset
for help on using the changeset viewer.