void bli_l3_thrinfo_free ( thrinfo_t* thread ) { if ( thread == NULL || thread == &BLIS_PACKM_SINGLE_THREADED || thread == &BLIS_GEMM_SINGLE_THREADED ) return; thrinfo_t* thrinfo_sub_node = bli_thrinfo_sub_node( thread ); // Free the communicators, but only if the current thrinfo_t struct // is marked as needing them to be freed. The most common example of // thrinfo_t nodes NOT marked as needing their comms freed are those // associated with packm thrinfo_t nodes. if ( bli_thrinfo_needs_free_comm( thread ) ) { // The ochief always frees his communicator, and the ichief free its // communicator if we are at the leaf node. if ( bli_thread_am_ochief( thread ) ) bli_thrcomm_free( bli_thrinfo_ocomm( thread ) ); } // Free all children of the current thrinfo_t. bli_l3_thrinfo_free( thrinfo_sub_node ); // Free the thrinfo_t struct. bli_free_intl( thread ); }
void bli_thrcomm_cleanup( thrcomm_t* communicator ) { if ( communicator == NULL ) return; for ( dim_t i = 0; i < communicator->n_threads; i++ ) { bli_thrcomm_tree_barrier_free( communicator->barriers[i] ); } bli_free_intl( communicator->barriers ); }
void bli_level3_thread_decorator ( dim_t n_threads, l3_int_t func, obj_t* alpha, obj_t* a, obj_t* b, obj_t* beta, obj_t* c, void* cntx, void* cntl, void** thread ) { pthread_t* pthreads = (pthread_t*) bli_malloc_intl(sizeof(pthread_t) * n_threads); thread_data_t* datas = (thread_data_t*) bli_malloc_intl(sizeof(thread_data_t) * n_threads); for( int i = 1; i < n_threads; i++ ) { //Setup the thread data datas[i].func = func; datas[i].alpha = alpha; datas[i].a = a; datas[i].b = b; datas[i].beta = beta; datas[i].c = c; datas[i].cntx = cntx; datas[i].cntl = cntl; datas[i].thread = thread[i]; pthread_create( &pthreads[i], NULL, &thread_decorator_helper, &datas[i] ); } func( alpha, a, b, beta, c, cntx, cntl, thread[0] ); for( int i = 1; i < n_threads; i++) { pthread_join( pthreads[i], NULL ); } bli_free_intl( pthreads ); bli_free_intl( datas ); }
void bli_thrcomm_tree_barrier_free( barrier_t* barrier ) { if ( barrier == NULL ) return; barrier->count--; if ( barrier->count == 0 ) { bli_thrcomm_tree_barrier_free( barrier->dad ); bli_free_intl( barrier ); } return; }
void bli_l3_thrinfo_free_paths ( thrinfo_t** threads ) { dim_t n_threads = bli_thread_num_threads( threads[0] ); dim_t i; for ( i = 0; i < n_threads; ++i ) bli_l3_thrinfo_free( threads[i] ); bli_free_intl( threads ); }
void bli_gemm_thrinfo_free( gemm_thrinfo_t* thread) { if( thread == NULL || thread == &BLIS_GEMM_SINGLE_THREADED ) return; // Free Communicators if( thread_am_ochief( thread ) ) bli_free_communicator( thread->ocomm ); if( thread->sub_gemm == NULL && thread_am_ichief( thread ) ) bli_free_communicator( thread->icomm ); // Free Sub Thrinfos bli_packm_thrinfo_free( thread->opackm ); bli_packm_thrinfo_free( thread->ipackm ); bli_gemm_thrinfo_free( thread->sub_gemm ); bli_free_intl( thread ); return; }
void bli_thrcomm_free( thrcomm_t* communicator ) { if ( communicator == NULL ) return; bli_thrcomm_cleanup( communicator ); bli_free_intl( communicator ); }
void bli_blksz_obj_free( blksz_t* b ) { bli_free_intl( b ); }
void bli_func_free( func_t* f ) { bli_free_intl( f ); }
void bli_gemm_thrinfo_free_paths( gemm_thrinfo_t** threads, dim_t num ) { for( int i = 0; i < num; i++) bli_gemm_thrinfo_free( threads[i] ); bli_free_intl( threads ); }
void bli_free_communicator( thread_comm_t* communicator ) { if( communicator == NULL ) return; bli_cleanup_communicator( communicator ); bli_free_intl( communicator ); }