void atags_detect(uint32_t *atags, struct atag_info_t *info) { /* each tag has at least 32-bit size and then 32-bit value */ /* some tags have multiple values */ uint32_t size,total_ram; // int tag_value; uint32_t *tags=atags; char *cmdline; /* clear out the info array */ memset(info,0,sizeof(struct atag_info_t)); while(1) { size=tags[0]; switch (tags[1]) { /* Start List */ case ATAG_CORE: tags += size; break; /* Physical Memory */ case ATAG_MEM: total_ram=tags[2]; if (tags[3]!=0) { printk("Warning! We do not handle memory not starting at zero!\n"); } info->ramsize=total_ram; tags += size; break; /* VGA Text Display */ case ATAG_VIDEOTEXT: tags += size; break; /* RAMDISK Use */ case ATAG_RAMDISK: tags += size; break; /* INITRD Ramdisk */ case ATAG_INITRD2: tags += size; break; /* 64-bit serial number */ case ATAG_SERIAL: tags += size; break; /* Board Revision */ case ATAG_REVISION: tags += size; break; /* VESA Framebuffer Info */ case ATAG_VIDEOLFB: tags += size; break; case ATAG_CMDLINE: cmdline = (char *)(&tags[2]); info->framebuffer_x=parse_cmdline_int(cmdline,"fbwidth"); info->framebuffer_y=parse_cmdline_int(cmdline,"fbheight"); info->revision=parse_cmdline_int(cmdline,"rev"); /* http://elinux.org/RPi_HardwareHistory */ switch(info->revision) { case 0x2: case 0x3: case 0x4: case 0x5: case 0x6: case 0xd: case 0xe: case 0xf: info->hardware_type=RPI_MODEL_B; break; case 0x7: case 0x8: case 0x9: info->hardware_type=RPI_MODEL_A; break; case 0x10: info->hardware_type=RPI_MODEL_BPLUS; break; case 0x11: info->hardware_type=RPI_COMPUTE_NODE; break; case 0x12: info->hardware_type=RPI_MODEL_APLUS; break; default: info->hardware_type=RPI_UNKNOWN; break; } tags += size; break; /* Empty tag to end list */ case ATAG_NONE: return; break; default: printk("ERROR! Unknown atag\n"); break; } } }
int main( int argc, char** argv ) { int ni; long N; pvo_cookie_t cookie; pvo_float3_t* pts; int* cia; int* cja; uint8_t* types; pvo_vtu_file_t fh; double* U; float* V; int* ranks; double t0, t1, t2, t3; long i, nnodes, ncells; int N_u, N_v, N_r; double r_min, r_max, gamma; MPI_Init( &argc, &argv ); pvo_init( MPI_COMM_WORLD ); MPI_Barrier( MPI_COMM_WORLD ); t0 = MPI_Wtime(); // Minimal and maximal value for the radius r_min = parse_cmdline_double(); r_max = parse_cmdline_double(); gamma = parse_cmdline_double(); // Number of grid cells for each direction N_u = parse_cmdline_double(); N_v = parse_cmdline_double(); N_r = parse_cmdline_double(); /* The data is decomposed by slicing in the radial direction */ decompose( &N_r, &r_min, &r_max ); nnodes = (N_u+1)*(N_v+1)*(N_r+1); ncells = N_u * N_v * N_r ; pts = malloc( nnodes*sizeof(pvo_float3_t) ); cia = malloc( (ncells+1)*sizeof(int) ); cja = malloc( 8*ncells*sizeof(int) ); U = malloc( nnodes*3*sizeof(double) ); V = malloc( ncells*sizeof(float) ); types = malloc( ncells*sizeof(uint8_t) ); ranks = malloc( ncells*sizeof(int) ); ni = parse_cmdline_int(); if( 0 == pvo_world_rank() ) { printf( " +-----------------------------------------+\n" ); printf( " | PVO CHUNK VTU BENCHMARK |\n" ); printf( " +-----------------------------------------+\n" ); printf( "\n"); printf( " PVO_DEFAULT_LOW_IO_LAYER : \"%s\"\n", str_low_io_layer[PVO_DEFAULT_LOW_IO_LAYER] ); printf( " no of cores : %d\n", pvo_world_size() ); printf( " no of nodes : %d\n", nnodes ); printf( " no of cells : %d\n", ncells ); printf( " no of islands : %d\n", ni ); } create_chunk( N_u, N_v, N_r, r_min, r_max, gamma, nnodes, pts, ncells, cia, cja, types, U, V ); for( i = 0; i < ncells; ++i ) ranks[i] = pvo_world_rank(); if( -1 == pvo_cookie_create( pvo_world_rank()%ni, &cookie )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); if( -1 == pvo_cookie_insert_var( cookie, PVO_VAR_NODEDATA, PVO_VAR_FLOAT64, 3, "U", U )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); if( -1 == pvo_cookie_insert_var( cookie, PVO_VAR_CELLDATA, PVO_VAR_FLOAT32, 1, "V", V )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); if( -1 == pvo_cookie_insert_var( cookie, PVO_VAR_CELLDATA, PVO_VAR_INT32, 1, "ranks", ranks )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); if( -1 == pvo_vtu_file_open( "chunk", cookie, nnodes, pts, ncells, cia, cja, types, &fh )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); MPI_Barrier( MPI_COMM_WORLD ); t1 = MPI_Wtime(); pvo_file_write( (pvo_file_t )fh ); MPI_Barrier( MPI_COMM_WORLD ); t2 = MPI_Wtime(); if( 0 == pvo_world_rank() ) printf( " time [sec] : %f\n", t2-t1 ); N = (3*4/*pts*/ + 3*8/*U*/)*nnodes + (4/*cia*/ + 8*4/*cja*/ + 1/*types*/ + 4/*V*/ + 4/*ranks*/)*ncells; MPI_Allreduce( MPI_IN_PLACE, &N, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); if( 0 == pvo_world_rank() ) printf( " bandwidth [MB/sec] : %f\n", (1.0*N)/(1048576*(t2-t1)) ); if( -1 == pvo_vtu_file_close( fh )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); if( -1 == pvo_cookie_delete( cookie )) MPI_Abort( MPI_COMM_WORLD, __LINE__ ); MPI_Barrier( MPI_COMM_WORLD ); t3 = MPI_Wtime(); if( 0 == pvo_world_rank() ) { printf( " total execution time [sec] : %f\n", t3-t0 ); printf( "\n" ); } pvo_quit(); return MPI_Finalize(); }