// host stub function void ops_par_loop_calc_dt_kernel_get(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3) { ops_arg args[4] = { arg0, arg1, arg2, arg3}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args,4,range,29)) return; #endif ops_timing_realloc(29,"calc_dt_kernel_get"); OPS_kernels[29].count++; //compute locally allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<2; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<2; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int xdim0 = args[0].dat->size[0]*args[0].dat->dim; int xdim1 = args[1].dat->size[0]*args[1].dat->dim; //build opencl kernel if not already built buildOpenCLKernels_calc_dt_kernel_get( xdim0,xdim1); //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); //set up OpenCL thread blocks size_t globalWorkSize[3] = {((x_size-1)/OPS_block_size_x+ 1)*OPS_block_size_x, ((y_size-1)/OPS_block_size_y + 1)*OPS_block_size_y, 1}; size_t localWorkSize[3] = {OPS_block_size_x,OPS_block_size_y,1}; #ifdef OPS_MPI double *arg2h = (double *)(((ops_reduction)args[2].data)->data + ((ops_reduction)args[2].data)->size * block->index); #else //OPS_MPI double *arg2h = (double *)(((ops_reduction)args[2].data)->data); #endif //OPS_MPI #ifdef OPS_MPI double *arg3h = (double *)(((ops_reduction)args[3].data)->data + ((ops_reduction)args[3].data)->size * block->index); #else //OPS_MPI double *arg3h = (double *)(((ops_reduction)args[3].data)->data); #endif //OPS_MPI int nblocks = ((x_size-1)/OPS_block_size_x+ 1)*((y_size-1)/OPS_block_size_y + 1); int maxblocks = nblocks; int reduct_bytes = 0; reduct_bytes += ROUND_UP(maxblocks*1*sizeof(double)); reduct_bytes += ROUND_UP(maxblocks*1*sizeof(double)); reallocReductArrays(reduct_bytes); reduct_bytes = 0; int r_bytes2 = reduct_bytes/sizeof(double); arg2.data = OPS_reduct_h + reduct_bytes; arg2.data_d = OPS_reduct_d;// + reduct_bytes; for (int b=0; b<maxblocks; b++) for (int d=0; d<1; d++) ((double *)arg2.data)[d+b*1] = ZERO_double; reduct_bytes += ROUND_UP(maxblocks*1*sizeof(double)); int r_bytes3 = reduct_bytes/sizeof(double); arg3.data = OPS_reduct_h + reduct_bytes; arg3.data_d = OPS_reduct_d;// + reduct_bytes; for (int b=0; b<maxblocks; b++) for (int d=0; d<1; d++) ((double *)arg3.data)[d+b*1] = ZERO_double; reduct_bytes += ROUND_UP(maxblocks*1*sizeof(double)); mvReductArraysToDevice(reduct_bytes); int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); ops_H_D_exchanges_device(args, 4); ops_halo_exchanges(args,4,range); ops_H_D_exchanges_device(args, 4); ops_timers_core(&c1,&t1); OPS_kernels[29].mpi_time += t1-t2; int nthread = OPS_block_size_x*OPS_block_size_y; clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 0, sizeof(cl_mem), (void*) &arg0.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 1, sizeof(cl_mem), (void*) &arg1.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 2, sizeof(cl_mem), (void*) &arg2.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 3, nthread*sizeof(double), NULL)); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 4, sizeof(cl_int), (void*) &r_bytes2 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 5, sizeof(cl_mem), (void*) &arg3.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 6, nthread*sizeof(double), NULL)); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 7, sizeof(cl_int), (void*) &r_bytes3 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 8, sizeof(cl_int), (void*) &base0 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 9, sizeof(cl_int), (void*) &base1 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 10, sizeof(cl_int), (void*) &x_size )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[29], 11, sizeof(cl_int), (void*) &y_size )); //call/enque opencl kernel wrapper function clSafeCall( clEnqueueNDRangeKernel(OPS_opencl_core.command_queue, OPS_opencl_core.kernel[29], 3, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL) ); if (OPS_diags>1) { clSafeCall( clFinish(OPS_opencl_core.command_queue) ); } mvReductArraysToHost(reduct_bytes); for ( int b=0; b<maxblocks; b++ ){ for ( int d=0; d<1; d++ ){ arg2h[d] = arg2h[d] + ((double *)arg2.data)[d+b*1]; } } arg2.data = (char *)arg2h; for ( int b=0; b<maxblocks; b++ ){ for ( int d=0; d<1; d++ ){ arg3h[d] = arg3h[d] + ((double *)arg3.data)[d+b*1]; } } arg3.data = (char *)arg3h; ops_set_dirtybit_device(args, 4); //Update kernel record ops_timers_core(&c2,&t2); OPS_kernels[29].time += t2-t1; OPS_kernels[29].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[29].transfer += ops_compute_transfer(dim, range, &arg1); }
// host stub function void ops_par_loop_update_halo_kernel5_plus_2_left(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2) { // Timing double t1, t2, c1, c2; ops_arg args[3] = {arg0, arg1, arg2}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 3, range, 88)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(88, "update_halo_kernel5_plus_2_left"); OPS_kernels[88].count++; ops_timers_core(&c1, &t1); } // compute locally allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for (int n = 0; n < 3; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); } #else for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); int xdim0 = args[0].dat->size[0]; int ydim0 = args[0].dat->size[1]; int xdim1 = args[1].dat->size[0]; int ydim1 = args[1].dat->size[1]; // build opencl kernel if not already built buildOpenCLKernels_update_halo_kernel5_plus_2_left(xdim0, ydim0, xdim1, ydim1); // set up OpenCL thread blocks size_t globalWorkSize[3] = { ((x_size - 1) / OPS_block_size_x + 1) * OPS_block_size_x, ((y_size - 1) / OPS_block_size_y + 1) * OPS_block_size_y, ((z_size - 1) / OPS_block_size_z + 1) * OPS_block_size_z}; size_t localWorkSize[3] = {OPS_block_size_x, OPS_block_size_y, OPS_block_size_z}; int *arg2h = (int *)arg2.data; int consts_bytes = 0; consts_bytes += ROUND_UP(NUM_FIELDS * sizeof(int)); reallocConstArrays(consts_bytes); consts_bytes = 0; arg2.data = OPS_consts_h + consts_bytes; arg2.data_d = OPS_consts_d + consts_bytes; for (int d = 0; d < NUM_FIELDS; d++) ((int *)arg2.data)[d] = arg2h[d]; consts_bytes += ROUND_UP(NUM_FIELDS * sizeof(int)); mvConstArraysToDevice(consts_bytes); // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = 1 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + args[0].dat->size[0] * 1 * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + args[0].dat->size[0] * 1 * args[0].dat->size[1] * 1 * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif int base1 = 1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + args[1].dat->size[0] * 1 * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1 + args[1].dat->size[0] * 1 * args[1].dat->size[1] * 1 * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); ops_H_D_exchanges_device(args, 3); ops_halo_exchanges(args, 3, range); ops_H_D_exchanges_device(args, 3); if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[88].mpi_time += t2 - t1; } if (globalWorkSize[0] > 0 && globalWorkSize[1] > 0 && globalWorkSize[2] > 0) { clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 0, sizeof(cl_mem), (void *)&arg0.data_d)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 1, sizeof(cl_mem), (void *)&arg1.data_d)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 2, sizeof(cl_mem), (void *)&arg2.data_d)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 3, sizeof(cl_int), (void *)&base0)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 4, sizeof(cl_int), (void *)&base1)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 5, sizeof(cl_int), (void *)&x_size)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 6, sizeof(cl_int), (void *)&y_size)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[88], 7, sizeof(cl_int), (void *)&z_size)); // call/enque opencl kernel wrapper function clSafeCall(clEnqueueNDRangeKernel( OPS_opencl_core.command_queue, OPS_opencl_core.kernel[88], 3, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL)); } if (OPS_diags > 1) { clSafeCall(clFinish(OPS_opencl_core.command_queue)); } if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[88].time += t1 - t2; } ops_set_dirtybit_device(args, 3); ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[88].mpi_time += t2 - t1; OPS_kernels[88].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[88].transfer += ops_compute_transfer(dim, start, end, &arg1); } }
// host stub function void ops_par_loop_advec_cell_kernel4_ydir(char const *name, ops_block Block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7, ops_arg arg8, ops_arg arg9, ops_arg arg10) { ops_arg args[11] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10}; ops_timing_realloc(36,"advec_cell_kernel4_ydir"); OPS_kernels[36].count++; //compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int z_size = MAX(0,end[2]-start[2]); xdim0 = args[0].dat->size[0]*args[0].dat->dim; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]*args[1].dat->dim; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]*args[2].dat->dim; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]*args[3].dat->dim; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]*args[4].dat->dim; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]*args[5].dat->dim; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]*args[6].dat->dim; ydim6 = args[6].dat->size[1]; xdim7 = args[7].dat->size[0]*args[7].dat->dim; ydim7 = args[7].dat->size[1]; xdim8 = args[8].dat->size[0]*args[8].dat->dim; ydim8 = args[8].dat->size[1]; xdim9 = args[9].dat->size[0]*args[9].dat->dim; ydim9 = args[9].dat->size[1]; xdim10 = args[10].dat->size[0]*args[10].dat->dim; ydim10 = args[10].dat->size[1]; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); if (xdim0 != xdim0_advec_cell_kernel4_ydir_h || ydim0 != ydim0_advec_cell_kernel4_ydir_h || xdim1 != xdim1_advec_cell_kernel4_ydir_h || ydim1 != ydim1_advec_cell_kernel4_ydir_h || xdim2 != xdim2_advec_cell_kernel4_ydir_h || ydim2 != ydim2_advec_cell_kernel4_ydir_h || xdim3 != xdim3_advec_cell_kernel4_ydir_h || ydim3 != ydim3_advec_cell_kernel4_ydir_h || xdim4 != xdim4_advec_cell_kernel4_ydir_h || ydim4 != ydim4_advec_cell_kernel4_ydir_h || xdim5 != xdim5_advec_cell_kernel4_ydir_h || ydim5 != ydim5_advec_cell_kernel4_ydir_h || xdim6 != xdim6_advec_cell_kernel4_ydir_h || ydim6 != ydim6_advec_cell_kernel4_ydir_h || xdim7 != xdim7_advec_cell_kernel4_ydir_h || ydim7 != ydim7_advec_cell_kernel4_ydir_h || xdim8 != xdim8_advec_cell_kernel4_ydir_h || ydim8 != ydim8_advec_cell_kernel4_ydir_h || xdim9 != xdim9_advec_cell_kernel4_ydir_h || ydim9 != ydim9_advec_cell_kernel4_ydir_h || xdim10 != xdim10_advec_cell_kernel4_ydir_h || ydim10 != ydim10_advec_cell_kernel4_ydir_h) { xdim0_advec_cell_kernel4_ydir = xdim0; xdim0_advec_cell_kernel4_ydir_h = xdim0; ydim0_advec_cell_kernel4_ydir = ydim0; ydim0_advec_cell_kernel4_ydir_h = ydim0; xdim1_advec_cell_kernel4_ydir = xdim1; xdim1_advec_cell_kernel4_ydir_h = xdim1; ydim1_advec_cell_kernel4_ydir = ydim1; ydim1_advec_cell_kernel4_ydir_h = ydim1; xdim2_advec_cell_kernel4_ydir = xdim2; xdim2_advec_cell_kernel4_ydir_h = xdim2; ydim2_advec_cell_kernel4_ydir = ydim2; ydim2_advec_cell_kernel4_ydir_h = ydim2; xdim3_advec_cell_kernel4_ydir = xdim3; xdim3_advec_cell_kernel4_ydir_h = xdim3; ydim3_advec_cell_kernel4_ydir = ydim3; ydim3_advec_cell_kernel4_ydir_h = ydim3; xdim4_advec_cell_kernel4_ydir = xdim4; xdim4_advec_cell_kernel4_ydir_h = xdim4; ydim4_advec_cell_kernel4_ydir = ydim4; ydim4_advec_cell_kernel4_ydir_h = ydim4; xdim5_advec_cell_kernel4_ydir = xdim5; xdim5_advec_cell_kernel4_ydir_h = xdim5; ydim5_advec_cell_kernel4_ydir = ydim5; ydim5_advec_cell_kernel4_ydir_h = ydim5; xdim6_advec_cell_kernel4_ydir = xdim6; xdim6_advec_cell_kernel4_ydir_h = xdim6; ydim6_advec_cell_kernel4_ydir = ydim6; ydim6_advec_cell_kernel4_ydir_h = ydim6; xdim7_advec_cell_kernel4_ydir = xdim7; xdim7_advec_cell_kernel4_ydir_h = xdim7; ydim7_advec_cell_kernel4_ydir = ydim7; ydim7_advec_cell_kernel4_ydir_h = ydim7; xdim8_advec_cell_kernel4_ydir = xdim8; xdim8_advec_cell_kernel4_ydir_h = xdim8; ydim8_advec_cell_kernel4_ydir = ydim8; ydim8_advec_cell_kernel4_ydir_h = ydim8; xdim9_advec_cell_kernel4_ydir = xdim9; xdim9_advec_cell_kernel4_ydir_h = xdim9; ydim9_advec_cell_kernel4_ydir = ydim9; ydim9_advec_cell_kernel4_ydir_h = ydim9; xdim10_advec_cell_kernel4_ydir = xdim10; xdim10_advec_cell_kernel4_ydir_h = xdim10; ydim10_advec_cell_kernel4_ydir = ydim10; ydim10_advec_cell_kernel4_ydir_h = ydim10; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; int dat5 = args[5].dat->elem_size; int dat6 = args[6].dat->elem_size; int dat7 = args[7].dat->elem_size; int dat8 = args[8].dat->elem_size; int dat9 = args[9].dat->elem_size; int dat10 = args[10].dat->elem_size; //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0+ dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1+ dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif //OPS_MPI int base2 = dat2 * 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2+ dat2 * args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2+ dat2 * args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a2 = (double *)((char *)args[2].data_d + base2); #else double *p_a2 = (double *)((char *)args[2].data + base2); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = dat3 * 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3+ dat3 * args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3+ dat3 * args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a3 = (double *)((char *)args[3].data_d + base3); #else double *p_a3 = (double *)((char *)args[3].data + base3); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4+ dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4+ dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a4 = (double *)((char *)args[4].data_d + base4); #else double *p_a4 = (double *)((char *)args[4].data + base4); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif //OPS_MPI int base5 = dat5 * 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5+ dat5 * args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5+ dat5 * args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a5 = (double *)((char *)args[5].data_d + base5); #else double *p_a5 = (double *)((char *)args[5].data + base5); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif //OPS_MPI int base6 = dat6 * 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6+ dat6 * args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6+ dat6 * args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a6 = (double *)((char *)args[6].data_d + base6); #else double *p_a6 = (double *)((char *)args[6].data + base6); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d] + OPS_sub_dat_list[args[7].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d]; #endif //OPS_MPI int base7 = dat7 * 1 * (start[0] * args[7].stencil->stride[0] - args[7].dat->base[0] - d_m[0]); base7 = base7+ dat7 * args[7].dat->size[0] * (start[1] * args[7].stencil->stride[1] - args[7].dat->base[1] - d_m[1]); base7 = base7+ dat7 * args[7].dat->size[0] * args[7].dat->size[1] * (start[2] * args[7].stencil->stride[2] - args[7].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a7 = (double *)((char *)args[7].data_d + base7); #else double *p_a7 = (double *)((char *)args[7].data + base7); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[8].dat->d_m[d] + OPS_sub_dat_list[args[8].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[8].dat->d_m[d]; #endif //OPS_MPI int base8 = dat8 * 1 * (start[0] * args[8].stencil->stride[0] - args[8].dat->base[0] - d_m[0]); base8 = base8+ dat8 * args[8].dat->size[0] * (start[1] * args[8].stencil->stride[1] - args[8].dat->base[1] - d_m[1]); base8 = base8+ dat8 * args[8].dat->size[0] * args[8].dat->size[1] * (start[2] * args[8].stencil->stride[2] - args[8].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a8 = (double *)((char *)args[8].data_d + base8); #else double *p_a8 = (double *)((char *)args[8].data + base8); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[9].dat->d_m[d] + OPS_sub_dat_list[args[9].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[9].dat->d_m[d]; #endif //OPS_MPI int base9 = dat9 * 1 * (start[0] * args[9].stencil->stride[0] - args[9].dat->base[0] - d_m[0]); base9 = base9+ dat9 * args[9].dat->size[0] * (start[1] * args[9].stencil->stride[1] - args[9].dat->base[1] - d_m[1]); base9 = base9+ dat9 * args[9].dat->size[0] * args[9].dat->size[1] * (start[2] * args[9].stencil->stride[2] - args[9].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a9 = (double *)((char *)args[9].data_d + base9); #else double *p_a9 = (double *)((char *)args[9].data + base9); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[10].dat->d_m[d] + OPS_sub_dat_list[args[10].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[10].dat->d_m[d]; #endif //OPS_MPI int base10 = dat10 * 1 * (start[0] * args[10].stencil->stride[0] - args[10].dat->base[0] - d_m[0]); base10 = base10+ dat10 * args[10].dat->size[0] * (start[1] * args[10].stencil->stride[1] - args[10].dat->base[1] - d_m[1]); base10 = base10+ dat10 * args[10].dat->size[0] * args[10].dat->size[1] * (start[2] * args[10].stencil->stride[2] - args[10].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a10 = (double *)((char *)args[10].data_d + base10); #else double *p_a10 = (double *)((char *)args[10].data + base10); #endif #ifdef OPS_GPU ops_H_D_exchanges_device(args, 11); #else ops_H_D_exchanges_host(args, 11); #endif ops_halo_exchanges(args,11,range); ops_timers_core(&c1,&t1); OPS_kernels[36].mpi_time += t1-t2; advec_cell_kernel4_ydir_c_wrapper( p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, p_a6, p_a7, p_a8, p_a9, p_a10, x_size, y_size, z_size); ops_timers_core(&c2,&t2); OPS_kernels[36].time += t2-t1; #ifdef OPS_GPU ops_set_dirtybit_device(args, 11); #else ops_set_dirtybit_host(args, 11); #endif ops_set_halo_dirtybit3(&args[0],range); ops_set_halo_dirtybit3(&args[1],range); ops_set_halo_dirtybit3(&args[6],range); ops_set_halo_dirtybit3(&args[7],range); ops_set_halo_dirtybit3(&args[8],range); ops_set_halo_dirtybit3(&args[9],range); //Update kernel record OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg2); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg3); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg4); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg5); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg6); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg7); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg8); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg9); OPS_kernels[36].transfer += ops_compute_transfer(dim, range, &arg10); }
// host stub function void ops_par_loop_revert_kernel(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3) { ops_arg args[4] = { arg0, arg1, arg2, arg3}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args,4,range,0)) return; #endif ops_timing_realloc(0,"revert_kernel"); OPS_kernels[0].count++; //compute locally allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<2; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<2; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int xdim0 = args[0].dat->size[0]*args[0].dat->dim; int xdim1 = args[1].dat->size[0]*args[1].dat->dim; int xdim2 = args[2].dat->size[0]*args[2].dat->dim; int xdim3 = args[3].dat->size[0]*args[3].dat->dim; //build opencl kernel if not already built buildOpenCLKernels_revert_kernel( xdim0,xdim1,xdim2,xdim3); //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); //set up OpenCL thread blocks size_t globalWorkSize[3] = {((x_size-1)/OPS_block_size_x+ 1)*OPS_block_size_x, ((y_size-1)/OPS_block_size_y + 1)*OPS_block_size_y, 1}; size_t localWorkSize[3] = {OPS_block_size_x,OPS_block_size_y,1}; int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif //OPS_MPI int base2 = 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); ops_H_D_exchanges_device(args, 4); ops_halo_exchanges(args,4,range); ops_H_D_exchanges_device(args, 4); ops_timers_core(&c1,&t1); OPS_kernels[0].mpi_time += t1-t2; clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 0, sizeof(cl_mem), (void*) &arg0.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 1, sizeof(cl_mem), (void*) &arg1.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 2, sizeof(cl_mem), (void*) &arg2.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 3, sizeof(cl_mem), (void*) &arg3.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 4, sizeof(cl_int), (void*) &base0 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 5, sizeof(cl_int), (void*) &base1 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 6, sizeof(cl_int), (void*) &base2 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 7, sizeof(cl_int), (void*) &base3 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 8, sizeof(cl_int), (void*) &x_size )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[0], 9, sizeof(cl_int), (void*) &y_size )); //call/enque opencl kernel wrapper function clSafeCall( clEnqueueNDRangeKernel(OPS_opencl_core.command_queue, OPS_opencl_core.kernel[0], 3, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL) ); if (OPS_diags>1) { clSafeCall( clFinish(OPS_opencl_core.command_queue) ); } ops_set_dirtybit_device(args, 4); ops_set_halo_dirtybit3(&args[1],range); ops_set_halo_dirtybit3(&args[3],range); //Update kernel record ops_timers_core(&c2,&t2); OPS_kernels[0].time += t2-t1; OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg2); OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg3); }
// host stub function void ops_par_loop_set_val(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1) { ops_arg args[2] = {arg0, arg1}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 2, range, 6)) return; #endif ops_timing_realloc(6, "set_val"); OPS_kernels[6].count++; // compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for (int n = 0; n < 3; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); } #else for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; // Timing double t1, t2, c1, c2; ops_timers_core(&c2, &t2); if (xdim0 != xdim0_set_val_h || ydim0 != ydim0_set_val_h) { xdim0_set_val = xdim0; xdim0_set_val_h = xdim0; ydim0_set_val = ydim0; ydim0_set_val_h = ydim0; } int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); double *p_a0 = (double *)((char *)args[0].data + base0); double *p_a1 = (double *)args[1].data; ops_H_D_exchanges_host(args, 2); ops_halo_exchanges(args, 2, range); ops_timers_core(&c1, &t1); OPS_kernels[6].mpi_time += t1 - t2; set_val_c_wrapper(p_a0, p_a1, x_size, y_size, z_size); ops_timers_core(&c2, &t2); OPS_kernels[6].time += t2 - t1; ops_set_dirtybit_host(args, 2); ops_set_halo_dirtybit3(&args[0], range); // Update kernel record OPS_kernels[6].transfer += ops_compute_transfer(dim, start, end, &arg0); }
// host stub function void ops_par_loop_update_halo_kernel1_fr2(char const *name, ops_block Block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7) { ops_arg args[8] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; ops_timing_realloc(51,"update_halo_kernel1_fr2"); OPS_kernels[51].count++; //compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int z_size = MAX(0,end[2]-start[2]); xdim0 = args[0].dat->size[0]*args[0].dat->dim; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]*args[1].dat->dim; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]*args[2].dat->dim; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]*args[3].dat->dim; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]*args[4].dat->dim; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]*args[5].dat->dim; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]*args[6].dat->dim; ydim6 = args[6].dat->size[1]; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); if (xdim0 != xdim0_update_halo_kernel1_fr2_h || ydim0 != ydim0_update_halo_kernel1_fr2_h || xdim1 != xdim1_update_halo_kernel1_fr2_h || ydim1 != ydim1_update_halo_kernel1_fr2_h || xdim2 != xdim2_update_halo_kernel1_fr2_h || ydim2 != ydim2_update_halo_kernel1_fr2_h || xdim3 != xdim3_update_halo_kernel1_fr2_h || ydim3 != ydim3_update_halo_kernel1_fr2_h || xdim4 != xdim4_update_halo_kernel1_fr2_h || ydim4 != ydim4_update_halo_kernel1_fr2_h || xdim5 != xdim5_update_halo_kernel1_fr2_h || ydim5 != ydim5_update_halo_kernel1_fr2_h || xdim6 != xdim6_update_halo_kernel1_fr2_h || ydim6 != ydim6_update_halo_kernel1_fr2_h) { xdim0_update_halo_kernel1_fr2 = xdim0; xdim0_update_halo_kernel1_fr2_h = xdim0; ydim0_update_halo_kernel1_fr2 = ydim0; ydim0_update_halo_kernel1_fr2_h = ydim0; xdim1_update_halo_kernel1_fr2 = xdim1; xdim1_update_halo_kernel1_fr2_h = xdim1; ydim1_update_halo_kernel1_fr2 = ydim1; ydim1_update_halo_kernel1_fr2_h = ydim1; xdim2_update_halo_kernel1_fr2 = xdim2; xdim2_update_halo_kernel1_fr2_h = xdim2; ydim2_update_halo_kernel1_fr2 = ydim2; ydim2_update_halo_kernel1_fr2_h = ydim2; xdim3_update_halo_kernel1_fr2 = xdim3; xdim3_update_halo_kernel1_fr2_h = xdim3; ydim3_update_halo_kernel1_fr2 = ydim3; ydim3_update_halo_kernel1_fr2_h = ydim3; xdim4_update_halo_kernel1_fr2 = xdim4; xdim4_update_halo_kernel1_fr2_h = xdim4; ydim4_update_halo_kernel1_fr2 = ydim4; ydim4_update_halo_kernel1_fr2_h = ydim4; xdim5_update_halo_kernel1_fr2 = xdim5; xdim5_update_halo_kernel1_fr2_h = xdim5; ydim5_update_halo_kernel1_fr2 = ydim5; ydim5_update_halo_kernel1_fr2_h = ydim5; xdim6_update_halo_kernel1_fr2 = xdim6; xdim6_update_halo_kernel1_fr2_h = xdim6; ydim6_update_halo_kernel1_fr2 = ydim6; ydim6_update_halo_kernel1_fr2_h = ydim6; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; int dat5 = args[5].dat->elem_size; int dat6 = args[6].dat->elem_size; int *arg7h = (int *)arg7.data; //Upload large globals int consts_bytes = 0; consts_bytes += ROUND_UP(NUM_FIELDS*sizeof(int)); reallocConstArrays(consts_bytes); consts_bytes = 0; args[7].data = OPS_consts_h + consts_bytes; args[7].data_d = OPS_consts_d + consts_bytes; for (int d=0; d<NUM_FIELDS; d++) ((int *)args[7].data)[d] = arg7h[d]; consts_bytes += ROUND_UP(NUM_FIELDS*sizeof(int)); mvConstArraysToDevice(consts_bytes); //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0+ dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1+ dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif //OPS_MPI int base2 = dat2 * 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2+ dat2 * args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2+ dat2 * args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a2 = (double *)((char *)args[2].data_d + base2); #else double *p_a2 = (double *)((char *)args[2].data + base2); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = dat3 * 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3+ dat3 * args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3+ dat3 * args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a3 = (double *)((char *)args[3].data_d + base3); #else double *p_a3 = (double *)((char *)args[3].data + base3); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4+ dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4+ dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a4 = (double *)((char *)args[4].data_d + base4); #else double *p_a4 = (double *)((char *)args[4].data + base4); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif //OPS_MPI int base5 = dat5 * 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5+ dat5 * args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5+ dat5 * args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a5 = (double *)((char *)args[5].data_d + base5); #else double *p_a5 = (double *)((char *)args[5].data + base5); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif //OPS_MPI int base6 = dat6 * 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6+ dat6 * args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6+ dat6 * args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a6 = (double *)((char *)args[6].data_d + base6); #else double *p_a6 = (double *)((char *)args[6].data + base6); #endif #ifdef OPS_GPU int *p_a7 = (int *)args[7].data_d; #else int *p_a7 = arg7h; #endif #ifdef OPS_GPU ops_H_D_exchanges_device(args, 8); #else ops_H_D_exchanges_host(args, 8); #endif ops_halo_exchanges(args,8,range); ops_timers_core(&c1,&t1); OPS_kernels[51].mpi_time += t1-t2; update_halo_kernel1_fr2_c_wrapper( p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, p_a6, p_a7, x_size, y_size, z_size); ops_timers_core(&c2,&t2); OPS_kernels[51].time += t2-t1; #ifdef OPS_GPU ops_set_dirtybit_device(args, 8); #else ops_set_dirtybit_host(args, 8); #endif ops_set_halo_dirtybit3(&args[0],range); ops_set_halo_dirtybit3(&args[1],range); ops_set_halo_dirtybit3(&args[2],range); ops_set_halo_dirtybit3(&args[3],range); ops_set_halo_dirtybit3(&args[4],range); ops_set_halo_dirtybit3(&args[5],range); ops_set_halo_dirtybit3(&args[6],range); //Update kernel record OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg2); OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg3); OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg4); OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg5); OPS_kernels[51].transfer += ops_compute_transfer(dim, range, &arg6); }
// host stub function void ops_par_loop_update_halo_kernel2_xvel_minus_2_a(char const *name, ops_block Block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2) { ops_arg args[3] = { arg0, arg1, arg2}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args,3,range,56)) return; #endif ops_timing_realloc(56,"update_halo_kernel2_xvel_minus_2_a"); OPS_kernels[56].count++; //compute localy allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<2; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<2; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); xdim0 = args[0].dat->size[0]*args[0].dat->dim; xdim1 = args[1].dat->size[0]*args[1].dat->dim; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); if (xdim0 != xdim0_update_halo_kernel2_xvel_minus_2_a_h || xdim1 != xdim1_update_halo_kernel2_xvel_minus_2_a_h) { xdim0_update_halo_kernel2_xvel_minus_2_a = xdim0; xdim0_update_halo_kernel2_xvel_minus_2_a_h = xdim0; xdim1_update_halo_kernel2_xvel_minus_2_a = xdim1; xdim1_update_halo_kernel2_xvel_minus_2_a_h = xdim1; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int *arg2h = (int *)arg2.data; //Upload large globals int consts_bytes = 0; consts_bytes += ROUND_UP(NUM_FIELDS*sizeof(int)); reallocConstArrays(consts_bytes); consts_bytes = 0; args[2].data = OPS_consts_h + consts_bytes; args[2].data_d = OPS_consts_d + consts_bytes; for (int d=0; d<NUM_FIELDS; d++) ((int *)args[2].data)[d] = arg2h[d]; consts_bytes += ROUND_UP(NUM_FIELDS*sizeof(int)); mvConstArraysToDevice(consts_bytes); //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif #ifdef OPS_GPU int *p_a2 = (int *)args[2].data_d; #else int *p_a2 = arg2h; #endif #ifdef OPS_GPU ops_H_D_exchanges_device(args, 3); #else ops_H_D_exchanges_host(args, 3); #endif ops_halo_exchanges(args,3,range); ops_timers_core(&c1,&t1); OPS_kernels[56].mpi_time += t1-t2; update_halo_kernel2_xvel_minus_2_a_c_wrapper( p_a0, p_a1, p_a2, x_size, y_size); ops_timers_core(&c2,&t2); OPS_kernels[56].time += t2-t1; #ifdef OPS_GPU ops_set_dirtybit_device(args, 3); #else ops_set_dirtybit_host(args, 3); #endif ops_set_halo_dirtybit3(&args[0],range); ops_set_halo_dirtybit3(&args[1],range); //Update kernel record OPS_kernels[56].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[56].transfer += ops_compute_transfer(dim, range, &arg1); }
// host stub function void ops_par_loop_left_bndcon(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1) { //Timing double t1,t2,c1,c2; char *p_a[2]; int offs[2][2]; ops_arg args[2] = { arg0, arg1}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args,2,range,2)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(2,"left_bndcon"); OPS_kernels[2].count++; ops_timers_core(&c2,&t2); } //compute locally allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<2; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else for ( int n=0; n<2; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif #ifdef OPS_DEBUG ops_register_args(args, "left_bndcon"); #endif offs[0][0] = args[0].stencil->stride[0]*1; //unit step in x dimension offs[0][1] = off2D(1, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][0]; int arg_idx[2]; #ifdef OPS_MPI arg_idx[0] = sb->decomp_disp[0]+start[0]; arg_idx[1] = sb->decomp_disp[1]+start[1]; #else arg_idx[0] = start[0]; arg_idx[1] = start[1]; #endif int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); //set up initial pointers and exchange halos if necessary int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0+ (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; p_a[0] = (char *)args[0].data + base0; p_a[1] = (char *)arg_idx; //initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; //Halo Exchanges ops_H_D_exchanges_host(args, 2); ops_halo_exchanges(args,2,range); ops_H_D_exchanges_host(args, 2); if (OPS_diags > 1) { ops_timers_core(&c1,&t1); OPS_kernels[2].mpi_time += t1-t2; } int n_x; for ( int n_y=start[1]; n_y<end[1]; n_y++ ){ #pragma novector for( n_x=start[0]; n_x<start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x+=SIMD_VEC ) { //call kernel function, passing in pointers to data -vectorised for ( int i=0; i<SIMD_VEC; i++ ){ left_bndcon( (double *)p_a[0]+ i*1*1, (int *)p_a[1] ); arg_idx[0]++; } //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0)*SIMD_VEC; } for ( int n_x=start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x<end[0]; n_x++ ){ //call kernel function, passing in pointers to data - remainder left_bndcon( (double *)p_a[0], (int *)p_a[1] ); //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0); arg_idx[0]++; } //shift pointers to data y direction p_a[0]= p_a[0] + (dat0 * off0_1); #ifdef OPS_MPI arg_idx[0] = sb->decomp_disp[0]+start[0]; #else arg_idx[0] = start[0]; #endif arg_idx[1]++; } if (OPS_diags > 1) { ops_timers_core(&c2,&t2); OPS_kernels[2].time += t2-t1; } ops_set_dirtybit_host(args, 2); ops_set_halo_dirtybit3(&args[0],range); if (OPS_diags > 1) { //Update kernel record ops_timers_core(&c1,&t1); OPS_kernels[2].mpi_time += t1-t2; OPS_kernels[2].transfer += ops_compute_transfer(dim, start, end, &arg0); } }
// host stub function void ops_par_loop_advec_mom_kernel_mass_flux_y(char const *name, ops_block Block, int dim, int* range, ops_arg arg0, ops_arg arg1) { ops_arg args[2] = { arg0, arg1}; ops_timing_realloc(21,"advec_mom_kernel_mass_flux_y"); OPS_kernels[21].count++; //compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int z_size = MAX(0,end[2]-start[2]); xdim0 = args[0].dat->size[0]*args[0].dat->dim; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]*args[1].dat->dim; ydim1 = args[1].dat->size[1]; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); if (xdim0 != xdim0_advec_mom_kernel_mass_flux_y_h || ydim0 != ydim0_advec_mom_kernel_mass_flux_y_h || xdim1 != xdim1_advec_mom_kernel_mass_flux_y_h || ydim1 != ydim1_advec_mom_kernel_mass_flux_y_h) { xdim0_advec_mom_kernel_mass_flux_y = xdim0; xdim0_advec_mom_kernel_mass_flux_y_h = xdim0; ydim0_advec_mom_kernel_mass_flux_y = ydim0; ydim0_advec_mom_kernel_mass_flux_y_h = ydim0; xdim1_advec_mom_kernel_mass_flux_y = xdim1; xdim1_advec_mom_kernel_mass_flux_y_h = xdim1; ydim1_advec_mom_kernel_mass_flux_y = ydim1; ydim1_advec_mom_kernel_mass_flux_y_h = ydim1; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0+ dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1+ dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif #ifdef OPS_GPU ops_H_D_exchanges_device(args, 2); #else ops_H_D_exchanges_host(args, 2); #endif ops_halo_exchanges(args,2,range); ops_timers_core(&c1,&t1); OPS_kernels[21].mpi_time += t1-t2; advec_mom_kernel_mass_flux_y_c_wrapper( p_a0, p_a1, x_size, y_size, z_size); ops_timers_core(&c2,&t2); OPS_kernels[21].time += t2-t1; #ifdef OPS_GPU ops_set_dirtybit_device(args, 2); #else ops_set_dirtybit_host(args, 2); #endif ops_set_halo_dirtybit3(&args[0],range); //Update kernel record OPS_kernels[21].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[21].transfer += ops_compute_transfer(dim, range, &arg1); }
// host stub function void ops_par_loop_calc_dt_kernel_get(char const *name, ops_block Block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5) { ops_arg args[6] = { arg0, arg1, arg2, arg3, arg4, arg5}; ops_timing_realloc(128,"calc_dt_kernel_get"); OPS_kernels[128].count++; //compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int z_size = MAX(0,end[2]-start[2]); xdim0 = args[0].dat->size[0]*args[0].dat->dim; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]*args[1].dat->dim; ydim1 = args[1].dat->size[1]; xdim4 = args[4].dat->size[0]*args[4].dat->dim; ydim4 = args[4].dat->size[1]; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); if (xdim0 != xdim0_calc_dt_kernel_get_h || ydim0 != ydim0_calc_dt_kernel_get_h || xdim1 != xdim1_calc_dt_kernel_get_h || ydim1 != ydim1_calc_dt_kernel_get_h || xdim4 != xdim4_calc_dt_kernel_get_h || ydim4 != ydim4_calc_dt_kernel_get_h) { xdim0_calc_dt_kernel_get = xdim0; xdim0_calc_dt_kernel_get_h = xdim0; ydim0_calc_dt_kernel_get = ydim0; ydim0_calc_dt_kernel_get_h = ydim0; xdim1_calc_dt_kernel_get = xdim1; xdim1_calc_dt_kernel_get_h = xdim1; ydim1_calc_dt_kernel_get = ydim1; ydim1_calc_dt_kernel_get_h = ydim1; xdim4_calc_dt_kernel_get = xdim4; xdim4_calc_dt_kernel_get_h = xdim4; ydim4_calc_dt_kernel_get = ydim4; ydim4_calc_dt_kernel_get_h = ydim4; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat4 = args[4].dat->elem_size; #ifdef OPS_MPI double *arg2h = (double *)(((ops_reduction)args[2].data)->data + ((ops_reduction)args[2].data)->size * block->index); #else //OPS_MPI double *arg2h = (double *)(((ops_reduction)args[2].data)->data); #endif //OPS_MPI #ifdef OPS_MPI double *arg3h = (double *)(((ops_reduction)args[3].data)->data + ((ops_reduction)args[3].data)->size * block->index); #else //OPS_MPI double *arg3h = (double *)(((ops_reduction)args[3].data)->data); #endif //OPS_MPI #ifdef OPS_MPI double *arg5h = (double *)(((ops_reduction)args[5].data)->data + ((ops_reduction)args[5].data)->size * block->index); #else //OPS_MPI double *arg5h = (double *)(((ops_reduction)args[5].data)->data); #endif //OPS_MPI //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0+ dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1+ dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif double *p_a2 = arg2h; double *p_a3 = arg3h; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4+ dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4+ dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); #ifdef OPS_GPU double *p_a4 = (double *)((char *)args[4].data_d + base4); #else double *p_a4 = (double *)((char *)args[4].data + base4); #endif double *p_a5 = arg5h; #ifdef OPS_GPU ops_H_D_exchanges_device(args, 6); #else ops_H_D_exchanges_host(args, 6); #endif ops_halo_exchanges(args,6,range); ops_timers_core(&c1,&t1); OPS_kernels[128].mpi_time += t1-t2; calc_dt_kernel_get_c_wrapper( p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, x_size, y_size, z_size); ops_timers_core(&c2,&t2); OPS_kernels[128].time += t2-t1; #ifdef OPS_GPU ops_set_dirtybit_device(args, 6); #else ops_set_dirtybit_host(args, 6); #endif //Update kernel record OPS_kernels[128].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[128].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[128].transfer += ops_compute_transfer(dim, range, &arg4); }
// host stub function void ops_par_loop_update_halo_kernel2_zvel_plus_4_right( char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2) { // Timing double t1, t2, c1, c2; ops_arg args[3] = {arg0, arg1, arg2}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 3, range, 53)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(53, "update_halo_kernel2_zvel_plus_4_right"); OPS_kernels[53].count++; ops_timers_core(&c1, &t1); } // compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // OPS_MPI int arg_idx[3]; int arg_idx_base[3]; #ifdef OPS_MPI if (compute_ranges(args, 3, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif for (int n = 0; n < 3; n++) { arg_idx_base[n] = arg_idx[n]; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int *arg2h = (int *)arg2.data; // Upload large globals #ifdef OPS_GPU int consts_bytes = 0; consts_bytes += ROUND_UP(NUM_FIELDS * sizeof(int)); reallocConstArrays(consts_bytes); consts_bytes = 0; args[2].data = OPS_consts_h + consts_bytes; args[2].data_d = OPS_consts_d + consts_bytes; for (int d = 0; d < NUM_FIELDS; d++) ((int *)args[2].data)[d] = arg2h[d]; consts_bytes += ROUND_UP(NUM_FIELDS * sizeof(int)); mvConstArraysToDevice(consts_bytes); #endif // OPS_GPU // set up initial pointers int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * args[0].dat->size[1] * start[2] * args[0].stencil->stride[2]; #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * start[1] * args[1].stencil->stride[1]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * args[1].dat->size[1] * start[2] * args[1].stencil->stride[2]; #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif #ifdef OPS_GPU int *p_a2 = (int *)args[2].data_d; #else int *p_a2 = arg2h; #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; if (xdim0 != xdim0_update_halo_kernel2_zvel_plus_4_right_h || ydim0 != ydim0_update_halo_kernel2_zvel_plus_4_right_h || xdim1 != xdim1_update_halo_kernel2_zvel_plus_4_right_h || ydim1 != ydim1_update_halo_kernel2_zvel_plus_4_right_h) { xdim0_update_halo_kernel2_zvel_plus_4_right = xdim0; xdim0_update_halo_kernel2_zvel_plus_4_right_h = xdim0; ydim0_update_halo_kernel2_zvel_plus_4_right = ydim0; ydim0_update_halo_kernel2_zvel_plus_4_right_h = ydim0; xdim1_update_halo_kernel2_zvel_plus_4_right = xdim1; xdim1_update_halo_kernel2_zvel_plus_4_right_h = xdim1; ydim1_update_halo_kernel2_zvel_plus_4_right = ydim1; ydim1_update_halo_kernel2_zvel_plus_4_right_h = ydim1; } // Halo Exchanges #ifdef OPS_GPU ops_H_D_exchanges_device(args, 3); #else ops_H_D_exchanges_host(args, 3); #endif ops_halo_exchanges(args, 3, range); #ifdef OPS_GPU ops_H_D_exchanges_device(args, 3); #else ops_H_D_exchanges_host(args, 3); #endif if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[53].mpi_time += t2 - t1; } update_halo_kernel2_zvel_plus_4_right_c_wrapper(p_a0, p_a1, p_a2, x_size, y_size, z_size); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[53].time += t1 - t2; } #ifdef OPS_GPU ops_set_dirtybit_device(args, 3); #else ops_set_dirtybit_host(args, 3); #endif ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[53].mpi_time += t2 - t1; OPS_kernels[53].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[53].transfer += ops_compute_transfer(dim, start, end, &arg1); } }
// host stub function void ops_par_loop_poisson_kernel_initialguess(char const *name, ops_block block, int dim, int *range, ops_arg arg0) { // Timing double t1, t2, c1, c2; ops_arg args[1] = {arg0}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 1, range, 2)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(2, "poisson_kernel_initialguess"); OPS_kernels[2].count++; ops_timers_core(&c1, &t1); } // compute localy allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // OPS_MPI int arg_idx[2]; int arg_idx_base[2]; #ifdef OPS_MPI if (compute_ranges(args, 1, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 2; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif for (int n = 0; n < 2; n++) { arg_idx_base[n] = arg_idx[n]; } int dat0 = args[0].dat->elem_size; // set up initial pointers int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; if (xdim0 != xdim0_poisson_kernel_initialguess_h) { xdim0_poisson_kernel_initialguess = xdim0; xdim0_poisson_kernel_initialguess_h = xdim0; } // Halo Exchanges #ifdef OPS_GPU ops_H_D_exchanges_device(args, 1); #else ops_H_D_exchanges_host(args, 1); #endif ops_halo_exchanges(args, 1, range); #ifdef OPS_GPU ops_H_D_exchanges_device(args, 1); #else ops_H_D_exchanges_host(args, 1); #endif if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[2].mpi_time += t2 - t1; } poisson_kernel_initialguess_c_wrapper(p_a0, x_size, y_size); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[2].time += t1 - t2; } #ifdef OPS_GPU ops_set_dirtybit_device(args, 1); #else ops_set_dirtybit_host(args, 1); #endif ops_set_halo_dirtybit3(&args[0], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[2].mpi_time += t2 - t1; OPS_kernels[2].transfer += ops_compute_transfer(dim, start, end, &arg0); } }
// host stub function void ops_par_loop_poisson_kernel_populate(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5) { //Timing double t1,t2,c1,c2; ops_timers_core(&c1,&t1); int offs[6][2]; ops_arg args[6] = { arg0, arg1, arg2, arg3, arg4, arg5}; ops_timing_realloc(0,"poisson_kernel_populate"); OPS_kernels[0].count++; //compute locally allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<2; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<2; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI #ifdef OPS_DEBUG ops_register_args(args, "poisson_kernel_populate"); #endif offs[3][0] = args[3].stencil->stride[0]*1; //unit step in x dimension offs[3][1] = off2D(1, &start[0], &end[0],args[3].dat->size, args[3].stencil->stride) - offs[3][0]; offs[4][0] = args[4].stencil->stride[0]*1; //unit step in x dimension offs[4][1] = off2D(1, &start[0], &end[0],args[4].dat->size, args[4].stencil->stride) - offs[4][0]; offs[5][0] = args[5].stencil->stride[0]*1; //unit step in x dimension offs[5][1] = off2D(1, &start[0], &end[0],args[5].dat->size, args[5].stencil->stride) - offs[5][0]; int off3_0 = offs[3][0]; int off3_1 = offs[3][1]; int dat3 = args[3].dat->elem_size; int off4_0 = offs[4][0]; int off4_1 = offs[4][1]; int dat4 = args[4].dat->elem_size; int off5_0 = offs[5][0]; int off5_1 = offs[5][1]; int dat5 = args[5].dat->elem_size; #ifdef _OPENMP int nthreads = omp_get_max_threads( ); #else int nthreads = 1; #endif xdim3 = args[3].dat->size[0]*args[3].dat->dim; xdim4 = args[4].dat->size[0]*args[4].dat->dim; xdim5 = args[5].dat->size[0]*args[5].dat->dim; ops_H_D_exchanges_host(args, 6); //Halo Exchanges ops_halo_exchanges(args,6,range); ops_timers_core(&c2,&t2); OPS_kernels[0].mpi_time += t2-t1; #pragma omp parallel for for ( int thr=0; thr<nthreads; thr++ ){ int y_size = end[1]-start[1]; char *p_a[6]; int start_i = start[1] + ((y_size-1)/nthreads+1)*thr; int finish_i = start[1] + MIN(((y_size-1)/nthreads+1)*(thr+1),y_size); //get address per thread int start0 = start[0]; int start1 = start_i; int arg_idx[2]; #ifdef OPS_MPI arg_idx[0] = sb->decomp_disp[0]+start0; arg_idx[1] = sb->decomp_disp[1]+start1; #else //OPS_MPI arg_idx[0] = start0; arg_idx[1] = start1; #endif //OPS_MPI //set up initial pointers int d_m[OPS_MAX_DIM]; p_a[0] = (char *)args[0].data; p_a[1] = (char *)args[1].data; p_a[2] = (char *)arg_idx; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = dat3 * 1 * (start0 * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3+ dat3 * args[3].dat->size[0] * (start1 * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); p_a[3] = (char *)args[3].data + base3; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = dat4 * 1 * (start0 * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4+ dat4 * args[4].dat->size[0] * (start1 * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); p_a[4] = (char *)args[4].data + base4; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif //OPS_MPI int base5 = dat5 * 1 * (start0 * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5+ dat5 * args[5].dat->size[0] * (start1 * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); p_a[5] = (char *)args[5].data + base5; for ( int n_y=start_i; n_y<finish_i; n_y++ ){ for ( int n_x=start[0]; n_x<start[0]+(end[0]-start[0])/SIMD_VEC; n_x++ ){ //call kernel function, passing in pointers to data -vectorised for ( int i=0; i<SIMD_VEC; i++ ){ poisson_kernel_populate( (int * )p_a[0], (int * )p_a[1], arg_idx, (double * )p_a[3]+ i*1, (double * )p_a[4]+ i*1, (double * )p_a[5]+ i*1 ); arg_idx[0]++; } //shift pointers to data x direction p_a[3]= p_a[3] + (dat3 * off3_0)*SIMD_VEC; p_a[4]= p_a[4] + (dat4 * off4_0)*SIMD_VEC; p_a[5]= p_a[5] + (dat5 * off5_0)*SIMD_VEC; } for ( int n_x=start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x<end[0]; n_x++ ){ //call kernel function, passing in pointers to data - remainder poisson_kernel_populate( (int * )p_a[0], (int * )p_a[1], arg_idx, (double * )p_a[3], (double * )p_a[4], (double * )p_a[5] ); //shift pointers to data x direction p_a[3]= p_a[3] + (dat3 * off3_0); p_a[4]= p_a[4] + (dat4 * off4_0); p_a[5]= p_a[5] + (dat5 * off5_0); arg_idx[0]++; } //shift pointers to data y direction p_a[3]= p_a[3] + (dat3 * off3_1); p_a[4]= p_a[4] + (dat4 * off4_1); p_a[5]= p_a[5] + (dat5 * off5_1); #ifdef OPS_MPI arg_idx[0] = sb->decomp_disp[0]+start0; #else //OPS_MPI arg_idx[0] = start0; #endif //OPS_MPI arg_idx[1]++; } } ops_timers_core(&c1,&t1); OPS_kernels[0].time += t1-t2; ops_set_dirtybit_host(args, 6); ops_set_halo_dirtybit3(&args[3],range); ops_set_halo_dirtybit3(&args[4],range); ops_set_halo_dirtybit3(&args[5],range); //Update kernel record ops_timers_core(&c2,&t2); OPS_kernels[0].mpi_time += t2-t1; OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg3); OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg4); OPS_kernels[0].transfer += ops_compute_transfer(dim, range, &arg5); }
// host stub function void ops_par_loop_update_halo_kernel1_ba1(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7) { ops_arg args[8] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 8, range, 21)) return; #endif ops_timing_realloc(21, "update_halo_kernel1_ba1"); OPS_kernels[21].count++; // compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for (int n = 0; n < 3; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); } #else for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]; ydim6 = args[6].dat->size[1]; // Timing double t1, t2, c1, c2; ops_timers_core(&c2, &t2); if (xdim0 != xdim0_update_halo_kernel1_ba1_h || ydim0 != ydim0_update_halo_kernel1_ba1_h || xdim1 != xdim1_update_halo_kernel1_ba1_h || ydim1 != ydim1_update_halo_kernel1_ba1_h || xdim2 != xdim2_update_halo_kernel1_ba1_h || ydim2 != ydim2_update_halo_kernel1_ba1_h || xdim3 != xdim3_update_halo_kernel1_ba1_h || ydim3 != ydim3_update_halo_kernel1_ba1_h || xdim4 != xdim4_update_halo_kernel1_ba1_h || ydim4 != ydim4_update_halo_kernel1_ba1_h || xdim5 != xdim5_update_halo_kernel1_ba1_h || ydim5 != ydim5_update_halo_kernel1_ba1_h || xdim6 != xdim6_update_halo_kernel1_ba1_h || ydim6 != ydim6_update_halo_kernel1_ba1_h) { xdim0_update_halo_kernel1_ba1 = xdim0; xdim0_update_halo_kernel1_ba1_h = xdim0; ydim0_update_halo_kernel1_ba1 = ydim0; ydim0_update_halo_kernel1_ba1_h = ydim0; xdim1_update_halo_kernel1_ba1 = xdim1; xdim1_update_halo_kernel1_ba1_h = xdim1; ydim1_update_halo_kernel1_ba1 = ydim1; ydim1_update_halo_kernel1_ba1_h = ydim1; xdim2_update_halo_kernel1_ba1 = xdim2; xdim2_update_halo_kernel1_ba1_h = xdim2; ydim2_update_halo_kernel1_ba1 = ydim2; ydim2_update_halo_kernel1_ba1_h = ydim2; xdim3_update_halo_kernel1_ba1 = xdim3; xdim3_update_halo_kernel1_ba1_h = xdim3; ydim3_update_halo_kernel1_ba1 = ydim3; ydim3_update_halo_kernel1_ba1_h = ydim3; xdim4_update_halo_kernel1_ba1 = xdim4; xdim4_update_halo_kernel1_ba1_h = xdim4; ydim4_update_halo_kernel1_ba1 = ydim4; ydim4_update_halo_kernel1_ba1_h = ydim4; xdim5_update_halo_kernel1_ba1 = xdim5; xdim5_update_halo_kernel1_ba1_h = xdim5; ydim5_update_halo_kernel1_ba1 = ydim5; ydim5_update_halo_kernel1_ba1_h = ydim5; xdim6_update_halo_kernel1_ba1 = xdim6; xdim6_update_halo_kernel1_ba1_h = xdim6; ydim6_update_halo_kernel1_ba1 = ydim6; ydim6_update_halo_kernel1_ba1_h = ydim6; } int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); int dat2 = (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size); int dat3 = (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size); int dat4 = (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size); int dat5 = (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size); int dat6 = (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size); int *arg7h = (int *)arg7.data; // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); double *p_a0 = (double *)((char *)args[0].data + base0); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1 + dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); double *p_a1 = (double *)((char *)args[1].data + base1); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif int base2 = dat2 * 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + dat2 * args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2 + dat2 * args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); double *p_a2 = (double *)((char *)args[2].data + base2); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif int base3 = dat3 * 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + dat3 * args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3 + dat3 * args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); double *p_a3 = (double *)((char *)args[3].data + base3); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4 + dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4 + dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); double *p_a4 = (double *)((char *)args[4].data + base4); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif int base5 = dat5 * 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5 + dat5 * args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5 + dat5 * args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); double *p_a5 = (double *)((char *)args[5].data + base5); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif int base6 = dat6 * 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6 + dat6 * args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6 + dat6 * args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); double *p_a6 = (double *)((char *)args[6].data + base6); int *p_a7 = arg7h; ops_H_D_exchanges_host(args, 8); ops_halo_exchanges(args, 8, range); ops_timers_core(&c1, &t1); OPS_kernels[21].mpi_time += t1 - t2; update_halo_kernel1_ba1_c_wrapper(p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, p_a6, p_a7, x_size, y_size, z_size); ops_timers_core(&c2, &t2); OPS_kernels[21].time += t2 - t1; ops_set_dirtybit_host(args, 8); ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); ops_set_halo_dirtybit3(&args[2], range); ops_set_halo_dirtybit3(&args[3], range); ops_set_halo_dirtybit3(&args[4], range); ops_set_halo_dirtybit3(&args[5], range); ops_set_halo_dirtybit3(&args[6], range); // Update kernel record OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg5); OPS_kernels[21].transfer += ops_compute_transfer(dim, start, end, &arg6); }
// host stub function void ops_par_loop_advec_mom_kernel1_x_nonvector(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4) { // Timing double t1, t2, c1, c2; ops_arg args[5] = {arg0, arg1, arg2, arg3, arg4}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 5, range, 75)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(75, "advec_mom_kernel1_x_nonvector"); OPS_kernels[75].count++; ops_timers_core(&c1, &t1); } // compute localy allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // OPS_MPI int arg_idx[2]; int arg_idx_base[2]; #ifdef OPS_MPI if (compute_ranges(args, 5, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 2; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif for (int n = 0; n < 2; n++) { arg_idx_base[n] = arg_idx[n]; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; // set up initial pointers int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * start[1] * args[1].stencil->stride[1]; #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif int base2 = args[2].dat->base_offset + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * start[0] * args[2].stencil->stride[0]; base2 = base2 + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * start[1] * args[2].stencil->stride[1]; #ifdef OPS_GPU double *p_a2 = (double *)((char *)args[2].data_d + base2); #else double *p_a2 = (double *)((char *)args[2].data + base2); #endif int base3 = args[3].dat->base_offset + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * start[0] * args[3].stencil->stride[0]; base3 = base3 + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * start[1] * args[3].stencil->stride[1]; #ifdef OPS_GPU double *p_a3 = (double *)((char *)args[3].data_d + base3); #else double *p_a3 = (double *)((char *)args[3].data + base3); #endif int base4 = args[4].dat->base_offset + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * start[0] * args[4].stencil->stride[0]; base4 = base4 + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * start[1] * args[4].stencil->stride[1]; #ifdef OPS_GPU double *p_a4 = (double *)((char *)args[4].data_d + base4); #else double *p_a4 = (double *)((char *)args[4].data + base4); #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; xdim1 = args[1].dat->size[0]; xdim2 = args[2].dat->size[0]; xdim3 = args[3].dat->size[0]; xdim4 = args[4].dat->size[0]; if (xdim0 != xdim0_advec_mom_kernel1_x_nonvector_h || xdim1 != xdim1_advec_mom_kernel1_x_nonvector_h || xdim2 != xdim2_advec_mom_kernel1_x_nonvector_h || xdim3 != xdim3_advec_mom_kernel1_x_nonvector_h || xdim4 != xdim4_advec_mom_kernel1_x_nonvector_h) { xdim0_advec_mom_kernel1_x_nonvector = xdim0; xdim0_advec_mom_kernel1_x_nonvector_h = xdim0; xdim1_advec_mom_kernel1_x_nonvector = xdim1; xdim1_advec_mom_kernel1_x_nonvector_h = xdim1; xdim2_advec_mom_kernel1_x_nonvector = xdim2; xdim2_advec_mom_kernel1_x_nonvector_h = xdim2; xdim3_advec_mom_kernel1_x_nonvector = xdim3; xdim3_advec_mom_kernel1_x_nonvector_h = xdim3; xdim4_advec_mom_kernel1_x_nonvector = xdim4; xdim4_advec_mom_kernel1_x_nonvector_h = xdim4; } // Halo Exchanges #ifdef OPS_GPU ops_H_D_exchanges_device(args, 5); #else ops_H_D_exchanges_host(args, 5); #endif ops_halo_exchanges(args, 5, range); #ifdef OPS_GPU ops_H_D_exchanges_device(args, 5); #else ops_H_D_exchanges_host(args, 5); #endif if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[75].mpi_time += t2 - t1; } advec_mom_kernel1_x_nonvector_c_wrapper(p_a0, p_a1, p_a2, p_a3, p_a4, x_size, y_size); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[75].time += t1 - t2; } #ifdef OPS_GPU ops_set_dirtybit_device(args, 5); #else ops_set_dirtybit_host(args, 5); #endif ops_set_halo_dirtybit3(&args[2], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[75].mpi_time += t2 - t1; OPS_kernels[75].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[75].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[75].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[75].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[75].transfer += ops_compute_transfer(dim, start, end, &arg4); } }
// host stub function void ops_par_loop_test_kernel(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1) { // Timing double t1, t2, c1, c2; char *p_a[2]; int offs[2][1]; ops_arg args[2] = {arg0, arg1}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 2, range, 14)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(14, "test_kernel"); OPS_kernels[14].count++; ops_timers_core(&c2, &t2); } // compute locally allocated range for the sub-block int start[1]; int end[1]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif #ifdef OPS_DEBUG ops_register_args(args, "test_kernel"); #endif int arg_idx[1]; int arg_idx_base[1]; #ifdef OPS_MPI if (compute_ranges(args, 2, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 1; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif // OPS_MPI for (int n = 0; n < 1; n++) { arg_idx_base[n] = arg_idx[n]; } offs[0][0] = args[0].stencil->stride[0] * 1; // unit step in x dimension int off0_0 = offs[0][0]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); // set up initial pointers and exchange halos if necessary int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; p_a[0] = (char *)args[0].data + base0; #ifdef OPS_MPI p_a[1] = ((ops_reduction)args[1].data)->data + ((ops_reduction)args[1].data)->size * block->index; #else p_a[1] = ((ops_reduction)args[1].data)->data; #endif // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; // Halo Exchanges ops_H_D_exchanges_host(args, 2); ops_halo_exchanges(args, 2, range); ops_H_D_exchanges_host(args, 2); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[14].mpi_time += t1 - t2; } int n_x; #pragma novector for (n_x = start[0]; n_x < start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x += SIMD_VEC) { // call kernel function, passing in pointers to data -vectorised for (int i = 0; i < SIMD_VEC; i++) { test_kernel((double *)p_a[0] + i * 1 * 1, (double *)p_a[1]); } // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0) * SIMD_VEC; } for (int n_x = start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x < end[0]; n_x++) { // call kernel function, passing in pointers to data - remainder test_kernel((double *)p_a[0], (double *)p_a[1]); // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0); } if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[14].time += t2 - t1; } ops_set_dirtybit_host(args, 2); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c1, &t1); OPS_kernels[14].mpi_time += t1 - t2; OPS_kernels[14].transfer += ops_compute_transfer(dim, start, end, &arg0); } }
// host stub function void ops_par_loop_advec_cell_kernel3_ydir(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7) { char *p_a[8]; int offs[8][3]; ops_arg args[8] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; ops_timing_realloc(35,"advec_cell_kernel3_ydir"); OPS_kernels[35].count++; //compute locally allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI #ifdef OPS_DEBUG ops_register_args(args, "advec_cell_kernel3_ydir"); #endif offs[0][0] = args[0].stencil->stride[0]*1; //unit step in x dimension offs[0][1] = off3D(1, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][0]; offs[0][2] = off3D(2, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][1] - offs[0][0]; offs[1][0] = args[1].stencil->stride[0]*1; //unit step in x dimension offs[1][1] = off3D(1, &start[0], &end[0],args[1].dat->size, args[1].stencil->stride) - offs[1][0]; offs[1][2] = off3D(2, &start[0], &end[0],args[1].dat->size, args[1].stencil->stride) - offs[1][1] - offs[1][0]; offs[2][0] = args[2].stencil->stride[0]*1; //unit step in x dimension offs[2][1] = off3D(1, &start[0], &end[0],args[2].dat->size, args[2].stencil->stride) - offs[2][0]; offs[2][2] = off3D(2, &start[0], &end[0],args[2].dat->size, args[2].stencil->stride) - offs[2][1] - offs[2][0]; offs[3][0] = args[3].stencil->stride[0]*1; //unit step in x dimension offs[3][1] = off3D(1, &start[0], &end[0],args[3].dat->size, args[3].stencil->stride) - offs[3][0]; offs[3][2] = off3D(2, &start[0], &end[0],args[3].dat->size, args[3].stencil->stride) - offs[3][1] - offs[3][0]; offs[4][0] = args[4].stencil->stride[0]*1; //unit step in x dimension offs[4][1] = off3D(1, &start[0], &end[0],args[4].dat->size, args[4].stencil->stride) - offs[4][0]; offs[4][2] = off3D(2, &start[0], &end[0],args[4].dat->size, args[4].stencil->stride) - offs[4][1] - offs[4][0]; offs[5][0] = args[5].stencil->stride[0]*1; //unit step in x dimension offs[5][1] = off3D(1, &start[0], &end[0],args[5].dat->size, args[5].stencil->stride) - offs[5][0]; offs[5][2] = off3D(2, &start[0], &end[0],args[5].dat->size, args[5].stencil->stride) - offs[5][1] - offs[5][0]; offs[6][0] = args[6].stencil->stride[0]*1; //unit step in x dimension offs[6][1] = off3D(1, &start[0], &end[0],args[6].dat->size, args[6].stencil->stride) - offs[6][0]; offs[6][2] = off3D(2, &start[0], &end[0],args[6].dat->size, args[6].stencil->stride) - offs[6][1] - offs[6][0]; offs[7][0] = args[7].stencil->stride[0]*1; //unit step in x dimension offs[7][1] = off3D(1, &start[0], &end[0],args[7].dat->size, args[7].stencil->stride) - offs[7][0]; offs[7][2] = off3D(2, &start[0], &end[0],args[7].dat->size, args[7].stencil->stride) - offs[7][1] - offs[7][0]; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int off0_2 = offs[0][2]; int dat0 = args[0].dat->elem_size; int off1_0 = offs[1][0]; int off1_1 = offs[1][1]; int off1_2 = offs[1][2]; int dat1 = args[1].dat->elem_size; int off2_0 = offs[2][0]; int off2_1 = offs[2][1]; int off2_2 = offs[2][2]; int dat2 = args[2].dat->elem_size; int off3_0 = offs[3][0]; int off3_1 = offs[3][1]; int off3_2 = offs[3][2]; int dat3 = args[3].dat->elem_size; int off4_0 = offs[4][0]; int off4_1 = offs[4][1]; int off4_2 = offs[4][2]; int dat4 = args[4].dat->elem_size; int off5_0 = offs[5][0]; int off5_1 = offs[5][1]; int off5_2 = offs[5][2]; int dat5 = args[5].dat->elem_size; int off6_0 = offs[6][0]; int off6_1 = offs[6][1]; int off6_2 = offs[6][2]; int dat6 = args[6].dat->elem_size; int off7_0 = offs[7][0]; int off7_1 = offs[7][1]; int off7_2 = offs[7][2]; int dat7 = args[7].dat->elem_size; //set up initial pointers and exchange halos if necessary int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0+ dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); p_a[0] = (char *)args[0].data + base0; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1+ dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); p_a[1] = (char *)args[1].data + base1; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif //OPS_MPI int base2 = dat2 * 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2+ dat2 * args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2+ dat2 * args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); p_a[2] = (char *)args[2].data + base2; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = dat3 * 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3+ dat3 * args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3+ dat3 * args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); p_a[3] = (char *)args[3].data + base3; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4+ dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4+ dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); p_a[4] = (char *)args[4].data + base4; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif //OPS_MPI int base5 = dat5 * 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5+ dat5 * args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5+ dat5 * args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); p_a[5] = (char *)args[5].data + base5; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif //OPS_MPI int base6 = dat6 * 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6+ dat6 * args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6+ dat6 * args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); p_a[6] = (char *)args[6].data + base6; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d] + OPS_sub_dat_list[args[7].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d]; #endif //OPS_MPI int base7 = dat7 * 1 * (start[0] * args[7].stencil->stride[0] - args[7].dat->base[0] - d_m[0]); base7 = base7+ dat7 * args[7].dat->size[0] * (start[1] * args[7].stencil->stride[1] - args[7].dat->base[1] - d_m[1]); base7 = base7+ dat7 * args[7].dat->size[0] * args[7].dat->size[1] * (start[2] * args[7].stencil->stride[2] - args[7].dat->base[2] - d_m[2]); p_a[7] = (char *)args[7].data + base7; ops_H_D_exchanges_host(args, 8); ops_halo_exchanges(args,8,range); ops_H_D_exchanges_host(args, 8); ops_timers_core(&c1,&t1); OPS_kernels[35].mpi_time += t1-t2; xdim0 = args[0].dat->size[0]*args[0].dat->dim; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]*args[1].dat->dim; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]*args[2].dat->dim; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]*args[3].dat->dim; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]*args[4].dat->dim; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]*args[5].dat->dim; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]*args[6].dat->dim; ydim6 = args[6].dat->size[1]; xdim7 = args[7].dat->size[0]*args[7].dat->dim; ydim7 = args[7].dat->size[1]; int n_x; for ( int n_z=start[2]; n_z<end[2]; n_z++ ){ for ( int n_y=start[1]; n_y<end[1]; n_y++ ){ #pragma novector for( n_x=start[0]; n_x<start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x+=SIMD_VEC ) { //call kernel function, passing in pointers to data -vectorised #pragma simd for ( int i=0; i<SIMD_VEC; i++ ){ advec_cell_kernel3_ydir( (double *)p_a[0]+ i*1, (double *)p_a[1]+ i*1, (int *)p_a[2]+ i*0, (double *)p_a[3]+ i*0, (double *)p_a[4]+ i*1, (double *)p_a[5]+ i*1, (double *)p_a[6]+ i*1, (double *)p_a[7]+ i*1 ); } //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0)*SIMD_VEC; p_a[1]= p_a[1] + (dat1 * off1_0)*SIMD_VEC; p_a[2]= p_a[2] + (dat2 * off2_0)*SIMD_VEC; p_a[3]= p_a[3] + (dat3 * off3_0)*SIMD_VEC; p_a[4]= p_a[4] + (dat4 * off4_0)*SIMD_VEC; p_a[5]= p_a[5] + (dat5 * off5_0)*SIMD_VEC; p_a[6]= p_a[6] + (dat6 * off6_0)*SIMD_VEC; p_a[7]= p_a[7] + (dat7 * off7_0)*SIMD_VEC; } for ( int n_x=start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x<end[0]; n_x++ ){ //call kernel function, passing in pointers to data - remainder advec_cell_kernel3_ydir( (double *)p_a[0], (double *)p_a[1], (int *)p_a[2], (double *)p_a[3], (double *)p_a[4], (double *)p_a[5], (double *)p_a[6], (double *)p_a[7] ); //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0); p_a[1]= p_a[1] + (dat1 * off1_0); p_a[2]= p_a[2] + (dat2 * off2_0); p_a[3]= p_a[3] + (dat3 * off3_0); p_a[4]= p_a[4] + (dat4 * off4_0); p_a[5]= p_a[5] + (dat5 * off5_0); p_a[6]= p_a[6] + (dat6 * off6_0); p_a[7]= p_a[7] + (dat7 * off7_0); } //shift pointers to data y direction p_a[0]= p_a[0] + (dat0 * off0_1); p_a[1]= p_a[1] + (dat1 * off1_1); p_a[2]= p_a[2] + (dat2 * off2_1); p_a[3]= p_a[3] + (dat3 * off3_1); p_a[4]= p_a[4] + (dat4 * off4_1); p_a[5]= p_a[5] + (dat5 * off5_1); p_a[6]= p_a[6] + (dat6 * off6_1); p_a[7]= p_a[7] + (dat7 * off7_1); } //shift pointers to data z direction p_a[0]= p_a[0] + (dat0 * off0_2); p_a[1]= p_a[1] + (dat1 * off1_2); p_a[2]= p_a[2] + (dat2 * off2_2); p_a[3]= p_a[3] + (dat3 * off3_2); p_a[4]= p_a[4] + (dat4 * off4_2); p_a[5]= p_a[5] + (dat5 * off5_2); p_a[6]= p_a[6] + (dat6 * off6_2); p_a[7]= p_a[7] + (dat7 * off7_2); } ops_timers_core(&c2,&t2); OPS_kernels[35].time += t2-t1; ops_set_dirtybit_host(args, 8); ops_set_halo_dirtybit3(&args[6],range); ops_set_halo_dirtybit3(&args[7],range); //Update kernel record OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg2); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg3); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg4); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg5); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg6); OPS_kernels[35].transfer += ops_compute_transfer(dim, range, &arg7); }
// host stub function void ops_par_loop_update_halo_kernel1_l2(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7) { ops_arg args[8] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; ops_timing_realloc(45,"update_halo_kernel1_l2"); OPS_kernels[45].count++; //compute locally allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int z_size = MAX(0,end[2]-start[2]); int xdim0 = args[0].dat->size[0]*args[0].dat->dim; int ydim0 = args[0].dat->size[1]; int xdim1 = args[1].dat->size[0]*args[1].dat->dim; int ydim1 = args[1].dat->size[1]; int xdim2 = args[2].dat->size[0]*args[2].dat->dim; int ydim2 = args[2].dat->size[1]; int xdim3 = args[3].dat->size[0]*args[3].dat->dim; int ydim3 = args[3].dat->size[1]; int xdim4 = args[4].dat->size[0]*args[4].dat->dim; int ydim4 = args[4].dat->size[1]; int xdim5 = args[5].dat->size[0]*args[5].dat->dim; int ydim5 = args[5].dat->size[1]; int xdim6 = args[6].dat->size[0]*args[6].dat->dim; int ydim6 = args[6].dat->size[1]; //build opencl kernel if not already built buildOpenCLKernels_update_halo_kernel1_l2( xdim0,ydim0,xdim1,ydim1,xdim2,ydim2,xdim3,ydim3,xdim4,ydim4,xdim5,ydim5,xdim6,ydim6); //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); //set up OpenCL thread blocks size_t globalWorkSize[3] = {((x_size-1)/OPS_block_size_x+ 1)*OPS_block_size_x, ((y_size-1)/OPS_block_size_y + 1)*OPS_block_size_y, MAX(1,end[2]-start[2])}; size_t localWorkSize[3] = {OPS_block_size_x,OPS_block_size_y,1}; int *arg7h = (int *)arg7.data; int consts_bytes = 0; consts_bytes += ROUND_UP(NUM_FIELDS*sizeof(int)); reallocConstArrays(consts_bytes); consts_bytes = 0; arg7.data = OPS_consts_h + consts_bytes; arg7.data_d = OPS_consts_d + consts_bytes; for (int d=0; d<NUM_FIELDS; d++) ((int *)arg7.data)[d] = arg7h[d]; consts_bytes += ROUND_UP(NUM_FIELDS*sizeof(int)); mvConstArraysToDevice(consts_bytes); int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; int dat5 = args[5].dat->elem_size; int dat6 = args[6].dat->elem_size; //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1 + args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif //OPS_MPI int base2 = 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2 + args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3 + args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4 + args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4 + args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif //OPS_MPI int base5 = 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5 + args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5 + args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif //OPS_MPI int base6 = 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6 + args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6 + args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); ops_H_D_exchanges_device(args, 8); ops_halo_exchanges(args,8,range); ops_H_D_exchanges_device(args, 8); ops_timers_core(&c1,&t1); OPS_kernels[45].mpi_time += t1-t2; clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 0, sizeof(cl_mem), (void*) &arg0.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 1, sizeof(cl_mem), (void*) &arg1.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 2, sizeof(cl_mem), (void*) &arg2.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 3, sizeof(cl_mem), (void*) &arg3.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 4, sizeof(cl_mem), (void*) &arg4.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 5, sizeof(cl_mem), (void*) &arg5.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 6, sizeof(cl_mem), (void*) &arg6.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 7, sizeof(cl_mem), (void*) &arg7.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 8, sizeof(cl_int), (void*) &base0 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 9, sizeof(cl_int), (void*) &base1 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 10, sizeof(cl_int), (void*) &base2 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 11, sizeof(cl_int), (void*) &base3 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 12, sizeof(cl_int), (void*) &base4 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 13, sizeof(cl_int), (void*) &base5 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 14, sizeof(cl_int), (void*) &base6 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 15, sizeof(cl_int), (void*) &x_size )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 16, sizeof(cl_int), (void*) &y_size )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[45], 17, sizeof(cl_int), (void*) &z_size )); //call/enque opencl kernel wrapper function clSafeCall( clEnqueueNDRangeKernel(OPS_opencl_core.command_queue, OPS_opencl_core.kernel[45], 3, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL) ); if (OPS_diags>1) { clSafeCall( clFinish(OPS_opencl_core.command_queue) ); } ops_set_dirtybit_device(args, 8); ops_set_halo_dirtybit3(&args[0],range); ops_set_halo_dirtybit3(&args[1],range); ops_set_halo_dirtybit3(&args[2],range); ops_set_halo_dirtybit3(&args[3],range); ops_set_halo_dirtybit3(&args[4],range); ops_set_halo_dirtybit3(&args[5],range); ops_set_halo_dirtybit3(&args[6],range); //Update kernel record ops_timers_core(&c2,&t2); OPS_kernels[45].time += t2-t1; OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg2); OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg3); OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg4); OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg5); OPS_kernels[45].transfer += ops_compute_transfer(dim, range, &arg6); }
// host stub function void ops_par_loop_update_halo_kernel3_plus_4_a(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2) { // Timing double t1, t2, c1, c2; char *p_a[3]; int offs[3][2]; ops_arg args[3] = {arg0, arg1, arg2}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 3, range, 33)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(33, "update_halo_kernel3_plus_4_a"); OPS_kernels[33].count++; ops_timers_core(&c2, &t2); } // compute locally allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif #ifdef OPS_DEBUG ops_register_args(args, "update_halo_kernel3_plus_4_a"); #endif int arg_idx[2]; int arg_idx_base[2]; #ifdef OPS_MPI if (compute_ranges(args, 3, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 2; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif // OPS_MPI for (int n = 0; n < 2; n++) { arg_idx_base[n] = arg_idx[n]; } offs[0][0] = args[0].stencil->stride[0] * 1; // unit step in x dimension offs[0][1] = off2D(1, &start[0], &end[0], args[0].dat->size, args[0].stencil->stride) - offs[0][0]; offs[1][0] = args[1].stencil->stride[0] * 1; // unit step in x dimension offs[1][1] = off2D(1, &start[0], &end[0], args[1].dat->size, args[1].stencil->stride) - offs[1][0]; int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int off1_0 = offs[1][0]; int off1_1 = offs[1][1]; int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); // set up initial pointers and exchange halos if necessary int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; p_a[0] = (char *)args[0].data + base0; int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * start[1] * args[1].stencil->stride[1]; p_a[1] = (char *)args[1].data + base1; p_a[2] = args[2].data; // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; xdim1 = args[1].dat->size[0]; // Halo Exchanges ops_H_D_exchanges_host(args, 3); ops_halo_exchanges(args, 3, range); ops_H_D_exchanges_host(args, 3); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[33].mpi_time += t1 - t2; } int n_x; for (int n_y = start[1]; n_y < end[1]; n_y++) { #pragma novector for (n_x = start[0]; n_x < start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x += SIMD_VEC) { // call kernel function, passing in pointers to data -vectorised #pragma simd for (int i = 0; i < SIMD_VEC; i++) { update_halo_kernel3_plus_4_a((double *)p_a[0] + i * 1 * 1, (double *)p_a[1] + i * 1 * 1, (int *)p_a[2]); } // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0) * SIMD_VEC; p_a[1] = p_a[1] + (dat1 * off1_0) * SIMD_VEC; } for (int n_x = start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x < end[0]; n_x++) { // call kernel function, passing in pointers to data - remainder update_halo_kernel3_plus_4_a((double *)p_a[0], (double *)p_a[1], (int *)p_a[2]); // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0); p_a[1] = p_a[1] + (dat1 * off1_0); } // shift pointers to data y direction p_a[0] = p_a[0] + (dat0 * off0_1); p_a[1] = p_a[1] + (dat1 * off1_1); } if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[33].time += t2 - t1; } ops_set_dirtybit_host(args, 3); ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c1, &t1); OPS_kernels[33].mpi_time += t1 - t2; OPS_kernels[33].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[33].transfer += ops_compute_transfer(dim, start, end, &arg1); } }
// host stub function void ops_par_loop_preproc_kernel(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7, ops_arg arg8, ops_arg arg9, ops_arg arg10, ops_arg arg11) { //Timing double t1,t2,c1,c2; char *p_a[12]; int offs[12][3]; ops_arg args[12] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args,12,range,1)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(1,"preproc_kernel"); OPS_kernels[1].count++; ops_timers_core(&c2,&t2); } //compute locally allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif #ifdef OPS_DEBUG ops_register_args(args, "preproc_kernel"); #endif int arg_idx[3]; int arg_idx_base[3]; #ifdef OPS_MPI if (compute_ranges(args, 12, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif // OPS_MPI for (int n = 0; n < 3; n++) { arg_idx_base[n] = arg_idx[n]; } offs[0][0] = args[0].stencil->stride[0]*1; //unit step in x dimension offs[0][1] = off3D(1, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][0]; offs[0][2] = off3D(2, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][1] - offs[0][0]; offs[1][0] = args[1].stencil->stride[0]*1; //unit step in x dimension offs[1][1] = off3D(1, &start[0], &end[0],args[1].dat->size, args[1].stencil->stride) - offs[1][0]; offs[1][2] = off3D(2, &start[0], &end[0],args[1].dat->size, args[1].stencil->stride) - offs[1][1] - offs[1][0]; offs[2][0] = args[2].stencil->stride[0]*1; //unit step in x dimension offs[2][1] = off3D(1, &start[0], &end[0],args[2].dat->size, args[2].stencil->stride) - offs[2][0]; offs[2][2] = off3D(2, &start[0], &end[0],args[2].dat->size, args[2].stencil->stride) - offs[2][1] - offs[2][0]; offs[3][0] = args[3].stencil->stride[0]*1; //unit step in x dimension offs[3][1] = off3D(1, &start[0], &end[0],args[3].dat->size, args[3].stencil->stride) - offs[3][0]; offs[3][2] = off3D(2, &start[0], &end[0],args[3].dat->size, args[3].stencil->stride) - offs[3][1] - offs[3][0]; offs[4][0] = args[4].stencil->stride[0]*1; //unit step in x dimension offs[4][1] = off3D(1, &start[0], &end[0],args[4].dat->size, args[4].stencil->stride) - offs[4][0]; offs[4][2] = off3D(2, &start[0], &end[0],args[4].dat->size, args[4].stencil->stride) - offs[4][1] - offs[4][0]; offs[5][0] = args[5].stencil->stride[0]*1; //unit step in x dimension offs[5][1] = off3D(1, &start[0], &end[0],args[5].dat->size, args[5].stencil->stride) - offs[5][0]; offs[5][2] = off3D(2, &start[0], &end[0],args[5].dat->size, args[5].stencil->stride) - offs[5][1] - offs[5][0]; offs[6][0] = args[6].stencil->stride[0]*1; //unit step in x dimension offs[6][1] = off3D(1, &start[0], &end[0],args[6].dat->size, args[6].stencil->stride) - offs[6][0]; offs[6][2] = off3D(2, &start[0], &end[0],args[6].dat->size, args[6].stencil->stride) - offs[6][1] - offs[6][0]; offs[7][0] = args[7].stencil->stride[0]*1; //unit step in x dimension offs[7][1] = off3D(1, &start[0], &end[0],args[7].dat->size, args[7].stencil->stride) - offs[7][0]; offs[7][2] = off3D(2, &start[0], &end[0],args[7].dat->size, args[7].stencil->stride) - offs[7][1] - offs[7][0]; offs[8][0] = args[8].stencil->stride[0]*1; //unit step in x dimension offs[8][1] = off3D(1, &start[0], &end[0],args[8].dat->size, args[8].stencil->stride) - offs[8][0]; offs[8][2] = off3D(2, &start[0], &end[0],args[8].dat->size, args[8].stencil->stride) - offs[8][1] - offs[8][0]; offs[9][0] = args[9].stencil->stride[0]*1; //unit step in x dimension offs[9][1] = off3D(1, &start[0], &end[0],args[9].dat->size, args[9].stencil->stride) - offs[9][0]; offs[9][2] = off3D(2, &start[0], &end[0],args[9].dat->size, args[9].stencil->stride) - offs[9][1] - offs[9][0]; offs[10][0] = args[10].stencil->stride[0]*1; //unit step in x dimension offs[10][1] = off3D(1, &start[0], &end[0],args[10].dat->size, args[10].stencil->stride) - offs[10][0]; offs[10][2] = off3D(2, &start[0], &end[0],args[10].dat->size, args[10].stencil->stride) - offs[10][1] - offs[10][0]; int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int off0_2 = offs[0][2]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int off1_0 = offs[1][0]; int off1_1 = offs[1][1]; int off1_2 = offs[1][2]; int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); int off2_0 = offs[2][0]; int off2_1 = offs[2][1]; int off2_2 = offs[2][2]; int dat2 = (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size); int off3_0 = offs[3][0]; int off3_1 = offs[3][1]; int off3_2 = offs[3][2]; int dat3 = (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size); int off4_0 = offs[4][0]; int off4_1 = offs[4][1]; int off4_2 = offs[4][2]; int dat4 = (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size); int off5_0 = offs[5][0]; int off5_1 = offs[5][1]; int off5_2 = offs[5][2]; int dat5 = (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size); int off6_0 = offs[6][0]; int off6_1 = offs[6][1]; int off6_2 = offs[6][2]; int dat6 = (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size); int off7_0 = offs[7][0]; int off7_1 = offs[7][1]; int off7_2 = offs[7][2]; int dat7 = (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size); int off8_0 = offs[8][0]; int off8_1 = offs[8][1]; int off8_2 = offs[8][2]; int dat8 = (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size); int off9_0 = offs[9][0]; int off9_1 = offs[9][1]; int off9_2 = offs[9][2]; int dat9 = (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size); int off10_0 = offs[10][0]; int off10_1 = offs[10][1]; int off10_2 = offs[10][2]; int dat10 = (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size); //set up initial pointers and exchange halos if necessary int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0+ (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; base0 = base0+ (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * args[0].dat->size[1] * start[2] * args[0].stencil->stride[2]; p_a[0] = (char *)args[0].data + base0; int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; base1 = base1+ (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * start[1] * args[1].stencil->stride[1]; base1 = base1+ (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * args[1].dat->size[1] * start[2] * args[1].stencil->stride[2]; p_a[1] = (char *)args[1].data + base1; int base2 = args[2].dat->base_offset + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * start[0] * args[2].stencil->stride[0]; base2 = base2+ (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * start[1] * args[2].stencil->stride[1]; base2 = base2+ (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * args[2].dat->size[1] * start[2] * args[2].stencil->stride[2]; p_a[2] = (char *)args[2].data + base2; int base3 = args[3].dat->base_offset + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * start[0] * args[3].stencil->stride[0]; base3 = base3+ (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * start[1] * args[3].stencil->stride[1]; base3 = base3+ (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * args[3].dat->size[1] * start[2] * args[3].stencil->stride[2]; p_a[3] = (char *)args[3].data + base3; int base4 = args[4].dat->base_offset + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * start[0] * args[4].stencil->stride[0]; base4 = base4+ (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * start[1] * args[4].stencil->stride[1]; base4 = base4+ (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * args[4].dat->size[1] * start[2] * args[4].stencil->stride[2]; p_a[4] = (char *)args[4].data + base4; int base5 = args[5].dat->base_offset + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * start[0] * args[5].stencil->stride[0]; base5 = base5+ (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * args[5].dat->size[0] * start[1] * args[5].stencil->stride[1]; base5 = base5+ (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * args[5].dat->size[0] * args[5].dat->size[1] * start[2] * args[5].stencil->stride[2]; p_a[5] = (char *)args[5].data + base5; int base6 = args[6].dat->base_offset + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * start[0] * args[6].stencil->stride[0]; base6 = base6+ (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * args[6].dat->size[0] * start[1] * args[6].stencil->stride[1]; base6 = base6+ (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * args[6].dat->size[0] * args[6].dat->size[1] * start[2] * args[6].stencil->stride[2]; p_a[6] = (char *)args[6].data + base6; int base7 = args[7].dat->base_offset + (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size) * start[0] * args[7].stencil->stride[0]; base7 = base7+ (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size) * args[7].dat->size[0] * start[1] * args[7].stencil->stride[1]; base7 = base7+ (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size) * args[7].dat->size[0] * args[7].dat->size[1] * start[2] * args[7].stencil->stride[2]; p_a[7] = (char *)args[7].data + base7; int base8 = args[8].dat->base_offset + (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size) * start[0] * args[8].stencil->stride[0]; base8 = base8+ (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size) * args[8].dat->size[0] * start[1] * args[8].stencil->stride[1]; base8 = base8+ (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size) * args[8].dat->size[0] * args[8].dat->size[1] * start[2] * args[8].stencil->stride[2]; p_a[8] = (char *)args[8].data + base8; int base9 = args[9].dat->base_offset + (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size) * start[0] * args[9].stencil->stride[0]; base9 = base9+ (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size) * args[9].dat->size[0] * start[1] * args[9].stencil->stride[1]; base9 = base9+ (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size) * args[9].dat->size[0] * args[9].dat->size[1] * start[2] * args[9].stencil->stride[2]; p_a[9] = (char *)args[9].data + base9; int base10 = args[10].dat->base_offset + (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size) * start[0] * args[10].stencil->stride[0]; base10 = base10+ (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size) * args[10].dat->size[0] * start[1] * args[10].stencil->stride[1]; base10 = base10+ (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size) * args[10].dat->size[0] * args[10].dat->size[1] * start[2] * args[10].stencil->stride[2]; p_a[10] = (char *)args[10].data + base10; p_a[11] = (char *)arg_idx; //initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]; ydim6 = args[6].dat->size[1]; xdim7 = args[7].dat->size[0]; ydim7 = args[7].dat->size[1]; xdim8 = args[8].dat->size[0]; ydim8 = args[8].dat->size[1]; xdim9 = args[9].dat->size[0]; ydim9 = args[9].dat->size[1]; xdim10 = args[10].dat->size[0]; ydim10 = args[10].dat->size[1]; //Halo Exchanges ops_H_D_exchanges_host(args, 12); ops_halo_exchanges(args,12,range); ops_H_D_exchanges_host(args, 12); if (OPS_diags > 1) { ops_timers_core(&c1,&t1); OPS_kernels[1].mpi_time += t1-t2; } int n_x; for ( int n_z=start[2]; n_z<end[2]; n_z++ ){ for ( int n_y=start[1]; n_y<end[1]; n_y++ ){ #pragma novector for( n_x=start[0]; n_x<start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x+=SIMD_VEC ) { //call kernel function, passing in pointers to data -vectorised for ( int i=0; i<SIMD_VEC; i++ ){ preproc_kernel( (double *)p_a[0]+ i*1*1, (double *)p_a[1]+ i*1*1, (double *)p_a[2]+ i*1*1, (double *)p_a[3]+ i*1*1, (double *)p_a[4]+ i*1*1, (double *)p_a[5]+ i*1*1, (double *)p_a[6]+ i*1*1, (double *)p_a[7]+ i*1*1, (double *)p_a[8]+ i*1*1, (double *)p_a[9]+ i*1*1, (double *)p_a[10]+ i*1*1, (int *)p_a[11] ); arg_idx[0]++; } //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0)*SIMD_VEC; p_a[1]= p_a[1] + (dat1 * off1_0)*SIMD_VEC; p_a[2]= p_a[2] + (dat2 * off2_0)*SIMD_VEC; p_a[3]= p_a[3] + (dat3 * off3_0)*SIMD_VEC; p_a[4]= p_a[4] + (dat4 * off4_0)*SIMD_VEC; p_a[5]= p_a[5] + (dat5 * off5_0)*SIMD_VEC; p_a[6]= p_a[6] + (dat6 * off6_0)*SIMD_VEC; p_a[7]= p_a[7] + (dat7 * off7_0)*SIMD_VEC; p_a[8]= p_a[8] + (dat8 * off8_0)*SIMD_VEC; p_a[9]= p_a[9] + (dat9 * off9_0)*SIMD_VEC; p_a[10]= p_a[10] + (dat10 * off10_0)*SIMD_VEC; } for ( int n_x=start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x<end[0]; n_x++ ){ //call kernel function, passing in pointers to data - remainder preproc_kernel( (double *)p_a[0], (double *)p_a[1], (double *)p_a[2], (double *)p_a[3], (double *)p_a[4], (double *)p_a[5], (double *)p_a[6], (double *)p_a[7], (double *)p_a[8], (double *)p_a[9], (double *)p_a[10], (int *)p_a[11] ); //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0); p_a[1]= p_a[1] + (dat1 * off1_0); p_a[2]= p_a[2] + (dat2 * off2_0); p_a[3]= p_a[3] + (dat3 * off3_0); p_a[4]= p_a[4] + (dat4 * off4_0); p_a[5]= p_a[5] + (dat5 * off5_0); p_a[6]= p_a[6] + (dat6 * off6_0); p_a[7]= p_a[7] + (dat7 * off7_0); p_a[8]= p_a[8] + (dat8 * off8_0); p_a[9]= p_a[9] + (dat9 * off9_0); p_a[10]= p_a[10] + (dat10 * off10_0); arg_idx[0]++; } //shift pointers to data y direction p_a[0]= p_a[0] + (dat0 * off0_1); p_a[1]= p_a[1] + (dat1 * off1_1); p_a[2]= p_a[2] + (dat2 * off2_1); p_a[3]= p_a[3] + (dat3 * off3_1); p_a[4]= p_a[4] + (dat4 * off4_1); p_a[5]= p_a[5] + (dat5 * off5_1); p_a[6]= p_a[6] + (dat6 * off6_1); p_a[7]= p_a[7] + (dat7 * off7_1); p_a[8]= p_a[8] + (dat8 * off8_1); p_a[9]= p_a[9] + (dat9 * off9_1); p_a[10]= p_a[10] + (dat10 * off10_1); arg_idx[0] = arg_idx_base[0]; arg_idx[1]++; } //shift pointers to data z direction p_a[0]= p_a[0] + (dat0 * off0_2); p_a[1]= p_a[1] + (dat1 * off1_2); p_a[2]= p_a[2] + (dat2 * off2_2); p_a[3]= p_a[3] + (dat3 * off3_2); p_a[4]= p_a[4] + (dat4 * off4_2); p_a[5]= p_a[5] + (dat5 * off5_2); p_a[6]= p_a[6] + (dat6 * off6_2); p_a[7]= p_a[7] + (dat7 * off7_2); p_a[8]= p_a[8] + (dat8 * off8_2); p_a[9]= p_a[9] + (dat9 * off9_2); p_a[10]= p_a[10] + (dat10 * off10_2); arg_idx[0] = arg_idx_base[0]; arg_idx[1] = arg_idx_base[1]; arg_idx[2]++; } if (OPS_diags > 1) { ops_timers_core(&c2,&t2); OPS_kernels[1].time += t2-t1; } ops_set_dirtybit_host(args, 12); ops_set_halo_dirtybit3(&args[1],range); ops_set_halo_dirtybit3(&args[2],range); ops_set_halo_dirtybit3(&args[3],range); ops_set_halo_dirtybit3(&args[4],range); ops_set_halo_dirtybit3(&args[5],range); ops_set_halo_dirtybit3(&args[6],range); ops_set_halo_dirtybit3(&args[7],range); ops_set_halo_dirtybit3(&args[8],range); ops_set_halo_dirtybit3(&args[9],range); ops_set_halo_dirtybit3(&args[10],range); if (OPS_diags > 1) { //Update kernel record ops_timers_core(&c1,&t1); OPS_kernels[1].mpi_time += t1-t2; OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg5); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg6); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg7); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg8); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg9); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg10); } }
// host stub function void ops_par_loop_update_halo_kernel2_zvel_plus_4_top(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2) { char *p_a[3]; int offs[3][3]; ops_arg args[3] = { arg0, arg1, arg2}; ops_timing_realloc(79,"update_halo_kernel2_zvel_plus_4_top"); OPS_kernels[79].count++; //compute locally allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI #ifdef OPS_DEBUG ops_register_args(args, "update_halo_kernel2_zvel_plus_4_top"); #endif offs[0][0] = args[0].stencil->stride[0]*1; //unit step in x dimension offs[0][1] = off3D(1, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][0]; offs[0][2] = off3D(2, &start[0], &end[0],args[0].dat->size, args[0].stencil->stride) - offs[0][1] - offs[0][0]; offs[1][0] = args[1].stencil->stride[0]*1; //unit step in x dimension offs[1][1] = off3D(1, &start[0], &end[0],args[1].dat->size, args[1].stencil->stride) - offs[1][0]; offs[1][2] = off3D(2, &start[0], &end[0],args[1].dat->size, args[1].stencil->stride) - offs[1][1] - offs[1][0]; //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int off0_2 = offs[0][2]; int dat0 = args[0].dat->elem_size; int off1_0 = offs[1][0]; int off1_1 = offs[1][1]; int off1_2 = offs[1][2]; int dat1 = args[1].dat->elem_size; //set up initial pointers and exchange halos if necessary int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0+ dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0+ dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); p_a[0] = (char *)args[0].data + base0; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1+ dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1+ dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); p_a[1] = (char *)args[1].data + base1; p_a[2] = args[2].data; ops_H_D_exchanges_host(args, 3); ops_halo_exchanges(args,3,range); ops_H_D_exchanges_host(args, 3); ops_timers_core(&c1,&t1); OPS_kernels[79].mpi_time += t1-t2; xdim0 = args[0].dat->size[0]*args[0].dat->dim; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]*args[1].dat->dim; ydim1 = args[1].dat->size[1]; int n_x; for ( int n_z=start[2]; n_z<end[2]; n_z++ ){ for ( int n_y=start[1]; n_y<end[1]; n_y++ ){ #pragma novector for( n_x=start[0]; n_x<start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x+=SIMD_VEC ) { //call kernel function, passing in pointers to data -vectorised #pragma simd for ( int i=0; i<SIMD_VEC; i++ ){ update_halo_kernel2_zvel_plus_4_top( (double *)p_a[0]+ i*1, (double *)p_a[1]+ i*1, (int *)p_a[2] ); } //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0)*SIMD_VEC; p_a[1]= p_a[1] + (dat1 * off1_0)*SIMD_VEC; } for ( int n_x=start[0]+((end[0]-start[0])/SIMD_VEC)*SIMD_VEC; n_x<end[0]; n_x++ ){ //call kernel function, passing in pointers to data - remainder update_halo_kernel2_zvel_plus_4_top( (double *)p_a[0], (double *)p_a[1], (int *)p_a[2] ); //shift pointers to data x direction p_a[0]= p_a[0] + (dat0 * off0_0); p_a[1]= p_a[1] + (dat1 * off1_0); } //shift pointers to data y direction p_a[0]= p_a[0] + (dat0 * off0_1); p_a[1]= p_a[1] + (dat1 * off1_1); } //shift pointers to data z direction p_a[0]= p_a[0] + (dat0 * off0_2); p_a[1]= p_a[1] + (dat1 * off1_2); } ops_timers_core(&c2,&t2); OPS_kernels[79].time += t2-t1; ops_set_dirtybit_host(args, 3); ops_set_halo_dirtybit3(&args[0],range); ops_set_halo_dirtybit3(&args[1],range); //Update kernel record OPS_kernels[79].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[79].transfer += ops_compute_transfer(dim, range, &arg1); }
// host stub function void ops_par_loop_PdV_kernel_nopredict( char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7, ops_arg arg8, ops_arg arg9, ops_arg arg10, ops_arg arg11, ops_arg arg12, ops_arg arg13, ops_arg arg14, ops_arg arg15, ops_arg arg16) { ops_arg args[17] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 17, range, 103)) return; #endif ops_timing_realloc(103, "PdV_kernel_nopredict"); OPS_kernels[103].count++; // compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for (int n = 0; n < 3; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); } #else for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]; ydim6 = args[6].dat->size[1]; xdim7 = args[7].dat->size[0]; ydim7 = args[7].dat->size[1]; xdim8 = args[8].dat->size[0]; ydim8 = args[8].dat->size[1]; xdim9 = args[9].dat->size[0]; ydim9 = args[9].dat->size[1]; xdim10 = args[10].dat->size[0]; ydim10 = args[10].dat->size[1]; xdim11 = args[11].dat->size[0]; ydim11 = args[11].dat->size[1]; xdim12 = args[12].dat->size[0]; ydim12 = args[12].dat->size[1]; xdim13 = args[13].dat->size[0]; ydim13 = args[13].dat->size[1]; xdim14 = args[14].dat->size[0]; ydim14 = args[14].dat->size[1]; xdim15 = args[15].dat->size[0]; ydim15 = args[15].dat->size[1]; xdim16 = args[16].dat->size[0]; ydim16 = args[16].dat->size[1]; // Timing double t1, t2, c1, c2; ops_timers_core(&c2, &t2); if (xdim0 != xdim0_PdV_kernel_nopredict_h || ydim0 != ydim0_PdV_kernel_nopredict_h || xdim1 != xdim1_PdV_kernel_nopredict_h || ydim1 != ydim1_PdV_kernel_nopredict_h || xdim2 != xdim2_PdV_kernel_nopredict_h || ydim2 != ydim2_PdV_kernel_nopredict_h || xdim3 != xdim3_PdV_kernel_nopredict_h || ydim3 != ydim3_PdV_kernel_nopredict_h || xdim4 != xdim4_PdV_kernel_nopredict_h || ydim4 != ydim4_PdV_kernel_nopredict_h || xdim5 != xdim5_PdV_kernel_nopredict_h || ydim5 != ydim5_PdV_kernel_nopredict_h || xdim6 != xdim6_PdV_kernel_nopredict_h || ydim6 != ydim6_PdV_kernel_nopredict_h || xdim7 != xdim7_PdV_kernel_nopredict_h || ydim7 != ydim7_PdV_kernel_nopredict_h || xdim8 != xdim8_PdV_kernel_nopredict_h || ydim8 != ydim8_PdV_kernel_nopredict_h || xdim9 != xdim9_PdV_kernel_nopredict_h || ydim9 != ydim9_PdV_kernel_nopredict_h || xdim10 != xdim10_PdV_kernel_nopredict_h || ydim10 != ydim10_PdV_kernel_nopredict_h || xdim11 != xdim11_PdV_kernel_nopredict_h || ydim11 != ydim11_PdV_kernel_nopredict_h || xdim12 != xdim12_PdV_kernel_nopredict_h || ydim12 != ydim12_PdV_kernel_nopredict_h || xdim13 != xdim13_PdV_kernel_nopredict_h || ydim13 != ydim13_PdV_kernel_nopredict_h || xdim14 != xdim14_PdV_kernel_nopredict_h || ydim14 != ydim14_PdV_kernel_nopredict_h || xdim15 != xdim15_PdV_kernel_nopredict_h || ydim15 != ydim15_PdV_kernel_nopredict_h || xdim16 != xdim16_PdV_kernel_nopredict_h || ydim16 != ydim16_PdV_kernel_nopredict_h) { xdim0_PdV_kernel_nopredict = xdim0; xdim0_PdV_kernel_nopredict_h = xdim0; ydim0_PdV_kernel_nopredict = ydim0; ydim0_PdV_kernel_nopredict_h = ydim0; xdim1_PdV_kernel_nopredict = xdim1; xdim1_PdV_kernel_nopredict_h = xdim1; ydim1_PdV_kernel_nopredict = ydim1; ydim1_PdV_kernel_nopredict_h = ydim1; xdim2_PdV_kernel_nopredict = xdim2; xdim2_PdV_kernel_nopredict_h = xdim2; ydim2_PdV_kernel_nopredict = ydim2; ydim2_PdV_kernel_nopredict_h = ydim2; xdim3_PdV_kernel_nopredict = xdim3; xdim3_PdV_kernel_nopredict_h = xdim3; ydim3_PdV_kernel_nopredict = ydim3; ydim3_PdV_kernel_nopredict_h = ydim3; xdim4_PdV_kernel_nopredict = xdim4; xdim4_PdV_kernel_nopredict_h = xdim4; ydim4_PdV_kernel_nopredict = ydim4; ydim4_PdV_kernel_nopredict_h = ydim4; xdim5_PdV_kernel_nopredict = xdim5; xdim5_PdV_kernel_nopredict_h = xdim5; ydim5_PdV_kernel_nopredict = ydim5; ydim5_PdV_kernel_nopredict_h = ydim5; xdim6_PdV_kernel_nopredict = xdim6; xdim6_PdV_kernel_nopredict_h = xdim6; ydim6_PdV_kernel_nopredict = ydim6; ydim6_PdV_kernel_nopredict_h = ydim6; xdim7_PdV_kernel_nopredict = xdim7; xdim7_PdV_kernel_nopredict_h = xdim7; ydim7_PdV_kernel_nopredict = ydim7; ydim7_PdV_kernel_nopredict_h = ydim7; xdim8_PdV_kernel_nopredict = xdim8; xdim8_PdV_kernel_nopredict_h = xdim8; ydim8_PdV_kernel_nopredict = ydim8; ydim8_PdV_kernel_nopredict_h = ydim8; xdim9_PdV_kernel_nopredict = xdim9; xdim9_PdV_kernel_nopredict_h = xdim9; ydim9_PdV_kernel_nopredict = ydim9; ydim9_PdV_kernel_nopredict_h = ydim9; xdim10_PdV_kernel_nopredict = xdim10; xdim10_PdV_kernel_nopredict_h = xdim10; ydim10_PdV_kernel_nopredict = ydim10; ydim10_PdV_kernel_nopredict_h = ydim10; xdim11_PdV_kernel_nopredict = xdim11; xdim11_PdV_kernel_nopredict_h = xdim11; ydim11_PdV_kernel_nopredict = ydim11; ydim11_PdV_kernel_nopredict_h = ydim11; xdim12_PdV_kernel_nopredict = xdim12; xdim12_PdV_kernel_nopredict_h = xdim12; ydim12_PdV_kernel_nopredict = ydim12; ydim12_PdV_kernel_nopredict_h = ydim12; xdim13_PdV_kernel_nopredict = xdim13; xdim13_PdV_kernel_nopredict_h = xdim13; ydim13_PdV_kernel_nopredict = ydim13; ydim13_PdV_kernel_nopredict_h = ydim13; xdim14_PdV_kernel_nopredict = xdim14; xdim14_PdV_kernel_nopredict_h = xdim14; ydim14_PdV_kernel_nopredict = ydim14; ydim14_PdV_kernel_nopredict_h = ydim14; xdim15_PdV_kernel_nopredict = xdim15; xdim15_PdV_kernel_nopredict_h = xdim15; ydim15_PdV_kernel_nopredict = ydim15; ydim15_PdV_kernel_nopredict_h = ydim15; xdim16_PdV_kernel_nopredict = xdim16; xdim16_PdV_kernel_nopredict_h = xdim16; ydim16_PdV_kernel_nopredict = ydim16; ydim16_PdV_kernel_nopredict_h = ydim16; } int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); int dat2 = (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size); int dat3 = (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size); int dat4 = (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size); int dat5 = (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size); int dat6 = (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size); int dat7 = (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size); int dat8 = (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size); int dat9 = (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size); int dat10 = (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size); int dat11 = (OPS_soa ? args[11].dat->type_size : args[11].dat->elem_size); int dat12 = (OPS_soa ? args[12].dat->type_size : args[12].dat->elem_size); int dat13 = (OPS_soa ? args[13].dat->type_size : args[13].dat->elem_size); int dat14 = (OPS_soa ? args[14].dat->type_size : args[14].dat->elem_size); int dat15 = (OPS_soa ? args[15].dat->type_size : args[15].dat->elem_size); int dat16 = (OPS_soa ? args[16].dat->type_size : args[16].dat->elem_size); // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); double *p_a0 = (double *)((char *)args[0].data + base0); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1 + dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); double *p_a1 = (double *)((char *)args[1].data + base1); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif int base2 = dat2 * 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + dat2 * args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2 + dat2 * args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); double *p_a2 = (double *)((char *)args[2].data + base2); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif int base3 = dat3 * 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + dat3 * args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3 + dat3 * args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); double *p_a3 = (double *)((char *)args[3].data + base3); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4 + dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4 + dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); double *p_a4 = (double *)((char *)args[4].data + base4); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif int base5 = dat5 * 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5 + dat5 * args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5 + dat5 * args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); double *p_a5 = (double *)((char *)args[5].data + base5); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif int base6 = dat6 * 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6 + dat6 * args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6 + dat6 * args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); double *p_a6 = (double *)((char *)args[6].data + base6); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d] + OPS_sub_dat_list[args[7].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d]; #endif int base7 = dat7 * 1 * (start[0] * args[7].stencil->stride[0] - args[7].dat->base[0] - d_m[0]); base7 = base7 + dat7 * args[7].dat->size[0] * (start[1] * args[7].stencil->stride[1] - args[7].dat->base[1] - d_m[1]); base7 = base7 + dat7 * args[7].dat->size[0] * args[7].dat->size[1] * (start[2] * args[7].stencil->stride[2] - args[7].dat->base[2] - d_m[2]); double *p_a7 = (double *)((char *)args[7].data + base7); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[8].dat->d_m[d] + OPS_sub_dat_list[args[8].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[8].dat->d_m[d]; #endif int base8 = dat8 * 1 * (start[0] * args[8].stencil->stride[0] - args[8].dat->base[0] - d_m[0]); base8 = base8 + dat8 * args[8].dat->size[0] * (start[1] * args[8].stencil->stride[1] - args[8].dat->base[1] - d_m[1]); base8 = base8 + dat8 * args[8].dat->size[0] * args[8].dat->size[1] * (start[2] * args[8].stencil->stride[2] - args[8].dat->base[2] - d_m[2]); double *p_a8 = (double *)((char *)args[8].data + base8); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[9].dat->d_m[d] + OPS_sub_dat_list[args[9].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[9].dat->d_m[d]; #endif int base9 = dat9 * 1 * (start[0] * args[9].stencil->stride[0] - args[9].dat->base[0] - d_m[0]); base9 = base9 + dat9 * args[9].dat->size[0] * (start[1] * args[9].stencil->stride[1] - args[9].dat->base[1] - d_m[1]); base9 = base9 + dat9 * args[9].dat->size[0] * args[9].dat->size[1] * (start[2] * args[9].stencil->stride[2] - args[9].dat->base[2] - d_m[2]); double *p_a9 = (double *)((char *)args[9].data + base9); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[10].dat->d_m[d] + OPS_sub_dat_list[args[10].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[10].dat->d_m[d]; #endif int base10 = dat10 * 1 * (start[0] * args[10].stencil->stride[0] - args[10].dat->base[0] - d_m[0]); base10 = base10 + dat10 * args[10].dat->size[0] * (start[1] * args[10].stencil->stride[1] - args[10].dat->base[1] - d_m[1]); base10 = base10 + dat10 * args[10].dat->size[0] * args[10].dat->size[1] * (start[2] * args[10].stencil->stride[2] - args[10].dat->base[2] - d_m[2]); double *p_a10 = (double *)((char *)args[10].data + base10); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[11].dat->d_m[d] + OPS_sub_dat_list[args[11].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[11].dat->d_m[d]; #endif int base11 = dat11 * 1 * (start[0] * args[11].stencil->stride[0] - args[11].dat->base[0] - d_m[0]); base11 = base11 + dat11 * args[11].dat->size[0] * (start[1] * args[11].stencil->stride[1] - args[11].dat->base[1] - d_m[1]); base11 = base11 + dat11 * args[11].dat->size[0] * args[11].dat->size[1] * (start[2] * args[11].stencil->stride[2] - args[11].dat->base[2] - d_m[2]); double *p_a11 = (double *)((char *)args[11].data + base11); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[12].dat->d_m[d] + OPS_sub_dat_list[args[12].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[12].dat->d_m[d]; #endif int base12 = dat12 * 1 * (start[0] * args[12].stencil->stride[0] - args[12].dat->base[0] - d_m[0]); base12 = base12 + dat12 * args[12].dat->size[0] * (start[1] * args[12].stencil->stride[1] - args[12].dat->base[1] - d_m[1]); base12 = base12 + dat12 * args[12].dat->size[0] * args[12].dat->size[1] * (start[2] * args[12].stencil->stride[2] - args[12].dat->base[2] - d_m[2]); double *p_a12 = (double *)((char *)args[12].data + base12); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[13].dat->d_m[d] + OPS_sub_dat_list[args[13].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[13].dat->d_m[d]; #endif int base13 = dat13 * 1 * (start[0] * args[13].stencil->stride[0] - args[13].dat->base[0] - d_m[0]); base13 = base13 + dat13 * args[13].dat->size[0] * (start[1] * args[13].stencil->stride[1] - args[13].dat->base[1] - d_m[1]); base13 = base13 + dat13 * args[13].dat->size[0] * args[13].dat->size[1] * (start[2] * args[13].stencil->stride[2] - args[13].dat->base[2] - d_m[2]); double *p_a13 = (double *)((char *)args[13].data + base13); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[14].dat->d_m[d] + OPS_sub_dat_list[args[14].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[14].dat->d_m[d]; #endif int base14 = dat14 * 1 * (start[0] * args[14].stencil->stride[0] - args[14].dat->base[0] - d_m[0]); base14 = base14 + dat14 * args[14].dat->size[0] * (start[1] * args[14].stencil->stride[1] - args[14].dat->base[1] - d_m[1]); base14 = base14 + dat14 * args[14].dat->size[0] * args[14].dat->size[1] * (start[2] * args[14].stencil->stride[2] - args[14].dat->base[2] - d_m[2]); double *p_a14 = (double *)((char *)args[14].data + base14); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[15].dat->d_m[d] + OPS_sub_dat_list[args[15].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[15].dat->d_m[d]; #endif int base15 = dat15 * 1 * (start[0] * args[15].stencil->stride[0] - args[15].dat->base[0] - d_m[0]); base15 = base15 + dat15 * args[15].dat->size[0] * (start[1] * args[15].stencil->stride[1] - args[15].dat->base[1] - d_m[1]); base15 = base15 + dat15 * args[15].dat->size[0] * args[15].dat->size[1] * (start[2] * args[15].stencil->stride[2] - args[15].dat->base[2] - d_m[2]); double *p_a15 = (double *)((char *)args[15].data + base15); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[16].dat->d_m[d] + OPS_sub_dat_list[args[16].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[16].dat->d_m[d]; #endif int base16 = dat16 * 1 * (start[0] * args[16].stencil->stride[0] - args[16].dat->base[0] - d_m[0]); base16 = base16 + dat16 * args[16].dat->size[0] * (start[1] * args[16].stencil->stride[1] - args[16].dat->base[1] - d_m[1]); base16 = base16 + dat16 * args[16].dat->size[0] * args[16].dat->size[1] * (start[2] * args[16].stencil->stride[2] - args[16].dat->base[2] - d_m[2]); double *p_a16 = (double *)((char *)args[16].data + base16); ops_H_D_exchanges_host(args, 17); ops_halo_exchanges(args, 17, range); ops_timers_core(&c1, &t1); OPS_kernels[103].mpi_time += t1 - t2; PdV_kernel_nopredict_c_wrapper(p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, p_a6, p_a7, p_a8, p_a9, p_a10, p_a11, p_a12, p_a13, p_a14, p_a15, p_a16, x_size, y_size, z_size); ops_timers_core(&c2, &t2); OPS_kernels[103].time += t2 - t1; ops_set_dirtybit_host(args, 17); ops_set_halo_dirtybit3(&args[6], range); ops_set_halo_dirtybit3(&args[10], range); ops_set_halo_dirtybit3(&args[13], range); // Update kernel record OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg5); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg6); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg7); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg8); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg9); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg10); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg11); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg12); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg13); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg14); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg15); OPS_kernels[103].transfer += ops_compute_transfer(dim, start, end, &arg16); }
// host stub function void ops_par_loop_update_halo_kernel1_ba2(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7) { // Timing double t1, t2, c1, c2; int offs[8][3]; ops_arg args[8] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 8, range, 20)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(20, "update_halo_kernel1_ba2"); OPS_kernels[20].count++; ops_timers_core(&c1, &t1); } #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // compute locally allocated range for the sub-block int start[3]; int end[3]; int arg_idx[3]; #ifdef OPS_MPI if (!sb->owned) return; for (int n = 0; n < 3; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); if (end[n] < start[n]) end[n] = start[n]; } #else for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif #ifdef OPS_DEBUG ops_register_args(args, "update_halo_kernel1_ba2"); #endif offs[0][0] = args[0].stencil->stride[0] * 1; // unit step in x dimension offs[0][1] = off3D(1, &start[0], &end[0], args[0].dat->size, args[0].stencil->stride) - offs[0][0]; offs[0][2] = off3D(2, &start[0], &end[0], args[0].dat->size, args[0].stencil->stride) - offs[0][1] - offs[0][0]; offs[1][0] = args[1].stencil->stride[0] * 1; // unit step in x dimension offs[1][1] = off3D(1, &start[0], &end[0], args[1].dat->size, args[1].stencil->stride) - offs[1][0]; offs[1][2] = off3D(2, &start[0], &end[0], args[1].dat->size, args[1].stencil->stride) - offs[1][1] - offs[1][0]; offs[2][0] = args[2].stencil->stride[0] * 1; // unit step in x dimension offs[2][1] = off3D(1, &start[0], &end[0], args[2].dat->size, args[2].stencil->stride) - offs[2][0]; offs[2][2] = off3D(2, &start[0], &end[0], args[2].dat->size, args[2].stencil->stride) - offs[2][1] - offs[2][0]; offs[3][0] = args[3].stencil->stride[0] * 1; // unit step in x dimension offs[3][1] = off3D(1, &start[0], &end[0], args[3].dat->size, args[3].stencil->stride) - offs[3][0]; offs[3][2] = off3D(2, &start[0], &end[0], args[3].dat->size, args[3].stencil->stride) - offs[3][1] - offs[3][0]; offs[4][0] = args[4].stencil->stride[0] * 1; // unit step in x dimension offs[4][1] = off3D(1, &start[0], &end[0], args[4].dat->size, args[4].stencil->stride) - offs[4][0]; offs[4][2] = off3D(2, &start[0], &end[0], args[4].dat->size, args[4].stencil->stride) - offs[4][1] - offs[4][0]; offs[5][0] = args[5].stencil->stride[0] * 1; // unit step in x dimension offs[5][1] = off3D(1, &start[0], &end[0], args[5].dat->size, args[5].stencil->stride) - offs[5][0]; offs[5][2] = off3D(2, &start[0], &end[0], args[5].dat->size, args[5].stencil->stride) - offs[5][1] - offs[5][0]; offs[6][0] = args[6].stencil->stride[0] * 1; // unit step in x dimension offs[6][1] = off3D(1, &start[0], &end[0], args[6].dat->size, args[6].stencil->stride) - offs[6][0]; offs[6][2] = off3D(2, &start[0], &end[0], args[6].dat->size, args[6].stencil->stride) - offs[6][1] - offs[6][0]; int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int off0_2 = offs[0][2]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int off1_0 = offs[1][0]; int off1_1 = offs[1][1]; int off1_2 = offs[1][2]; int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); int off2_0 = offs[2][0]; int off2_1 = offs[2][1]; int off2_2 = offs[2][2]; int dat2 = (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size); int off3_0 = offs[3][0]; int off3_1 = offs[3][1]; int off3_2 = offs[3][2]; int dat3 = (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size); int off4_0 = offs[4][0]; int off4_1 = offs[4][1]; int off4_2 = offs[4][2]; int dat4 = (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size); int off5_0 = offs[5][0]; int off5_1 = offs[5][1]; int off5_2 = offs[5][2]; int dat5 = (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size); int off6_0 = offs[6][0]; int off6_1 = offs[6][1]; int off6_2 = offs[6][2]; int dat6 = (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size); // Halo Exchanges ops_H_D_exchanges_host(args, 8); ops_halo_exchanges(args, 8, range); ops_H_D_exchanges_host(args, 8); #ifdef _OPENMP int nthreads = omp_get_max_threads(); #else int nthreads = 1; #endif xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]; ydim6 = args[6].dat->size[1]; if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[20].mpi_time += t2 - t1; } #pragma omp parallel for for (int thr = 0; thr < nthreads; thr++) { int z_size = end[2] - start[2]; char *p_a[8]; int start_i = start[2] + ((z_size - 1) / nthreads + 1) * thr; int finish_i = start[2] + MIN(((z_size - 1) / nthreads + 1) * (thr + 1), z_size); // get address per thread int start0 = start[0]; int start1 = start[1]; int start2 = start_i; // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = dat0 * 1 * (start0 * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + dat0 * args[0].dat->size[0] * (start1 * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + dat0 * args[0].dat->size[0] * args[0].dat->size[1] * (start2 * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); p_a[0] = (char *)args[0].data + base0; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif int base1 = dat1 * 1 * (start0 * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + dat1 * args[1].dat->size[0] * (start1 * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1 + dat1 * args[1].dat->size[0] * args[1].dat->size[1] * (start2 * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); p_a[1] = (char *)args[1].data + base1; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif int base2 = dat2 * 1 * (start0 * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + dat2 * args[2].dat->size[0] * (start1 * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2 + dat2 * args[2].dat->size[0] * args[2].dat->size[1] * (start2 * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); p_a[2] = (char *)args[2].data + base2; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif int base3 = dat3 * 1 * (start0 * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + dat3 * args[3].dat->size[0] * (start1 * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3 + dat3 * args[3].dat->size[0] * args[3].dat->size[1] * (start2 * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); p_a[3] = (char *)args[3].data + base3; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif int base4 = dat4 * 1 * (start0 * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4 + dat4 * args[4].dat->size[0] * (start1 * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4 + dat4 * args[4].dat->size[0] * args[4].dat->size[1] * (start2 * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); p_a[4] = (char *)args[4].data + base4; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif int base5 = dat5 * 1 * (start0 * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5 + dat5 * args[5].dat->size[0] * (start1 * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5 + dat5 * args[5].dat->size[0] * args[5].dat->size[1] * (start2 * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); p_a[5] = (char *)args[5].data + base5; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif int base6 = dat6 * 1 * (start0 * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6 + dat6 * args[6].dat->size[0] * (start1 * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6 + dat6 * args[6].dat->size[0] * args[6].dat->size[1] * (start2 * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); p_a[6] = (char *)args[6].data + base6; p_a[7] = (char *)args[7].data; for (int n_z = start_i; n_z < finish_i; n_z++) { for (int n_y = start[1]; n_y < end[1]; n_y++) { for (int n_x = start[0]; n_x < start[0] + (end[0] - start[0]) / SIMD_VEC; n_x++) { // call kernel function, passing in pointers to data -vectorised #pragma simd for (int i = 0; i < SIMD_VEC; i++) { update_halo_kernel1_ba2( (double *)p_a[0] + i * 1 * 1, (double *)p_a[1] + i * 1 * 1, (double *)p_a[2] + i * 1 * 1, (double *)p_a[3] + i * 1 * 1, (double *)p_a[4] + i * 1 * 1, (double *)p_a[5] + i * 1 * 1, (double *)p_a[6] + i * 1 * 1, (int *)p_a[7]); } // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0) * SIMD_VEC; p_a[1] = p_a[1] + (dat1 * off1_0) * SIMD_VEC; p_a[2] = p_a[2] + (dat2 * off2_0) * SIMD_VEC; p_a[3] = p_a[3] + (dat3 * off3_0) * SIMD_VEC; p_a[4] = p_a[4] + (dat4 * off4_0) * SIMD_VEC; p_a[5] = p_a[5] + (dat5 * off5_0) * SIMD_VEC; p_a[6] = p_a[6] + (dat6 * off6_0) * SIMD_VEC; } for (int n_x = start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x < end[0]; n_x++) { // call kernel function, passing in pointers to data - remainder update_halo_kernel1_ba2((double *)p_a[0], (double *)p_a[1], (double *)p_a[2], (double *)p_a[3], (double *)p_a[4], (double *)p_a[5], (double *)p_a[6], (int *)p_a[7]); // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0); p_a[1] = p_a[1] + (dat1 * off1_0); p_a[2] = p_a[2] + (dat2 * off2_0); p_a[3] = p_a[3] + (dat3 * off3_0); p_a[4] = p_a[4] + (dat4 * off4_0); p_a[5] = p_a[5] + (dat5 * off5_0); p_a[6] = p_a[6] + (dat6 * off6_0); } // shift pointers to data y direction p_a[0] = p_a[0] + (dat0 * off0_1); p_a[1] = p_a[1] + (dat1 * off1_1); p_a[2] = p_a[2] + (dat2 * off2_1); p_a[3] = p_a[3] + (dat3 * off3_1); p_a[4] = p_a[4] + (dat4 * off4_1); p_a[5] = p_a[5] + (dat5 * off5_1); p_a[6] = p_a[6] + (dat6 * off6_1); } // shift pointers to data z direction p_a[0] = p_a[0] + (dat0 * off0_2); p_a[1] = p_a[1] + (dat1 * off1_2); p_a[2] = p_a[2] + (dat2 * off2_2); p_a[3] = p_a[3] + (dat3 * off3_2); p_a[4] = p_a[4] + (dat4 * off4_2); p_a[5] = p_a[5] + (dat5 * off5_2); p_a[6] = p_a[6] + (dat6 * off6_2); } } if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[20].time += t1 - t2; } ops_set_dirtybit_host(args, 8); ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); ops_set_halo_dirtybit3(&args[2], range); ops_set_halo_dirtybit3(&args[3], range); ops_set_halo_dirtybit3(&args[4], range); ops_set_halo_dirtybit3(&args[5], range); ops_set_halo_dirtybit3(&args[6], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[20].mpi_time += t2 - t1; OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg5); OPS_kernels[20].transfer += ops_compute_transfer(dim, start, end, &arg6); } }
// host stub function void ops_par_loop_update_halo_kernel1_b2(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7) { // Timing double t1, t2, c1, c2; ops_arg args[8] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 8, range, 12)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(12, "update_halo_kernel1_b2"); OPS_kernels[12].count++; ops_timers_core(&c1, &t1); } // compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // OPS_MPI int arg_idx[3]; int arg_idx_base[3]; #ifdef OPS_MPI if (compute_ranges(args, 8, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif for (int n = 0; n < 3; n++) { arg_idx_base[n] = arg_idx[n]; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; int dat5 = args[5].dat->elem_size; int dat6 = args[6].dat->elem_size; int *arg7h = (int *)arg7.data; // Upload large globals #ifdef OPS_GPU int consts_bytes = 0; consts_bytes += ROUND_UP(NUM_FIELDS * sizeof(int)); reallocConstArrays(consts_bytes); consts_bytes = 0; args[7].data = OPS_consts_h + consts_bytes; args[7].data_d = OPS_consts_d + consts_bytes; for (int d = 0; d < NUM_FIELDS; d++) ((int *)args[7].data)[d] = arg7h[d]; consts_bytes += ROUND_UP(NUM_FIELDS * sizeof(int)); mvConstArraysToDevice(consts_bytes); #endif // OPS_GPU // set up initial pointers int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * args[0].dat->size[1] * start[2] * args[0].stencil->stride[2]; #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * start[1] * args[1].stencil->stride[1]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * args[1].dat->size[1] * start[2] * args[1].stencil->stride[2]; #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif int base2 = args[2].dat->base_offset + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * start[0] * args[2].stencil->stride[0]; base2 = base2 + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * start[1] * args[2].stencil->stride[1]; base2 = base2 + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * args[2].dat->size[1] * start[2] * args[2].stencil->stride[2]; #ifdef OPS_GPU double *p_a2 = (double *)((char *)args[2].data_d + base2); #else double *p_a2 = (double *)((char *)args[2].data + base2); #endif int base3 = args[3].dat->base_offset + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * start[0] * args[3].stencil->stride[0]; base3 = base3 + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * start[1] * args[3].stencil->stride[1]; base3 = base3 + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * args[3].dat->size[1] * start[2] * args[3].stencil->stride[2]; #ifdef OPS_GPU double *p_a3 = (double *)((char *)args[3].data_d + base3); #else double *p_a3 = (double *)((char *)args[3].data + base3); #endif int base4 = args[4].dat->base_offset + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * start[0] * args[4].stencil->stride[0]; base4 = base4 + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * start[1] * args[4].stencil->stride[1]; base4 = base4 + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * args[4].dat->size[1] * start[2] * args[4].stencil->stride[2]; #ifdef OPS_GPU double *p_a4 = (double *)((char *)args[4].data_d + base4); #else double *p_a4 = (double *)((char *)args[4].data + base4); #endif int base5 = args[5].dat->base_offset + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * start[0] * args[5].stencil->stride[0]; base5 = base5 + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * args[5].dat->size[0] * start[1] * args[5].stencil->stride[1]; base5 = base5 + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * args[5].dat->size[0] * args[5].dat->size[1] * start[2] * args[5].stencil->stride[2]; #ifdef OPS_GPU double *p_a5 = (double *)((char *)args[5].data_d + base5); #else double *p_a5 = (double *)((char *)args[5].data + base5); #endif int base6 = args[6].dat->base_offset + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * start[0] * args[6].stencil->stride[0]; base6 = base6 + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * args[6].dat->size[0] * start[1] * args[6].stencil->stride[1]; base6 = base6 + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * args[6].dat->size[0] * args[6].dat->size[1] * start[2] * args[6].stencil->stride[2]; #ifdef OPS_GPU double *p_a6 = (double *)((char *)args[6].data_d + base6); #else double *p_a6 = (double *)((char *)args[6].data + base6); #endif #ifdef OPS_GPU int *p_a7 = (int *)args[7].data_d; #else int *p_a7 = arg7h; #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]; ydim6 = args[6].dat->size[1]; if (xdim0 != xdim0_update_halo_kernel1_b2_h || ydim0 != ydim0_update_halo_kernel1_b2_h || xdim1 != xdim1_update_halo_kernel1_b2_h || ydim1 != ydim1_update_halo_kernel1_b2_h || xdim2 != xdim2_update_halo_kernel1_b2_h || ydim2 != ydim2_update_halo_kernel1_b2_h || xdim3 != xdim3_update_halo_kernel1_b2_h || ydim3 != ydim3_update_halo_kernel1_b2_h || xdim4 != xdim4_update_halo_kernel1_b2_h || ydim4 != ydim4_update_halo_kernel1_b2_h || xdim5 != xdim5_update_halo_kernel1_b2_h || ydim5 != ydim5_update_halo_kernel1_b2_h || xdim6 != xdim6_update_halo_kernel1_b2_h || ydim6 != ydim6_update_halo_kernel1_b2_h) { xdim0_update_halo_kernel1_b2 = xdim0; xdim0_update_halo_kernel1_b2_h = xdim0; ydim0_update_halo_kernel1_b2 = ydim0; ydim0_update_halo_kernel1_b2_h = ydim0; xdim1_update_halo_kernel1_b2 = xdim1; xdim1_update_halo_kernel1_b2_h = xdim1; ydim1_update_halo_kernel1_b2 = ydim1; ydim1_update_halo_kernel1_b2_h = ydim1; xdim2_update_halo_kernel1_b2 = xdim2; xdim2_update_halo_kernel1_b2_h = xdim2; ydim2_update_halo_kernel1_b2 = ydim2; ydim2_update_halo_kernel1_b2_h = ydim2; xdim3_update_halo_kernel1_b2 = xdim3; xdim3_update_halo_kernel1_b2_h = xdim3; ydim3_update_halo_kernel1_b2 = ydim3; ydim3_update_halo_kernel1_b2_h = ydim3; xdim4_update_halo_kernel1_b2 = xdim4; xdim4_update_halo_kernel1_b2_h = xdim4; ydim4_update_halo_kernel1_b2 = ydim4; ydim4_update_halo_kernel1_b2_h = ydim4; xdim5_update_halo_kernel1_b2 = xdim5; xdim5_update_halo_kernel1_b2_h = xdim5; ydim5_update_halo_kernel1_b2 = ydim5; ydim5_update_halo_kernel1_b2_h = ydim5; xdim6_update_halo_kernel1_b2 = xdim6; xdim6_update_halo_kernel1_b2_h = xdim6; ydim6_update_halo_kernel1_b2 = ydim6; ydim6_update_halo_kernel1_b2_h = ydim6; } // Halo Exchanges #ifdef OPS_GPU ops_H_D_exchanges_device(args, 8); #else ops_H_D_exchanges_host(args, 8); #endif ops_halo_exchanges(args, 8, range); #ifdef OPS_GPU ops_H_D_exchanges_device(args, 8); #else ops_H_D_exchanges_host(args, 8); #endif if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[12].mpi_time += t2 - t1; } update_halo_kernel1_b2_c_wrapper(p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, p_a6, p_a7, x_size, y_size, z_size); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[12].time += t1 - t2; } #ifdef OPS_GPU ops_set_dirtybit_device(args, 8); #else ops_set_dirtybit_host(args, 8); #endif ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); ops_set_halo_dirtybit3(&args[2], range); ops_set_halo_dirtybit3(&args[3], range); ops_set_halo_dirtybit3(&args[4], range); ops_set_halo_dirtybit3(&args[5], range); ops_set_halo_dirtybit3(&args[6], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[12].mpi_time += t2 - t1; OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg5); OPS_kernels[12].transfer += ops_compute_transfer(dim, start, end, &arg6); } }
// host stub function void ops_par_loop_generate_chunk_kernel( char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7, ops_arg arg8, ops_arg arg9, ops_arg arg10) { // Timing double t1, t2, c1, c2; ops_arg args[11] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 11, range, 10)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(10, "generate_chunk_kernel"); OPS_kernels[10].count++; ops_timers_core(&c1, &t1); } // compute localy allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // OPS_MPI int arg_idx[3]; int arg_idx_base[3]; #ifdef OPS_MPI if (compute_ranges(args, 11, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 3; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif for (int n = 0; n < 3; n++) { arg_idx_base[n] = arg_idx[n]; } int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; int dat5 = args[5].dat->elem_size; int dat6 = args[6].dat->elem_size; int dat7 = args[7].dat->elem_size; int dat8 = args[8].dat->elem_size; int dat9 = args[9].dat->elem_size; int dat10 = args[10].dat->elem_size; // set up initial pointers int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * start[1] * args[0].stencil->stride[1]; base0 = base0 + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * args[0].dat->size[0] * args[0].dat->size[1] * start[2] * args[0].stencil->stride[2]; #ifdef OPS_GPU double *p_a0 = (double *)((char *)args[0].data_d + base0); #else double *p_a0 = (double *)((char *)args[0].data + base0); #endif int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * start[1] * args[1].stencil->stride[1]; base1 = base1 + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * args[1].dat->size[0] * args[1].dat->size[1] * start[2] * args[1].stencil->stride[2]; #ifdef OPS_GPU double *p_a1 = (double *)((char *)args[1].data_d + base1); #else double *p_a1 = (double *)((char *)args[1].data + base1); #endif int base2 = args[2].dat->base_offset + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * start[0] * args[2].stencil->stride[0]; base2 = base2 + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * start[1] * args[2].stencil->stride[1]; base2 = base2 + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * args[2].dat->size[0] * args[2].dat->size[1] * start[2] * args[2].stencil->stride[2]; #ifdef OPS_GPU double *p_a2 = (double *)((char *)args[2].data_d + base2); #else double *p_a2 = (double *)((char *)args[2].data + base2); #endif int base3 = args[3].dat->base_offset + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * start[0] * args[3].stencil->stride[0]; base3 = base3 + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * start[1] * args[3].stencil->stride[1]; base3 = base3 + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * args[3].dat->size[0] * args[3].dat->size[1] * start[2] * args[3].stencil->stride[2]; #ifdef OPS_GPU double *p_a3 = (double *)((char *)args[3].data_d + base3); #else double *p_a3 = (double *)((char *)args[3].data + base3); #endif int base4 = args[4].dat->base_offset + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * start[0] * args[4].stencil->stride[0]; base4 = base4 + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * start[1] * args[4].stencil->stride[1]; base4 = base4 + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * args[4].dat->size[0] * args[4].dat->size[1] * start[2] * args[4].stencil->stride[2]; #ifdef OPS_GPU double *p_a4 = (double *)((char *)args[4].data_d + base4); #else double *p_a4 = (double *)((char *)args[4].data + base4); #endif int base5 = args[5].dat->base_offset + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * start[0] * args[5].stencil->stride[0]; base5 = base5 + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * args[5].dat->size[0] * start[1] * args[5].stencil->stride[1]; base5 = base5 + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * args[5].dat->size[0] * args[5].dat->size[1] * start[2] * args[5].stencil->stride[2]; #ifdef OPS_GPU double *p_a5 = (double *)((char *)args[5].data_d + base5); #else double *p_a5 = (double *)((char *)args[5].data + base5); #endif int base6 = args[6].dat->base_offset + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * start[0] * args[6].stencil->stride[0]; base6 = base6 + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * args[6].dat->size[0] * start[1] * args[6].stencil->stride[1]; base6 = base6 + (OPS_soa ? args[6].dat->type_size : args[6].dat->elem_size) * args[6].dat->size[0] * args[6].dat->size[1] * start[2] * args[6].stencil->stride[2]; #ifdef OPS_GPU double *p_a6 = (double *)((char *)args[6].data_d + base6); #else double *p_a6 = (double *)((char *)args[6].data + base6); #endif int base7 = args[7].dat->base_offset + (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size) * start[0] * args[7].stencil->stride[0]; base7 = base7 + (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size) * args[7].dat->size[0] * start[1] * args[7].stencil->stride[1]; base7 = base7 + (OPS_soa ? args[7].dat->type_size : args[7].dat->elem_size) * args[7].dat->size[0] * args[7].dat->size[1] * start[2] * args[7].stencil->stride[2]; #ifdef OPS_GPU double *p_a7 = (double *)((char *)args[7].data_d + base7); #else double *p_a7 = (double *)((char *)args[7].data + base7); #endif int base8 = args[8].dat->base_offset + (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size) * start[0] * args[8].stencil->stride[0]; base8 = base8 + (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size) * args[8].dat->size[0] * start[1] * args[8].stencil->stride[1]; base8 = base8 + (OPS_soa ? args[8].dat->type_size : args[8].dat->elem_size) * args[8].dat->size[0] * args[8].dat->size[1] * start[2] * args[8].stencil->stride[2]; #ifdef OPS_GPU double *p_a8 = (double *)((char *)args[8].data_d + base8); #else double *p_a8 = (double *)((char *)args[8].data + base8); #endif int base9 = args[9].dat->base_offset + (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size) * start[0] * args[9].stencil->stride[0]; base9 = base9 + (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size) * args[9].dat->size[0] * start[1] * args[9].stencil->stride[1]; base9 = base9 + (OPS_soa ? args[9].dat->type_size : args[9].dat->elem_size) * args[9].dat->size[0] * args[9].dat->size[1] * start[2] * args[9].stencil->stride[2]; #ifdef OPS_GPU double *p_a9 = (double *)((char *)args[9].data_d + base9); #else double *p_a9 = (double *)((char *)args[9].data + base9); #endif int base10 = args[10].dat->base_offset + (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size) * start[0] * args[10].stencil->stride[0]; base10 = base10 + (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size) * args[10].dat->size[0] * start[1] * args[10].stencil->stride[1]; base10 = base10 + (OPS_soa ? args[10].dat->type_size : args[10].dat->elem_size) * args[10].dat->size[0] * args[10].dat->size[1] * start[2] * args[10].stencil->stride[2]; #ifdef OPS_GPU double *p_a10 = (double *)((char *)args[10].data_d + base10); #else double *p_a10 = (double *)((char *)args[10].data + base10); #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); int z_size = MAX(0, end[2] - start[2]); // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; ydim0 = args[0].dat->size[1]; xdim1 = args[1].dat->size[0]; ydim1 = args[1].dat->size[1]; xdim2 = args[2].dat->size[0]; ydim2 = args[2].dat->size[1]; xdim3 = args[3].dat->size[0]; ydim3 = args[3].dat->size[1]; xdim4 = args[4].dat->size[0]; ydim4 = args[4].dat->size[1]; xdim5 = args[5].dat->size[0]; ydim5 = args[5].dat->size[1]; xdim6 = args[6].dat->size[0]; ydim6 = args[6].dat->size[1]; xdim7 = args[7].dat->size[0]; ydim7 = args[7].dat->size[1]; xdim8 = args[8].dat->size[0]; ydim8 = args[8].dat->size[1]; xdim9 = args[9].dat->size[0]; ydim9 = args[9].dat->size[1]; xdim10 = args[10].dat->size[0]; ydim10 = args[10].dat->size[1]; if (xdim0 != xdim0_generate_chunk_kernel_h || ydim0 != ydim0_generate_chunk_kernel_h || xdim1 != xdim1_generate_chunk_kernel_h || ydim1 != ydim1_generate_chunk_kernel_h || xdim2 != xdim2_generate_chunk_kernel_h || ydim2 != ydim2_generate_chunk_kernel_h || xdim3 != xdim3_generate_chunk_kernel_h || ydim3 != ydim3_generate_chunk_kernel_h || xdim4 != xdim4_generate_chunk_kernel_h || ydim4 != ydim4_generate_chunk_kernel_h || xdim5 != xdim5_generate_chunk_kernel_h || ydim5 != ydim5_generate_chunk_kernel_h || xdim6 != xdim6_generate_chunk_kernel_h || ydim6 != ydim6_generate_chunk_kernel_h || xdim7 != xdim7_generate_chunk_kernel_h || ydim7 != ydim7_generate_chunk_kernel_h || xdim8 != xdim8_generate_chunk_kernel_h || ydim8 != ydim8_generate_chunk_kernel_h || xdim9 != xdim9_generate_chunk_kernel_h || ydim9 != ydim9_generate_chunk_kernel_h || xdim10 != xdim10_generate_chunk_kernel_h || ydim10 != ydim10_generate_chunk_kernel_h) { xdim0_generate_chunk_kernel = xdim0; xdim0_generate_chunk_kernel_h = xdim0; ydim0_generate_chunk_kernel = ydim0; ydim0_generate_chunk_kernel_h = ydim0; xdim1_generate_chunk_kernel = xdim1; xdim1_generate_chunk_kernel_h = xdim1; ydim1_generate_chunk_kernel = ydim1; ydim1_generate_chunk_kernel_h = ydim1; xdim2_generate_chunk_kernel = xdim2; xdim2_generate_chunk_kernel_h = xdim2; ydim2_generate_chunk_kernel = ydim2; ydim2_generate_chunk_kernel_h = ydim2; xdim3_generate_chunk_kernel = xdim3; xdim3_generate_chunk_kernel_h = xdim3; ydim3_generate_chunk_kernel = ydim3; ydim3_generate_chunk_kernel_h = ydim3; xdim4_generate_chunk_kernel = xdim4; xdim4_generate_chunk_kernel_h = xdim4; ydim4_generate_chunk_kernel = ydim4; ydim4_generate_chunk_kernel_h = ydim4; xdim5_generate_chunk_kernel = xdim5; xdim5_generate_chunk_kernel_h = xdim5; ydim5_generate_chunk_kernel = ydim5; ydim5_generate_chunk_kernel_h = ydim5; xdim6_generate_chunk_kernel = xdim6; xdim6_generate_chunk_kernel_h = xdim6; ydim6_generate_chunk_kernel = ydim6; ydim6_generate_chunk_kernel_h = ydim6; xdim7_generate_chunk_kernel = xdim7; xdim7_generate_chunk_kernel_h = xdim7; ydim7_generate_chunk_kernel = ydim7; ydim7_generate_chunk_kernel_h = ydim7; xdim8_generate_chunk_kernel = xdim8; xdim8_generate_chunk_kernel_h = xdim8; ydim8_generate_chunk_kernel = ydim8; ydim8_generate_chunk_kernel_h = ydim8; xdim9_generate_chunk_kernel = xdim9; xdim9_generate_chunk_kernel_h = xdim9; ydim9_generate_chunk_kernel = ydim9; ydim9_generate_chunk_kernel_h = ydim9; xdim10_generate_chunk_kernel = xdim10; xdim10_generate_chunk_kernel_h = xdim10; ydim10_generate_chunk_kernel = ydim10; ydim10_generate_chunk_kernel_h = ydim10; } // Halo Exchanges #ifdef OPS_GPU ops_H_D_exchanges_device(args, 11); #else ops_H_D_exchanges_host(args, 11); #endif ops_halo_exchanges(args, 11, range); #ifdef OPS_GPU ops_H_D_exchanges_device(args, 11); #else ops_H_D_exchanges_host(args, 11); #endif if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[10].mpi_time += t2 - t1; } generate_chunk_kernel_c_wrapper(p_a0, p_a1, p_a2, p_a3, p_a4, p_a5, p_a6, p_a7, p_a8, p_a9, p_a10, x_size, y_size, z_size); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[10].time += t1 - t2; } #ifdef OPS_GPU ops_set_dirtybit_device(args, 11); #else ops_set_dirtybit_host(args, 11); #endif ops_set_halo_dirtybit3(&args[3], range); ops_set_halo_dirtybit3(&args[4], range); ops_set_halo_dirtybit3(&args[5], range); ops_set_halo_dirtybit3(&args[6], range); ops_set_halo_dirtybit3(&args[7], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[10].mpi_time += t2 - t1; OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg5); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg6); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg7); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg8); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg9); OPS_kernels[10].transfer += ops_compute_transfer(dim, start, end, &arg10); } }
// host stub function void ops_par_loop_save_kernel(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5) { // Timing double t1, t2, c1, c2; char *p_a[6]; int offs[6][1]; ops_arg args[6] = {arg0, arg1, arg2, arg3, arg4, arg5}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 6, range, 1)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(1, "save_kernel"); OPS_kernels[1].count++; ops_timers_core(&c2, &t2); } // compute locally allocated range for the sub-block int start[1]; int end[1]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif #ifdef OPS_DEBUG ops_register_args(args, "save_kernel"); #endif int arg_idx[1]; int arg_idx_base[1]; #ifdef OPS_MPI if (compute_ranges(args, 6, block, range, start, end, arg_idx) < 0) return; #else // OPS_MPI for (int n = 0; n < 1; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; arg_idx[n] = start[n]; } #endif // OPS_MPI for (int n = 0; n < 1; n++) { arg_idx_base[n] = arg_idx[n]; } offs[0][0] = args[0].stencil->stride[0] * 1; // unit step in x dimension offs[1][0] = args[1].stencil->stride[0] * 1; // unit step in x dimension offs[2][0] = args[2].stencil->stride[0] * 1; // unit step in x dimension offs[3][0] = args[3].stencil->stride[0] * 1; // unit step in x dimension offs[4][0] = args[4].stencil->stride[0] * 1; // unit step in x dimension offs[5][0] = args[5].stencil->stride[0] * 1; // unit step in x dimension int off0_0 = offs[0][0]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int off1_0 = offs[1][0]; int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); int off2_0 = offs[2][0]; int dat2 = (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size); int off3_0 = offs[3][0]; int dat3 = (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size); int off4_0 = offs[4][0]; int dat4 = (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size); int off5_0 = offs[5][0]; int dat5 = (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size); // set up initial pointers and exchange halos if necessary int base0 = args[0].dat->base_offset + (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size) * start[0] * args[0].stencil->stride[0]; p_a[0] = (char *)args[0].data + base0; int base1 = args[1].dat->base_offset + (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size) * start[0] * args[1].stencil->stride[0]; p_a[1] = (char *)args[1].data + base1; int base2 = args[2].dat->base_offset + (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size) * start[0] * args[2].stencil->stride[0]; p_a[2] = (char *)args[2].data + base2; int base3 = args[3].dat->base_offset + (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size) * start[0] * args[3].stencil->stride[0]; p_a[3] = (char *)args[3].data + base3; int base4 = args[4].dat->base_offset + (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size) * start[0] * args[4].stencil->stride[0]; p_a[4] = (char *)args[4].data + base4; int base5 = args[5].dat->base_offset + (OPS_soa ? args[5].dat->type_size : args[5].dat->elem_size) * start[0] * args[5].stencil->stride[0]; p_a[5] = (char *)args[5].data + base5; // initialize global variable with the dimension of dats xdim0 = args[0].dat->size[0]; xdim1 = args[1].dat->size[0]; xdim2 = args[2].dat->size[0]; xdim3 = args[3].dat->size[0]; xdim4 = args[4].dat->size[0]; xdim5 = args[5].dat->size[0]; // Halo Exchanges ops_H_D_exchanges_host(args, 6); ops_halo_exchanges(args, 6, range); ops_H_D_exchanges_host(args, 6); if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[1].mpi_time += t1 - t2; } int n_x; #pragma novector for (n_x = start[0]; n_x < start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x += SIMD_VEC) { // call kernel function, passing in pointers to data -vectorised #pragma simd for (int i = 0; i < SIMD_VEC; i++) { save_kernel((double *)p_a[0] + i * 1 * 1, (double *)p_a[1] + i * 1 * 1, (double *)p_a[2] + i * 1 * 1, (double *)p_a[3] + i * 1 * 1, (double *)p_a[4] + i * 1 * 1, (double *)p_a[5] + i * 1 * 1); } // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0) * SIMD_VEC; p_a[1] = p_a[1] + (dat1 * off1_0) * SIMD_VEC; p_a[2] = p_a[2] + (dat2 * off2_0) * SIMD_VEC; p_a[3] = p_a[3] + (dat3 * off3_0) * SIMD_VEC; p_a[4] = p_a[4] + (dat4 * off4_0) * SIMD_VEC; p_a[5] = p_a[5] + (dat5 * off5_0) * SIMD_VEC; } for (int n_x = start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x < end[0]; n_x++) { // call kernel function, passing in pointers to data - remainder save_kernel((double *)p_a[0], (double *)p_a[1], (double *)p_a[2], (double *)p_a[3], (double *)p_a[4], (double *)p_a[5]); // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0); p_a[1] = p_a[1] + (dat1 * off1_0); p_a[2] = p_a[2] + (dat2 * off2_0); p_a[3] = p_a[3] + (dat3 * off3_0); p_a[4] = p_a[4] + (dat4 * off4_0); p_a[5] = p_a[5] + (dat5 * off5_0); } if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[1].time += t2 - t1; } ops_set_dirtybit_host(args, 6); ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[1], range); ops_set_halo_dirtybit3(&args[2], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c1, &t1); OPS_kernels[1].mpi_time += t1 - t2; OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg4); OPS_kernels[1].transfer += ops_compute_transfer(dim, start, end, &arg5); } }
// host stub function void ops_par_loop_tea_leaf_xpy_kernel(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1) { // Timing double t1, t2, c1, c2; int offs[2][2]; ops_arg args[2] = {arg0, arg1}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 2, range, 25)) return; #endif if (OPS_diags > 1) { ops_timing_realloc(25, "tea_leaf_xpy_kernel"); OPS_kernels[25].count++; ops_timers_core(&c1, &t1); } #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; #endif // compute locally allocated range for the sub-block int start[2]; int end[2]; int arg_idx[2]; #ifdef OPS_MPI if (!sb->owned) return; for (int n = 0; n < 2; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); if (end[n] < start[n]) end[n] = start[n]; } #else for (int n = 0; n < 2; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif #ifdef OPS_DEBUG ops_register_args(args, "tea_leaf_xpy_kernel"); #endif offs[0][0] = args[0].stencil->stride[0] * 1; // unit step in x dimension offs[0][1] = off2D(1, &start[0], &end[0], args[0].dat->size, args[0].stencil->stride) - offs[0][0]; offs[1][0] = args[1].stencil->stride[0] * 1; // unit step in x dimension offs[1][1] = off2D(1, &start[0], &end[0], args[1].dat->size, args[1].stencil->stride) - offs[1][0]; int off0_0 = offs[0][0]; int off0_1 = offs[0][1]; int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int off1_0 = offs[1][0]; int off1_1 = offs[1][1]; int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); // Halo Exchanges ops_H_D_exchanges_host(args, 2); ops_halo_exchanges(args, 2, range); ops_H_D_exchanges_host(args, 2); #ifdef _OPENMP int nthreads = omp_get_max_threads(); #else int nthreads = 1; #endif xdim0 = args[0].dat->size[0]; xdim1 = args[1].dat->size[0]; if (OPS_diags > 1) { ops_timers_core(&c2, &t2); OPS_kernels[25].mpi_time += t2 - t1; } #pragma omp parallel for for (int thr = 0; thr < nthreads; thr++) { int y_size = end[1] - start[1]; char *p_a[2]; int start_i = start[1] + ((y_size - 1) / nthreads + 1) * thr; int finish_i = start[1] + MIN(((y_size - 1) / nthreads + 1) * (thr + 1), y_size); // get address per thread int start0 = start[0]; int start1 = start_i; // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = dat0 * 1 * (start0 * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + dat0 * args[0].dat->size[0] * (start1 * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); p_a[0] = (char *)args[0].data + base0; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif int base1 = dat1 * 1 * (start0 * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + dat1 * args[1].dat->size[0] * (start1 * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); p_a[1] = (char *)args[1].data + base1; for (int n_y = start_i; n_y < finish_i; n_y++) { for (int n_x = start[0]; n_x < start[0] + (end[0] - start[0]) / SIMD_VEC; n_x++) { // call kernel function, passing in pointers to data -vectorised #pragma simd for (int i = 0; i < SIMD_VEC; i++) { tea_leaf_xpy_kernel((double *)p_a[0] + i * 1 * 1, (const double *)p_a[1] + i * 1 * 1); } // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0) * SIMD_VEC; p_a[1] = p_a[1] + (dat1 * off1_0) * SIMD_VEC; } for (int n_x = start[0] + ((end[0] - start[0]) / SIMD_VEC) * SIMD_VEC; n_x < end[0]; n_x++) { // call kernel function, passing in pointers to data - remainder tea_leaf_xpy_kernel((double *)p_a[0], (const double *)p_a[1]); // shift pointers to data x direction p_a[0] = p_a[0] + (dat0 * off0_0); p_a[1] = p_a[1] + (dat1 * off1_0); } // shift pointers to data y direction p_a[0] = p_a[0] + (dat0 * off0_1); p_a[1] = p_a[1] + (dat1 * off1_1); } } if (OPS_diags > 1) { ops_timers_core(&c1, &t1); OPS_kernels[25].time += t1 - t2; } ops_set_dirtybit_host(args, 2); ops_set_halo_dirtybit3(&args[0], range); if (OPS_diags > 1) { // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[25].mpi_time += t2 - t1; OPS_kernels[25].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[25].transfer += ops_compute_transfer(dim, start, end, &arg1); } }
// host stub function void ops_par_loop_initialise_chunk_kernel_x(char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2) { ops_arg args[3] = {arg0, arg1, arg2}; sub_block_list sb = OPS_sub_block_list[Block->index]; // compute localy allocated range for the sub-block int start_add[2]; int end_add[2]; for (int n = 0; n < 2; n++) { start_add[n] = sb->istart[n]; end_add[n] = sb->iend[n] + 1; if (start_add[n] >= range[2 * n]) { start_add[n] = 0; } else { start_add[n] = range[2 * n] - start_add[n]; } if (end_add[n] >= range[2 * n + 1]) { end_add[n] = range[2 * n + 1] - sb->istart[n]; } else { end_add[n] = sb->sizes[n]; } } int x_size = end_add[0] - start_add[0]; int y_size = end_add[1] - start_add[1]; int xdim0 = args[0].dat->block_size[0] * args[0].dat->dim; int xdim1 = args[1].dat->block_size[0] * args[1].dat->dim; int xdim2 = args[2].dat->block_size[0] * args[2].dat->dim; // build opencl kernel if not already built buildOpenCLKernels_initialise_chunk_kernel_x(xdim0, xdim1, xdim2); // Timing double t1, t2, c1, c2; ops_timing_realloc(72, "initialise_chunk_kernel_x"); ops_timers_core(&c2, &t2); // set up OpenCL thread blocks size_t globalWorkSize[3] = { ((x_size - 1) / OPS_block_size_x + 1) * OPS_block_size_x, ((y_size - 1) / OPS_block_size_y + 1) * OPS_block_size_y, 1}; size_t localWorkSize[3] = {OPS_block_size_x, OPS_block_size_y, 1}; int dat0 = args[0].dat->size; int dat1 = args[1].dat->size; int dat2 = args[2].dat->size; // set up initial pointers int base0 = 1 * (start_add[0] * args[0].stencil->stride[0] - args[0].dat->offset[0]); base0 = base0 + args[0].dat->block_size[0] * (start_add[1] * args[0].stencil->stride[1] - args[0].dat->offset[1]); // set up initial pointers int base1 = 1 * (start_add[0] * args[1].stencil->stride[0] - args[1].dat->offset[0]); base1 = base1 + args[1].dat->block_size[0] * (start_add[1] * args[1].stencil->stride[1] - args[1].dat->offset[1]); // set up initial pointers int base2 = 1 * (start_add[0] * args[2].stencil->stride[0] - args[2].dat->offset[0]); base2 = base2 + args[2].dat->block_size[0] * (start_add[1] * args[2].stencil->stride[1] - args[2].dat->offset[1]); ops_H_D_exchanges_cuda(args, 3); ops_timers_core(&c1, &t1); OPS_kernels[72].mpi_time += t1 - t2; clSafeCall(clEnqueueWriteBuffer( OPS_opencl_core.command_queue, OPS_opencl_core.constant[6], CL_TRUE, 0, sizeof(field_type) * 1, (void *)&field, 0, NULL, NULL)); clSafeCall(clFlush(OPS_opencl_core.command_queue)); clSafeCall(clEnqueueWriteBuffer( OPS_opencl_core.command_queue, OPS_opencl_core.constant[7], CL_TRUE, 0, sizeof(grid_type) * 1, (void *)&grid, 0, NULL, NULL)); clSafeCall(clFlush(OPS_opencl_core.command_queue)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 0, sizeof(cl_mem), (void *)&arg0.data_d)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 1, sizeof(cl_mem), (void *)&arg1.data_d)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 2, sizeof(cl_mem), (void *)&arg2.data_d)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 3, sizeof(cl_mem), (void *)&OPS_opencl_core.constant[6])); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 4, sizeof(cl_mem), (void *)&OPS_opencl_core.constant[7])); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 5, sizeof(cl_int), (void *)&base0)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 6, sizeof(cl_int), (void *)&base1)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 7, sizeof(cl_int), (void *)&base2)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 8, sizeof(cl_int), (void *)&x_size)); clSafeCall(clSetKernelArg(OPS_opencl_core.kernel[72], 9, sizeof(cl_int), (void *)&y_size)); // call/enque opencl kernel wrapper function clSafeCall(clEnqueueNDRangeKernel( OPS_opencl_core.command_queue, OPS_opencl_core.kernel[72], 3, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL)); if (OPS_diags > 1) { clSafeCall(clFinish(OPS_opencl_core.command_queue)); } ops_set_dirtybit_opencl(args, 3); // Update kernel record ops_timers_core(&c2, &t2); OPS_kernels[72].count++; OPS_kernels[72].time += t2 - t1; OPS_kernels[72].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[72].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[72].transfer += ops_compute_transfer(dim, range, &arg2); }
// host stub function void ops_par_loop_advec_mom_kernel_post_pre_advec_x( char const *name, ops_block block, int dim, int *range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4) { ops_arg args[5] = {arg0, arg1, arg2, arg3, arg4}; #ifdef CHECKPOINTING if (!ops_checkpointing_before(args, 5, range, 74)) return; #endif ops_timing_realloc(74, "advec_mom_kernel_post_pre_advec_x"); OPS_kernels[74].count++; // compute localy allocated range for the sub-block int start[2]; int end[2]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for (int n = 0; n < 2; n++) { start[n] = sb->decomp_disp[n]; end[n] = sb->decomp_disp[n] + sb->decomp_size[n]; if (start[n] >= range[2 * n]) { start[n] = 0; } else { start[n] = range[2 * n] - start[n]; } if (sb->id_m[n] == MPI_PROC_NULL && range[2 * n] < 0) start[n] = range[2 * n]; if (end[n] >= range[2 * n + 1]) { end[n] = range[2 * n + 1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n] == MPI_PROC_NULL && (range[2 * n + 1] > sb->decomp_disp[n] + sb->decomp_size[n])) end[n] += (range[2 * n + 1] - sb->decomp_disp[n] - sb->decomp_size[n]); } #else for (int n = 0; n < 2; n++) { start[n] = range[2 * n]; end[n] = range[2 * n + 1]; } #endif int x_size = MAX(0, end[0] - start[0]); int y_size = MAX(0, end[1] - start[1]); xdim0 = args[0].dat->size[0]; xdim1 = args[1].dat->size[0]; xdim2 = args[2].dat->size[0]; xdim3 = args[3].dat->size[0]; xdim4 = args[4].dat->size[0]; // Timing double t1, t2, c1, c2; ops_timers_core(&c2, &t2); if (xdim0 != xdim0_advec_mom_kernel_post_pre_advec_x_h || xdim1 != xdim1_advec_mom_kernel_post_pre_advec_x_h || xdim2 != xdim2_advec_mom_kernel_post_pre_advec_x_h || xdim3 != xdim3_advec_mom_kernel_post_pre_advec_x_h || xdim4 != xdim4_advec_mom_kernel_post_pre_advec_x_h) { xdim0_advec_mom_kernel_post_pre_advec_x = xdim0; xdim0_advec_mom_kernel_post_pre_advec_x_h = xdim0; xdim1_advec_mom_kernel_post_pre_advec_x = xdim1; xdim1_advec_mom_kernel_post_pre_advec_x_h = xdim1; xdim2_advec_mom_kernel_post_pre_advec_x = xdim2; xdim2_advec_mom_kernel_post_pre_advec_x_h = xdim2; xdim3_advec_mom_kernel_post_pre_advec_x = xdim3; xdim3_advec_mom_kernel_post_pre_advec_x_h = xdim3; xdim4_advec_mom_kernel_post_pre_advec_x = xdim4; xdim4_advec_mom_kernel_post_pre_advec_x_h = xdim4; } int dat0 = (OPS_soa ? args[0].dat->type_size : args[0].dat->elem_size); int dat1 = (OPS_soa ? args[1].dat->type_size : args[1].dat->elem_size); int dat2 = (OPS_soa ? args[2].dat->type_size : args[2].dat->elem_size); int dat3 = (OPS_soa ? args[3].dat->type_size : args[3].dat->elem_size); int dat4 = (OPS_soa ? args[4].dat->type_size : args[4].dat->elem_size); // set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif int base0 = dat0 * 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + dat0 * args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); double *p_a0 = (double *)((char *)args[0].data + base0); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif int base1 = dat1 * 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + dat1 * args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); double *p_a1 = (double *)((char *)args[1].data + base1); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif int base2 = dat2 * 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + dat2 * args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); double *p_a2 = (double *)((char *)args[2].data + base2); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif int base3 = dat3 * 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + dat3 * args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); double *p_a3 = (double *)((char *)args[3].data + base3); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif int base4 = dat4 * 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4 + dat4 * args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); double *p_a4 = (double *)((char *)args[4].data + base4); ops_H_D_exchanges_host(args, 5); ops_halo_exchanges(args, 5, range); ops_timers_core(&c1, &t1); OPS_kernels[74].mpi_time += t1 - t2; advec_mom_kernel_post_pre_advec_x_c_wrapper(p_a0, p_a1, p_a2, p_a3, p_a4, x_size, y_size); ops_timers_core(&c2, &t2); OPS_kernels[74].time += t2 - t1; ops_set_dirtybit_host(args, 5); ops_set_halo_dirtybit3(&args[0], range); ops_set_halo_dirtybit3(&args[3], range); // Update kernel record OPS_kernels[74].transfer += ops_compute_transfer(dim, start, end, &arg0); OPS_kernels[74].transfer += ops_compute_transfer(dim, start, end, &arg1); OPS_kernels[74].transfer += ops_compute_transfer(dim, start, end, &arg2); OPS_kernels[74].transfer += ops_compute_transfer(dim, start, end, &arg3); OPS_kernels[74].transfer += ops_compute_transfer(dim, start, end, &arg4); }
// host stub function void ops_par_loop_PdV_kernel_predict(char const *name, ops_block block, int dim, int* range, ops_arg arg0, ops_arg arg1, ops_arg arg2, ops_arg arg3, ops_arg arg4, ops_arg arg5, ops_arg arg6, ops_arg arg7, ops_arg arg8, ops_arg arg9, ops_arg arg10, ops_arg arg11, ops_arg arg12, ops_arg arg13) { ops_arg args[14] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13}; ops_timing_realloc(5,"PdV_kernel_predict"); OPS_kernels[5].count++; //compute locally allocated range for the sub-block int start[3]; int end[3]; #ifdef OPS_MPI sub_block_list sb = OPS_sub_block_list[block->index]; if (!sb->owned) return; for ( int n=0; n<3; n++ ){ start[n] = sb->decomp_disp[n];end[n] = sb->decomp_disp[n]+sb->decomp_size[n]; if (start[n] >= range[2*n]) { start[n] = 0; } else { start[n] = range[2*n] - start[n]; } if (sb->id_m[n]==MPI_PROC_NULL && range[2*n] < 0) start[n] = range[2*n]; if (end[n] >= range[2*n+1]) { end[n] = range[2*n+1] - sb->decomp_disp[n]; } else { end[n] = sb->decomp_size[n]; } if (sb->id_p[n]==MPI_PROC_NULL && (range[2*n+1] > sb->decomp_disp[n]+sb->decomp_size[n])) end[n] += (range[2*n+1]-sb->decomp_disp[n]-sb->decomp_size[n]); } #else //OPS_MPI for ( int n=0; n<3; n++ ){ start[n] = range[2*n];end[n] = range[2*n+1]; } #endif //OPS_MPI int x_size = MAX(0,end[0]-start[0]); int y_size = MAX(0,end[1]-start[1]); int z_size = MAX(0,end[2]-start[2]); int xdim0 = args[0].dat->size[0]*args[0].dat->dim; int ydim0 = args[0].dat->size[1]; int xdim1 = args[1].dat->size[0]*args[1].dat->dim; int ydim1 = args[1].dat->size[1]; int xdim2 = args[2].dat->size[0]*args[2].dat->dim; int ydim2 = args[2].dat->size[1]; int xdim3 = args[3].dat->size[0]*args[3].dat->dim; int ydim3 = args[3].dat->size[1]; int xdim4 = args[4].dat->size[0]*args[4].dat->dim; int ydim4 = args[4].dat->size[1]; int xdim5 = args[5].dat->size[0]*args[5].dat->dim; int ydim5 = args[5].dat->size[1]; int xdim6 = args[6].dat->size[0]*args[6].dat->dim; int ydim6 = args[6].dat->size[1]; int xdim7 = args[7].dat->size[0]*args[7].dat->dim; int ydim7 = args[7].dat->size[1]; int xdim8 = args[8].dat->size[0]*args[8].dat->dim; int ydim8 = args[8].dat->size[1]; int xdim9 = args[9].dat->size[0]*args[9].dat->dim; int ydim9 = args[9].dat->size[1]; int xdim10 = args[10].dat->size[0]*args[10].dat->dim; int ydim10 = args[10].dat->size[1]; int xdim11 = args[11].dat->size[0]*args[11].dat->dim; int ydim11 = args[11].dat->size[1]; int xdim12 = args[12].dat->size[0]*args[12].dat->dim; int ydim12 = args[12].dat->size[1]; int xdim13 = args[13].dat->size[0]*args[13].dat->dim; int ydim13 = args[13].dat->size[1]; //build opencl kernel if not already built buildOpenCLKernels_PdV_kernel_predict( xdim0,ydim0,xdim1,ydim1,xdim2,ydim2,xdim3,ydim3,xdim4,ydim4,xdim5,ydim5,xdim6,ydim6,xdim7,ydim7,xdim8,ydim8,xdim9,ydim9,xdim10,ydim10,xdim11,ydim11,xdim12,ydim12,xdim13,ydim13); //Timing double t1,t2,c1,c2; ops_timers_core(&c2,&t2); //set up OpenCL thread blocks size_t globalWorkSize[3] = {((x_size-1)/OPS_block_size_x+ 1)*OPS_block_size_x, ((y_size-1)/OPS_block_size_y + 1)*OPS_block_size_y, MAX(1,end[2]-start[2])}; size_t localWorkSize[3] = {OPS_block_size_x,OPS_block_size_y,1}; int dat0 = args[0].dat->elem_size; int dat1 = args[1].dat->elem_size; int dat2 = args[2].dat->elem_size; int dat3 = args[3].dat->elem_size; int dat4 = args[4].dat->elem_size; int dat5 = args[5].dat->elem_size; int dat6 = args[6].dat->elem_size; int dat7 = args[7].dat->elem_size; int dat8 = args[8].dat->elem_size; int dat9 = args[9].dat->elem_size; int dat10 = args[10].dat->elem_size; int dat11 = args[11].dat->elem_size; int dat12 = args[12].dat->elem_size; int dat13 = args[13].dat->elem_size; //set up initial pointers int d_m[OPS_MAX_DIM]; #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d] + OPS_sub_dat_list[args[0].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[0].dat->d_m[d]; #endif //OPS_MPI int base0 = 1 * (start[0] * args[0].stencil->stride[0] - args[0].dat->base[0] - d_m[0]); base0 = base0 + args[0].dat->size[0] * (start[1] * args[0].stencil->stride[1] - args[0].dat->base[1] - d_m[1]); base0 = base0 + args[0].dat->size[0] * args[0].dat->size[1] * (start[2] * args[0].stencil->stride[2] - args[0].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d] + OPS_sub_dat_list[args[1].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[1].dat->d_m[d]; #endif //OPS_MPI int base1 = 1 * (start[0] * args[1].stencil->stride[0] - args[1].dat->base[0] - d_m[0]); base1 = base1 + args[1].dat->size[0] * (start[1] * args[1].stencil->stride[1] - args[1].dat->base[1] - d_m[1]); base1 = base1 + args[1].dat->size[0] * args[1].dat->size[1] * (start[2] * args[1].stencil->stride[2] - args[1].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d] + OPS_sub_dat_list[args[2].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[2].dat->d_m[d]; #endif //OPS_MPI int base2 = 1 * (start[0] * args[2].stencil->stride[0] - args[2].dat->base[0] - d_m[0]); base2 = base2 + args[2].dat->size[0] * (start[1] * args[2].stencil->stride[1] - args[2].dat->base[1] - d_m[1]); base2 = base2 + args[2].dat->size[0] * args[2].dat->size[1] * (start[2] * args[2].stencil->stride[2] - args[2].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d] + OPS_sub_dat_list[args[3].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[3].dat->d_m[d]; #endif //OPS_MPI int base3 = 1 * (start[0] * args[3].stencil->stride[0] - args[3].dat->base[0] - d_m[0]); base3 = base3 + args[3].dat->size[0] * (start[1] * args[3].stencil->stride[1] - args[3].dat->base[1] - d_m[1]); base3 = base3 + args[3].dat->size[0] * args[3].dat->size[1] * (start[2] * args[3].stencil->stride[2] - args[3].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d] + OPS_sub_dat_list[args[4].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[4].dat->d_m[d]; #endif //OPS_MPI int base4 = 1 * (start[0] * args[4].stencil->stride[0] - args[4].dat->base[0] - d_m[0]); base4 = base4 + args[4].dat->size[0] * (start[1] * args[4].stencil->stride[1] - args[4].dat->base[1] - d_m[1]); base4 = base4 + args[4].dat->size[0] * args[4].dat->size[1] * (start[2] * args[4].stencil->stride[2] - args[4].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d] + OPS_sub_dat_list[args[5].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[5].dat->d_m[d]; #endif //OPS_MPI int base5 = 1 * (start[0] * args[5].stencil->stride[0] - args[5].dat->base[0] - d_m[0]); base5 = base5 + args[5].dat->size[0] * (start[1] * args[5].stencil->stride[1] - args[5].dat->base[1] - d_m[1]); base5 = base5 + args[5].dat->size[0] * args[5].dat->size[1] * (start[2] * args[5].stencil->stride[2] - args[5].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d] + OPS_sub_dat_list[args[6].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[6].dat->d_m[d]; #endif //OPS_MPI int base6 = 1 * (start[0] * args[6].stencil->stride[0] - args[6].dat->base[0] - d_m[0]); base6 = base6 + args[6].dat->size[0] * (start[1] * args[6].stencil->stride[1] - args[6].dat->base[1] - d_m[1]); base6 = base6 + args[6].dat->size[0] * args[6].dat->size[1] * (start[2] * args[6].stencil->stride[2] - args[6].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d] + OPS_sub_dat_list[args[7].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[7].dat->d_m[d]; #endif //OPS_MPI int base7 = 1 * (start[0] * args[7].stencil->stride[0] - args[7].dat->base[0] - d_m[0]); base7 = base7 + args[7].dat->size[0] * (start[1] * args[7].stencil->stride[1] - args[7].dat->base[1] - d_m[1]); base7 = base7 + args[7].dat->size[0] * args[7].dat->size[1] * (start[2] * args[7].stencil->stride[2] - args[7].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[8].dat->d_m[d] + OPS_sub_dat_list[args[8].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[8].dat->d_m[d]; #endif //OPS_MPI int base8 = 1 * (start[0] * args[8].stencil->stride[0] - args[8].dat->base[0] - d_m[0]); base8 = base8 + args[8].dat->size[0] * (start[1] * args[8].stencil->stride[1] - args[8].dat->base[1] - d_m[1]); base8 = base8 + args[8].dat->size[0] * args[8].dat->size[1] * (start[2] * args[8].stencil->stride[2] - args[8].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[9].dat->d_m[d] + OPS_sub_dat_list[args[9].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[9].dat->d_m[d]; #endif //OPS_MPI int base9 = 1 * (start[0] * args[9].stencil->stride[0] - args[9].dat->base[0] - d_m[0]); base9 = base9 + args[9].dat->size[0] * (start[1] * args[9].stencil->stride[1] - args[9].dat->base[1] - d_m[1]); base9 = base9 + args[9].dat->size[0] * args[9].dat->size[1] * (start[2] * args[9].stencil->stride[2] - args[9].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[10].dat->d_m[d] + OPS_sub_dat_list[args[10].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[10].dat->d_m[d]; #endif //OPS_MPI int base10 = 1 * (start[0] * args[10].stencil->stride[0] - args[10].dat->base[0] - d_m[0]); base10 = base10 + args[10].dat->size[0] * (start[1] * args[10].stencil->stride[1] - args[10].dat->base[1] - d_m[1]); base10 = base10 + args[10].dat->size[0] * args[10].dat->size[1] * (start[2] * args[10].stencil->stride[2] - args[10].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[11].dat->d_m[d] + OPS_sub_dat_list[args[11].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[11].dat->d_m[d]; #endif //OPS_MPI int base11 = 1 * (start[0] * args[11].stencil->stride[0] - args[11].dat->base[0] - d_m[0]); base11 = base11 + args[11].dat->size[0] * (start[1] * args[11].stencil->stride[1] - args[11].dat->base[1] - d_m[1]); base11 = base11 + args[11].dat->size[0] * args[11].dat->size[1] * (start[2] * args[11].stencil->stride[2] - args[11].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[12].dat->d_m[d] + OPS_sub_dat_list[args[12].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[12].dat->d_m[d]; #endif //OPS_MPI int base12 = 1 * (start[0] * args[12].stencil->stride[0] - args[12].dat->base[0] - d_m[0]); base12 = base12 + args[12].dat->size[0] * (start[1] * args[12].stencil->stride[1] - args[12].dat->base[1] - d_m[1]); base12 = base12 + args[12].dat->size[0] * args[12].dat->size[1] * (start[2] * args[12].stencil->stride[2] - args[12].dat->base[2] - d_m[2]); #ifdef OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[13].dat->d_m[d] + OPS_sub_dat_list[args[13].dat->index]->d_im[d]; #else //OPS_MPI for (int d = 0; d < dim; d++) d_m[d] = args[13].dat->d_m[d]; #endif //OPS_MPI int base13 = 1 * (start[0] * args[13].stencil->stride[0] - args[13].dat->base[0] - d_m[0]); base13 = base13 + args[13].dat->size[0] * (start[1] * args[13].stencil->stride[1] - args[13].dat->base[1] - d_m[1]); base13 = base13 + args[13].dat->size[0] * args[13].dat->size[1] * (start[2] * args[13].stencil->stride[2] - args[13].dat->base[2] - d_m[2]); ops_H_D_exchanges_device(args, 14); ops_halo_exchanges(args,14,range); ops_H_D_exchanges_device(args, 14); ops_timers_core(&c1,&t1); OPS_kernels[5].mpi_time += t1-t2; clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 0, sizeof(cl_mem), (void*) &arg0.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 1, sizeof(cl_mem), (void*) &arg1.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 2, sizeof(cl_mem), (void*) &arg2.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 3, sizeof(cl_mem), (void*) &arg3.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 4, sizeof(cl_mem), (void*) &arg4.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 5, sizeof(cl_mem), (void*) &arg5.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 6, sizeof(cl_mem), (void*) &arg6.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 7, sizeof(cl_mem), (void*) &arg7.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 8, sizeof(cl_mem), (void*) &arg8.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 9, sizeof(cl_mem), (void*) &arg9.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 10, sizeof(cl_mem), (void*) &arg10.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 11, sizeof(cl_mem), (void*) &arg11.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 12, sizeof(cl_mem), (void*) &arg12.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 13, sizeof(cl_mem), (void*) &arg13.data_d )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 14, sizeof(cl_double), (void*) &dt )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 15, sizeof(cl_int), (void*) &base0 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 16, sizeof(cl_int), (void*) &base1 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 17, sizeof(cl_int), (void*) &base2 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 18, sizeof(cl_int), (void*) &base3 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 19, sizeof(cl_int), (void*) &base4 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 20, sizeof(cl_int), (void*) &base5 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 21, sizeof(cl_int), (void*) &base6 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 22, sizeof(cl_int), (void*) &base7 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 23, sizeof(cl_int), (void*) &base8 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 24, sizeof(cl_int), (void*) &base9 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 25, sizeof(cl_int), (void*) &base10 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 26, sizeof(cl_int), (void*) &base11 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 27, sizeof(cl_int), (void*) &base12 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 28, sizeof(cl_int), (void*) &base13 )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 29, sizeof(cl_int), (void*) &x_size )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 30, sizeof(cl_int), (void*) &y_size )); clSafeCall( clSetKernelArg(OPS_opencl_core.kernel[5], 31, sizeof(cl_int), (void*) &z_size )); //call/enque opencl kernel wrapper function clSafeCall( clEnqueueNDRangeKernel(OPS_opencl_core.command_queue, OPS_opencl_core.kernel[5], 3, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL) ); if (OPS_diags>1) { clSafeCall( clFinish(OPS_opencl_core.command_queue) ); } ops_set_dirtybit_device(args, 14); ops_set_halo_dirtybit3(&args[4],range); ops_set_halo_dirtybit3(&args[8],range); ops_set_halo_dirtybit3(&args[11],range); //Update kernel record ops_timers_core(&c2,&t2); OPS_kernels[5].time += t2-t1; OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg0); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg1); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg2); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg3); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg4); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg5); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg6); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg7); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg8); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg9); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg10); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg11); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg12); OPS_kernels[5].transfer += ops_compute_transfer(dim, range, &arg13); }