コード例 #1
0
    def __init__(self,
                 mc,
                 r_cut,
                 code=None,
                 llvm_ir_file=None,
                 clang_exec=None):
        hoomd.util.print_status_line()

        # check if initialization has occurred
        if hoomd.context.exec_conf is None:
            hoomd.context.msg.error(
                "Cannot create patch energy before context initialization\n")
            raise RuntimeError('Error creating patch energy')

        if clang_exec is not None:
            clang = clang_exec
        else:
            clang = find_executable('clang')

        if code is not None:
            llvm_ir = self.compile_user(code, clang)
        else:
            # IR is a text file
            with open(llvm_ir_file, 'r') as f:
                llvm_ir = f.read()

        self.compute_name = "patch_union"
        self.cpp_evaluator = _jit.PatchEnergyJITUnion(
            hoomd.context.current.system_definition, hoomd.context.exec_conf,
            llvm_ir, r_cut)
        mc.set_PatchEnergyEvaluator(self)

        self.mc = mc
        self.enabled = True
        self.log = False
コード例 #2
0
    def __init__(self,
                 mc,
                 r_cut,
                 array_size=1,
                 code=None,
                 llvm_ir_file=None,
                 r_cut_iso=None,
                 code_iso=None,
                 llvm_ir_file_iso=None,
                 array_size_iso=1,
                 clang_exec=None):

        # check if initialization has occurred
        hoomd.context._verify_init()

        if clang_exec is not None:
            clang = clang_exec
        else:
            clang = 'clang'

        if code is not None:
            llvm_ir = self.compile_user(array_size_iso, array_size, code,
                                        clang)
        else:
            # IR is a text file
            with open(llvm_ir_file, 'r') as f:
                llvm_ir = f.read()

        if code_iso is not None:
            llvm_ir_iso = self.compile_user(array_size_iso, array_size,
                                            code_iso, clang)
        else:
            if llvm_ir_file_iso is not None:
                # IR is a text file
                with open(llvm_ir_file_iso, 'r') as f:
                    llvm_ir_iso = f.read()
            else:
                # provide a dummy function
                llvm_ir_iso = self.compile_user(array_size_iso, array_size,
                                                'return 0;', clang)

        if r_cut_iso is None:
            r_cut_iso = -1.0

        self.compute_name = "patch_union"
        self.cpp_evaluator = _jit.PatchEnergyJITUnion(
            hoomd.context.current.system_definition,
            hoomd.context.current.device.cpp_exec_conf, llvm_ir_iso, r_cut_iso,
            array_size_iso, llvm_ir, r_cut, array_size)
        mc.set_PatchEnergyEvaluator(self)

        self.mc = mc
        self.enabled = True
        self.log = False
        self.cpp_evaluator.alpha_iso[:] = [0] * array_size_iso
        self.cpp_evaluator.alpha_union[:] = [0] * array_size
        self.alpha_iso = self.cpp_evaluator.alpha_iso[:]
        self.alpha_union = self.cpp_evaluator.alpha_union[:]
コード例 #3
0
ファイル: patch.py プロジェクト: adulaney/hoomd-blue
    def __init__(self, mc, r_cut, code=None, llvm_ir_file=None, r_cut_iso=None, code_iso=None,
        llvm_ir_file_iso=None, clang_exec=None):
        hoomd.util.print_status_line();

        # check if initialization has occurred
        if hoomd.context.exec_conf is None:
            hoomd.context.msg.error("Cannot create patch energy before context initialization\n");
            raise RuntimeError('Error creating patch energy');

        if clang_exec is not None:
            clang = clang_exec;
        else:
            clang = 'clang'

        if code is not None:
            llvm_ir = self.compile_user(code,clang)
        else:
            # IR is a text file
            with open(llvm_ir_file,'r') as f:
                llvm_ir = f.read()

        if code_iso is not None:
            llvm_ir_iso = self.compile_user(code_iso,clang)
        else:
            if llvm_ir_file_iso is not None:
                # IR is a text file
                with open(llvm_ir_file_iso,'r') as f:
                    llvm_ir_iso = f.read()
            else:
                # provide a dummy function
                llvm_ir_iso = self.compile_user('return 0;',clang)

        if r_cut_iso is None:
            r_cut_iso = -1.0

        self.compute_name = "patch_union"
        self.cpp_evaluator = _jit.PatchEnergyJITUnion(hoomd.context.current.system_definition, hoomd.context.exec_conf,
            llvm_ir_iso, r_cut_iso, llvm_ir, r_cut);
        mc.set_PatchEnergyEvaluator(self);

        self.mc = mc
        self.enabled = True
        self.log = False
コード例 #4
0
ファイル: patch.py プロジェクト: blockspacer/hoomd-blue
    def __init__(self,
                 mc,
                 r_cut,
                 array_size=1,
                 code=None,
                 llvm_ir_file=None,
                 r_cut_iso=None,
                 code_iso=None,
                 llvm_ir_file_iso=None,
                 array_size_iso=1,
                 clang_exec=None):

        # check if initialization has occurred
        hoomd.context._verify_init()

        if clang_exec is not None:
            clang = clang_exec
        else:
            clang = 'clang'

        if code is not None:
            llvm_ir = self.compile_user(array_size_iso, array_size, code,
                                        clang)
        else:
            # IR is a text file
            with open(llvm_ir_file, 'r') as f:
                llvm_ir = f.read()

        if code_iso is not None:
            llvm_ir_iso = self.compile_user(array_size_iso, array_size,
                                            code_iso, clang)
        else:
            if llvm_ir_file_iso is not None:
                # IR is a text file
                with open(llvm_ir_file_iso, 'r') as f:
                    llvm_ir_iso = f.read()
            else:
                # provide a dummy function
                llvm_ir_iso = self.compile_user(array_size_iso, array_size,
                                                'return 0;', clang)

        if r_cut_iso is None:
            r_cut_iso = -1.0

        self.compute_name = "patch_union"

        if hoomd.context.current.device.cpp_exec_conf.isCUDAEnabled():
            include_path_hoomd = os.path.dirname(hoomd.__file__) + '/include'
            include_path_source = hoomd._hoomd.__hoomd_source_dir__
            include_path_cuda = _jit.__cuda_include_path__
            options = [
                "-I" + include_path_hoomd, "-I" + include_path_source,
                "-I" + include_path_cuda
            ]

            # use union evaluator
            options += ["-DUNION_EVAL"]

            cuda_devrt_library_path = _jit.__cuda_devrt_library_path__

            # select maximum supported compute capability out of those we compile for
            compute_archs = _jit.__cuda_compute_archs__
            compute_archs_vec = _hoomd.std_vector_uint()
            compute_capability = hoomd.context.current.device.cpp_exec_conf.getComputeCapability(
                0)  # GPU 0
            compute_major, compute_minor = compute_capability.split('.')
            max_arch = 0
            for a in compute_archs.split('_'):
                if int(a) < int(compute_major) * 10 + int(compute_major):
                    max_arch = int(a)

            gpu_code = self.wrap_gpu_code(code)
            self.cpp_evaluator = _jit.PatchEnergyJITUnionGPU(
                hoomd.context.current.system_definition,
                hoomd.context.current.device.cpp_exec_conf, llvm_ir_iso,
                r_cut_iso, array_size_iso, llvm_ir, r_cut, array_size,
                gpu_code, "hpmc::gpu::kernel::hpmc_narrow_phase_patch",
                options, cuda_devrt_library_path, max_arch)
        else:
            self.cpp_evaluator = _jit.PatchEnergyJITUnion(
                hoomd.context.current.system_definition,
                hoomd.context.current.device.cpp_exec_conf, llvm_ir_iso,
                r_cut_iso, array_size_iso, llvm_ir, r_cut, array_size)

        mc.set_PatchEnergyEvaluator(self)

        self.mc = mc
        self.enabled = True
        self.log = False
        self.cpp_evaluator.alpha_iso[:] = [0] * array_size_iso
        self.cpp_evaluator.alpha_union[:] = [0] * array_size
        self.alpha_iso = self.cpp_evaluator.alpha_iso[:]
        self.alpha_union = self.cpp_evaluator.alpha_union[:]