コード例 #1
0
void LBM::geometry_file_in_VTK( ){

	char buffer1[256];
	int x,y,z;

	snprintf(buffer1, sizeof(buffer1), "LBM2_%s_geometry.vtk", case_name.c_str());
	ofstream VTK_file(buffer1);

	VTK_file<<"# vtk DataFile Version 3.0"<< endl;
	VTK_file<<"vtk output"<< endl;
	VTK_file<<"ASCII"<< endl;

	int next_line_counter=0;

	//coordinates
	VTK_file<<"DATASET STRUCTURED_GRID"<< endl;
	VTK_file<<"DIMENSIONS "<< lx <<" "<< ly <<" " << lz << endl;
	VTK_file<<"POINTS " << lx*ly*lz <<" " STRINGIFY_MACRO(FLOATING) << endl;

	for (z = 0 ; z< lz ; ++z)
		for (y = 0 ; y< ly ; ++y)
			for (x = 0 ; x< lx ; ++x){
				VTK_file << x << "\t" << y << "\t" << "\t" << z << "\t";
				++next_line_counter;
				if(next_line_counter%9==0)
					VTK_file << endl;
			}

	VTK_file<< endl << endl;

	//print Obstacles
	VTK_file<<"POINT_DATA "<< lx*ly*lz << endl;
	VTK_file<<"SCALARS Obstacles int"<< endl;
	VTK_file<<"LOOKUP_TABLE default"<< endl;
	next_line_counter=0;
	for (z = 0 ; z< lz ; ++z){
		for (y = 0 ; y< ly ; ++y){
			for (x = 0 ; x< lx ; ++x){
				//.........if obstacle node, nothing is to do ...
				VTK_file <<  obstacles[index(z,y,x)] << "\t";

				++next_line_counter;
				if(next_line_counter%9==0)
					VTK_file << endl;
			}
		}
	}
	VTK_file<< endl << endl;

	VTK_file.close();
	cout << "geometry file exported!" << endl;

}
コード例 #2
0
/*! \brief Compiles nbnxn kernels for OpenCL GPU given by \p mygpu
 *
 * With OpenCL, a call to this function must precede nbnxn_gpu_init().
 *
 * Doing bFastGen means only the requested kernels are compiled,
 * significantly reducing the total compilation time. If false, all
 * OpenCL kernels are compiled.
 *
 * A fatal error results if compilation fails.
 *
 * \param[inout] nb  Manages OpenCL non-bonded calculations; compiled kernels returned in dev_info members
 *
 * Does not throw
 */
void
nbnxn_gpu_compile_kernels(gmx_nbnxn_ocl_t *nb)
{
    char                      gpu_err_str[STRLEN];
    gmx_bool                  bFastGen = TRUE;
    cl_device_id              device_id;
    cl_context                context;
    cl_program                program;
    char                      runtime_consts[256];

    if (getenv("GMX_OCL_NOFASTGEN") != NULL)
    {
        bFastGen = FALSE;
    }

    device_id        = nb->dev_info->ocl_gpu_id.ocl_device_id;
    context          = nb->dev_rundata->context;

    /* Here we pass macros and static const int variables defined in include
     * files outside the nbnxn_ocl as macros, to avoid including those files
     * in the JIT compilation that happens at runtime.
     */
    sprintf(runtime_consts,
            "-DCENTRAL=%d -DNBNXN_GPU_NCLUSTER_PER_SUPERCLUSTER=%d -DNBNXN_GPU_CLUSTER_SIZE=%d -DNBNXN_GPU_JGROUP_SIZE=%d -DNBNXN_AVOID_SING_R2_INC=%s %s",
            CENTRAL,                                    /* Defined in ishift.h */
            c_nbnxnGpuNumClusterPerSupercluster,        /* Defined in nbnxn_pairlist.h */
            c_nbnxnGpuClusterSize,                      /* Defined in nbnxn_pairlist.h */
            c_nbnxnGpuJgroupSize,                       /* Defined in nbnxn_pairlist.h */
            STRINGIFY_MACRO(NBNXN_AVOID_SING_R2_INC)    /* Defined in nbnxn_consts.h */
                                                        /* NBNXN_AVOID_SING_R2_INC passed as string to avoid
                                                           floating point representation problems with sprintf */
            , (nb->bPrefetchLjParam) ? "-DIATYPE_SHMEM" : ""
            );

    /* Need to catch std::bad_alloc here and during compilation string
       handling. */
    try
    {
        std::string defines_for_kernel_types =
            make_defines_for_kernel_types(bFastGen,
                                          nb->nbparam->eeltype,
                                          nb->nbparam->vdwtype);

        cl_int cl_error = ocl_compile_program(default_source,
                                              auto_vendor_kernels,
                                              defines_for_kernel_types.c_str(),
                                              gpu_err_str,
                                              context,
                                              device_id,
                                              nb->dev_info->vendor_e,
                                              &program,
                                              runtime_consts);
        if (cl_error != CL_SUCCESS)
        {
            gmx_fatal(FARGS, "Failed to compile NBNXN kernels for GPU #%s: %s",
                      nb->dev_info->device_name,
                      gpu_err_str);
        }
    }
    GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;

    nb->dev_rundata->program = program;
}
コード例 #3
0
const char* __asan_default_options() {
    return STRINGIFY_MACRO(ASAN_DEFAULT_OPTIONS);
}