tester/g_ult/unit_tests/gpu/common.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Create huge buffer that will contain all input
Create huge buffer that will contain all input
Create huge buffer that will contain all input
void generate_input_data( float *        &buffer,
                          uint_least32_t input_width,
                          uint_least32_t input_height,
                          uint_least32_t input_depth,
                          uint_least32_t num_inputs )
{
    std::uniform_real_distribution< float > rand_val( 0.0f, 1.0f );
    std::random_device rd;
    assert( buffer == nullptr );
    uint_least32_t total_size = input_width * input_height * input_depth * num_inputs * sizeof( float );
#ifdef __linux__
    buffer = ( float * )memalign( page_alignment, total_size );
#else
    buffer = ( float * )_aligned_malloc( total_size, page_alignment );
#endif 
    for( uint_least32_t i = 0; i < total_size / sizeof( float ); ++i )
    {
        buffer[i] = rand_val( rd );
    }
}
void generate_input_data ( float * & buffer , uint_least32_t input_width , uint_least32_t input_height , uint_least32_t input_depth , uint_least32_t num_inputs ) { std :: uniform_real_distribution < float > rand_val ( 0.0f , 1.0f ) ; std :: random_device rd ; assert ( buffer == nullptr ) ; uint_least32_t total_size = input_width * input_height * input_depth * num_inputs * sizeof ( float ) ; #ifdef __linux__ buffer = ( float * ) memalign ( page_alignment , total_size ) ; #else buffer = ( float * ) _aligned_malloc ( total_size , page_alignment ) ; #endif for ( uint_least32_t i = 0 ; i < total_size / sizeof ( float ) ; ++ i ) { buffer [ i ] = rand_val ( rd ) ; } }
Create huge buffer that will contain all input
Create huge buffer that will contain all input
// Sanity check // Memory need to be aligned to page , so that OCL driver not to // duplicate buffer data by creating aligned copy //__linux__ //buffer[i] = i;