int main(int argc, char** argv) { printf("Running MD Skeleton\n"); /* Thread numbers for Host */ int num_threads = 1; int teams = 1; /* Default value for number of force calculations */ int iter = 100; /* Default value for system size (4*nx*ny*nz atoms) * nx, ny and nz are set to system_size if not specififed on commandline */ int system_size = 20; int nx = -1; int ny = -1; int nz = -1; int neighbor_size = 1; // Default bin size for neighbor list construction double rho = 0.8442; // Number density of the system double delta = 0; // Scaling factor for random offsets of atom positions int device = 0; // Default device for GPU runs /* read in command-line arguments */ for(int i = 0; i < argc; i++) { if((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "--num_threads") == 0)) { num_threads = atoi(argv[++i]); continue; } if((strcmp(argv[i], "--teams") == 0)) { teams = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-d") == 0) || (strcmp(argv[i], "--device") == 0)) { device = atoi(argv[++i]); continue; } if((strcmp(argv[i], "--delta") == 0)) { delta = atof(argv[++i]); continue; } if((strcmp(argv[i], "-i") == 0) || (strcmp(argv[i], "--iter") == 0)) { iter = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-rho") == 0)) { rho = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-s") == 0) || (strcmp(argv[i], "--size") == 0)) { system_size = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-nx") == 0)) { nx = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-ny") == 0)) { ny = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-nz") == 0)) { nz = atoi(argv[++i]); continue; } if((strcmp(argv[i], "-b") == 0) || (strcmp(argv[i], "--neigh_bins") == 0)) { neighbor_size = atoi(argv[++i]); continue; } } if( nx < 0 ) nx = system_size; if( ny < 0 ) ny = system_size; if( nz < 0 ) nz = system_size; printf("-> Init Device\n"); #if defined( KOKKOS_HAVE_CUDA ) Kokkos::Cuda::host_mirror_device_type::initialize(teams*num_threads); Kokkos::Cuda::SelectDevice select_device(device); Kokkos::Cuda::initialize(select_device); #elif defined( KOKKOS_HAVE_OPENMP ) Kokkos::OpenMP::initialize(teams*num_threads); #elif defined( KOKKOS_HAVE_PTHREAD ) Kokkos::Threads::initialize(teams*num_threads); #endif System system; system.neigh_cut = 2.8; system.force_cut = 2.5; system.force_cutsq = system.force_cut*system.force_cut; system.delta = delta; printf("-> Build system\n"); create_system(system,nx,ny,nz,rho); printf("-> Created %i atoms and %i ghost atoms\n",system.nlocal,system.nghost); system.nbinx = system.box.xprd/neighbor_size+1; system.nbiny = system.box.yprd/neighbor_size+1; system.nbinz = system.box.zprd/neighbor_size+1; printf("-> Building Neighborlist\n"); neigh_setup(system); neigh_build(system); double2 ev = force(system,1); printf("-> Calculate Energy: %lf Virial: %lf\n",ev.x,ev.y); printf("-> Running %i force calculations\n",iter); Kokkos::Impl::Timer timer; for(int i=0;i<iter;i++) { force(system,0); } double time = timer.seconds(); printf("Time: %e s for %i iterations with %i atoms\n",time,iter,system.nlocal); device_type::finalize(); }
int main(int argc, char** argv) { /* Window manager data structures. */ struct wm_device* dev = NULL; struct wm_window* win = NULL; const struct wm_window_desc win_desc = { 800, 600, 0 }; /* Renderer data structure. */ struct rdr_glyph_desc glyph_desc_list[NB_CHARS]; struct rdr_font* font = NULL; struct rdr_frame* frame = NULL; struct rdr_system* sys = NULL; struct rdr_term* term = NULL; /* Resources data structure. */ struct rsrc_context* ctxt = NULL; struct rsrc_font* rfont = NULL; /* Miscellaneous data. */ const char* driver_name = NULL; const char* font_name = NULL; size_t line_space = 0; size_t i = 0; bool b = false; if(argc != 3) { printf("usage: %s RB_DRIVER FONT\n", argv[0]); return -1; } driver_name = argv[1]; font_name = argv[2]; /* Setup the render font. */ RSRC(create_context(NULL, &ctxt)); RSRC(create_font(ctxt, font_name, &rfont)); if(RSRC(is_font_scalable(rfont, &b)), b) RSRC(font_size(rfont, 18, 18)); for(i = 0; i < NB_CHARS; ++i) { struct rsrc_glyph* glyph = NULL; struct rsrc_glyph_desc glyph_desc; size_t width = 0; size_t height = 0; size_t Bpp = 0; size_t size = 0; RSRC(font_glyph(rfont, (wchar_t)(i + FIRST_CHAR), &glyph)); /* Get glyph desc. */ RSRC(glyph_desc(glyph, &glyph_desc)); glyph_desc_list[i].width = glyph_desc.width; glyph_desc_list[i].character = glyph_desc.character; glyph_desc_list[i].bitmap_left = glyph_desc.bbox.x_min; glyph_desc_list[i].bitmap_top = glyph_desc.bbox.y_min; /* Get glyph bitmap. */ RSRC(glyph_bitmap(glyph, true, &width, &height, &Bpp, NULL)); glyph_desc_list[i].bitmap.width = width; glyph_desc_list[i].bitmap.height = height; glyph_desc_list[i].bitmap.bytes_per_pixel = Bpp; glyph_desc_list[i].bitmap.buffer = NULL; size = width * height * Bpp; if(0 != size) { unsigned char* buffer = MEM_CALLOC(&mem_default_allocator, 1, size); RSRC(glyph_bitmap(glyph, true, NULL, NULL, NULL, buffer)); glyph_desc_list[i].bitmap.buffer = buffer; } RSRC(glyph_ref_put(glyph)); } RSRC(font_line_space(rfont, &line_space)); RSRC(font_ref_put(rfont)); RSRC(context_ref_put(ctxt)); WM(create_device(NULL, &dev)); WM(create_window(dev, &win_desc, &win)); RDR(create_system(driver_name, NULL, &sys)); RDR(create_frame (sys, (struct rdr_frame_desc[]){{win_desc.width,win_desc.height}}, &frame));