示例#1
0
文件: bli_pool.c 项目: ShawnLess/blis
void bli_pool_free_block( pblk_t* block )
{
	void* buf_sys;

	// Extract the pointer to the block that was originally provided by
	// the operating system.
	buf_sys = bli_pblk_buf_sys( block );

	// Free the block.
	bli_free( buf_sys );
}
void bli_level3_thread_decorator( dim_t n_threads,
                                  level3_int_t func,
                                  obj_t* alpha,
                                  obj_t* a,
                                  obj_t* b,
                                  obj_t* beta,
                                  obj_t* c,
                                  void* cntl,
                                  void** thread )
{
    pthread_t* pthreads = (pthread_t*) bli_malloc(sizeof(pthread_t) * n_threads);
    //Saying "datas" is kind of like saying "all y'all"
    thread_data_t* datas = (thread_data_t*) bli_malloc(sizeof(thread_data_t) * n_threads);
    //pthread_attr_t* attr = (pthread_attr_t*) bli_malloc(sizeof(pthread_attr_t) * n_threads);

    for( int i = 0; 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].cntl = cntl;
        datas[i].thread = thread[i];
        pthread_create( &pthreads[i], NULL, &thread_decorator_helper, &datas[i] );
    }

    for( int i = 0; i < n_threads; i++)
    {
        pthread_join( pthreads[i], NULL );
    }

    bli_free( pthreads );
    bli_free( datas );
}
示例#3
0
void bli_herk_thrinfo_free( herk_thrinfo_t* thread)
{
    if( thread == NULL ) return;

    // Free Communicators
    if( thread_am_ochief( thread ) ) 
        bli_free_communicator( thread->ocomm );

    // Free Sub Thrinfos
    bli_packm_thrinfo_free( thread->opackm );
    bli_packm_thrinfo_free( thread->ipackm );
    bli_herk_thrinfo_free( thread->sub_herk );
    bli_free( thread );
        
    return; 
}
示例#4
0
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 );

    // Free Sub Thrinfos
    bli_packm_thrinfo_free( thread->opackm );
    bli_packm_thrinfo_free( thread->ipackm );
    bli_gemm_thrinfo_free( thread->sub_gemm );
    bli_free( thread );
    
    return; 
}
示例#5
0
文件: bli_pool.c 项目: ShawnLess/blis
void bli_pool_finalize( pool_t* pool )
{
	pblk_t* block_ptrs;
	dim_t   num_blocks;
	dim_t   top_index;
	dim_t   i;

	// NOTE: This implementation assumes that either:
	// - all blocks have been checked in by all threads, or
	// - some subset of blocks have been checked in and the caller
	//   is bli_pool_reinit().

	// Query the current block_ptrs array.
	block_ptrs = bli_pool_block_ptrs( pool );

	// Query the total number of blocks presently allocated.
	num_blocks = bli_pool_num_blocks( pool );

	// Query the top_index of the pool.
	top_index  = bli_pool_top_index( pool );

	// Free the individual blocks currently in the pool.
	for ( i = top_index; i < num_blocks; ++i )
	{
		bli_pool_free_block( &(block_ptrs[i]) );
	}

	// Free the block_ptrs array.
	bli_free( block_ptrs );

	// Clear the contents of the pool_t struct.
	bli_pool_set_block_ptrs( NULL, pool );
	bli_pool_set_block_ptrs_len( 0, pool );
	bli_pool_set_num_blocks( 0, pool );
	bli_pool_set_top_index( 0, pool );
	bli_pool_set_block_size( 0, pool );
	bli_pool_set_align_size( 0, pool );
}
示例#6
0
文件: bli_pool.c 项目: rwl/blis
void bli_pool_finalize( pool_t* pool )
{
	pblk_t* block_ptrs;
	dim_t   num_blocks;
	dim_t   i;

	// NOTE: This implementation assumes that all blocks have been
	// checked in by all threads.

	// Query the current block_ptrs array and total number of blocks
	// presently allocated.
	block_ptrs = bli_pool_block_ptrs( pool );
	num_blocks = bli_pool_num_blocks( pool );

	// Free the individual blocks.
	for ( i = 0; i < num_blocks; ++i )
	{
		bli_pool_free_block( &(block_ptrs[i]) );
	}

	// Free the block_ptrs array.
	bli_free( block_ptrs );
}
示例#7
0
void bli_packm_thread_info_free( packm_thread_info_t* info )
{
    bli_free( info );
}
示例#8
0
void bli_blksz_obj_free( blksz_t* b )
{
	bli_free( b );
}
示例#9
0
void bli_free_communicator( thread_comm_t* communicator )
{
    if( communicator == NULL ) return;
    bli_cleanup_communicator( communicator );
    bli_free( communicator );
}
示例#10
0
void bli_trmm_thrinfo_free_paths( trmm_thrinfo_t** threads, dim_t num )
{
    for( int i = 0; i < num; i++)
        bli_trmm_thrinfo_free( threads[i] );
    bli_free( threads );
}
示例#11
0
文件: bli_cntl.c 项目: ShawnLess/blis
void bli_cntl_obj_free( void* cntl )
{
	bli_free( cntl );
}
示例#12
0
文件: bli_pool.c 项目: ShawnLess/blis
void bli_pool_grow( dim_t num_blocks_add, pool_t* pool )
{
	pblk_t* block_ptrs_cur;
	dim_t   block_ptrs_len_cur;
	dim_t   num_blocks_cur;

	pblk_t* block_ptrs_new;
	dim_t   num_blocks_new;

	siz_t   block_size;
	siz_t   align_size;
	dim_t   top_index;

	dim_t   i;

	// If the requested increase is zero (or negative), return early.
	if ( num_blocks_add < 1 ) return;

	// Query the allocated length of the block_ptrs array and also the
	// total number of blocks allocated.
	block_ptrs_len_cur = bli_pool_block_ptrs_len( pool );
	num_blocks_cur     = bli_pool_num_blocks( pool );

	// Compute the total number of allocated blocks that will exist
	// after we grow the pool.
	num_blocks_new = num_blocks_cur + num_blocks_add;

	// If the new total number of allocated blocks is larger than the
	// allocated length of the block_ptrs array, we need to allocate
	// a new (larger) block_ptrs array.
	if ( num_blocks_new > block_ptrs_len_cur )
	{
		// Query the current block_ptrs array.
		block_ptrs_cur = bli_pool_block_ptrs( pool );

		// Allocate a new block_ptrs array of length num_blocks_new.
		block_ptrs_new = bli_malloc( num_blocks_new * sizeof( pblk_t ) );

		// Query the top_index of the pool.
		top_index = bli_pool_top_index( pool );

		// Copy the contents of the old block_ptrs array to the new/resized
		// array. Notice that we can begin with top_index since all entries
		// from 0 to top_index-1 have been checked out to threads.
		for ( i = top_index; i < num_blocks_cur; ++i ) 
		{
//printf( "bli_pool_grow: copying from %lu\n", top_index );
			block_ptrs_new[i] = block_ptrs_cur[i];
		}

//printf( "bli_pool_grow: bp_cur: %p\n", block_ptrs_cur );
		// Free the old block_ptrs array.
		bli_free( block_ptrs_cur );

		// Update the pool_t struct with the new block_ptrs array and
		// record its allocated length.
		bli_pool_set_block_ptrs( block_ptrs_new, pool );
		bli_pool_set_block_ptrs_len( num_blocks_new, pool );
	}

	// At this point, we are guaranteed to have enough unused elements
	// in the block_ptrs array to accommodate an additional num_blocks_add
	// blocks.

	// Query the current block_ptrs array (which was possibly just resized).
	block_ptrs_cur = bli_pool_block_ptrs( pool );

	// Query the block size and alignment size of the current pool.
	block_size = bli_pool_block_size( pool );
	align_size = bli_pool_align_size( pool );

	// Allocate the requested additional blocks in the resized array.
	for ( i = num_blocks_cur; i < num_blocks_new; ++i ) 
	{
//printf( "libblis: growing pool, block_size = %lu\n", block_size ); fflush( stdout );

		bli_pool_alloc_block( block_size, align_size, &(block_ptrs_cur[i]) );
	}

	// Update the pool_t struct with the new number of allocated blocks.
	// Notice that top_index remains unchanged, as do the block_size and
	// align_size fields.
	bli_pool_set_num_blocks( num_blocks_new, pool );
}