How to use the dace.config.Config.get function in dace

To help you get started, we’ve selected a few dace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spcl / dace / dace / codegen / targets / cuda.py View on Github external
def cmake_options():

        host_compiler = make_absolute(
            Config.get("compiler", "cpu", "executable"))
        compiler = make_absolute(Config.get("compiler", "cuda", "executable"))
        flags = Config.get("compiler", "cuda", "args")
        flags += Config.get("compiler", "cuda", "additional_args")

        # Get CUDA architectures from configuration
        cuda_arch = Config.get('compiler', 'cuda', 'cuda_arch').split(',')
        cuda_arch = [ca for ca in cuda_arch if ca is not None and len(ca) > 0]

        flags += ' ' + ' '.join(
            '-gencode arch=compute_{arch},code=sm_{arch}'.format(arch=arch)
            for arch in cuda_arch)

        options = [
            "-DCUDA_HOST_COMPILER=\"{}\"".format(host_compiler),
            "-DCUDA_NVCC_FLAGS=\"{}\"".format(flags),
            "-DCUDA_TOOLKIT_ROOT_DIR=\"{}\"".format(
                os.path.dirname(os.path.dirname(compiler).replace('\\', '/')))
        ]

        return options
github spcl / dace / dace / codegen / targets / cuda.py View on Github external
def cmake_options():

        host_compiler = make_absolute(
            Config.get("compiler", "cpu", "executable"))
        compiler = make_absolute(Config.get("compiler", "cuda", "executable"))
        flags = Config.get("compiler", "cuda", "args")
        flags += Config.get("compiler", "cuda", "additional_args")

        # Get CUDA architectures from configuration
        cuda_arch = Config.get('compiler', 'cuda', 'cuda_arch').split(',')
        cuda_arch = [ca for ca in cuda_arch if ca is not None and len(ca) > 0]

        flags += ' ' + ' '.join(
            '-gencode arch=compute_{arch},code=sm_{arch}'.format(arch=arch)
            for arch in cuda_arch)

        options = [
            "-DCUDA_HOST_COMPILER=\"{}\"".format(host_compiler),
            "-DCUDA_NVCC_FLAGS=\"{}\"".format(flags),
            "-DCUDA_TOOLKIT_ROOT_DIR=\"{}\"".format(
                os.path.dirname(os.path.dirname(compiler).replace('\\', '/')))
        ]
github spcl / dace / dace / codegen / targets / cpp.py View on Github external
node.language))
        function_stream.write(
            type(node).__properties__["code_global"].to_string(
                node.code_global),
            sdfg,
            state_id,
            node,
        )
        function_stream.write("\n", sdfg, state_id, node)

    # If raw C++ code, return the code directly
    if node.language != dtypes.Language.Python:
        # If this code runs on the host and is associated with a CUDA stream,
        # set the stream to a local variable.
        max_streams = int(
            Config.get("compiler", "cuda", "max_concurrent_streams"))
        if (max_streams >= 0 and not is_devicelevel(sdfg, state_dfg, node)
                and hasattr(node, "_cuda_stream")):
            callsite_stream.write(
                'int __dace_current_stream_id = %d;\ncudaStream_t __dace_current_stream = dace::cuda::__streams[__dace_current_stream_id];'
                % node._cuda_stream,
                sdfg,
                state_id,
                node,
            )

        if node.language != dtypes.Language.CPP:
            raise ValueError(
                "Only Python or C++ code supported in CPU codegen, got: {}".
                format(node.language))
        callsite_stream.write(
            type(node).__properties__["code"].to_string(node.code), sdfg,
github spcl / dace / dace / codegen / targets / intel_fpga.py View on Github external
def cmake_options():

        compiler = make_absolute(
            Config.get("compiler", "intel_fpga", "executable"))
        host_flags = Config.get("compiler", "intel_fpga", "host_flags")
        kernel_flags = Config.get("compiler", "intel_fpga", "kernel_flags")
        mode = Config.get("compiler", "intel_fpga", "mode")
        target_board = Config.get("compiler", "intel_fpga", "board")
        enable_debugging = ("ON" if Config.get_bool(
            "compiler", "intel_fpga", "enable_debugging") else "OFF")
        options = [
            "-DINTELFPGAOCL_ROOT_DIR={}".format(
                os.path.dirname(os.path.dirname(compiler))),
            "-DDACE_INTELFPGA_HOST_FLAGS=\"{}\"".format(host_flags),
            "-DDACE_INTELFPGA_KERNEL_FLAGS=\"{}\"".format(kernel_flags),
            "-DDACE_INTELFPGA_MODE={}".format(mode),
            "-DDACE_INTELFPGA_TARGET_BOARD=\"{}\"".format(target_board),
            "-DDACE_INTELFPGA_ENABLE_DEBUGGING={}".format(enable_debugging),
        ]
        return options
github spcl / dace / diode / diode1.py View on Github external
pypane = self.builder.get_object("TopLeftPane")
        optgraphpane = self.builder.get_object("TopRightPane")
        codepane = self.builder.get_object("BottomPane")
        perfpane = self.builder.get_object("BottomRightPane")

        # Top pane
        toppane_height = float(Config.get('diode', 'layout', 'toppane_height'))
        pypane_width = float(Config.get('diode', 'layout', 'pypane_width'))
        optgraph_width = float(Config.get('diode', 'layout', 'optpane_width'))
        toppane.set_position((toppane_height / 100.0) * height)
        pypane.set_position((pypane_width / 100.0) * width)
        optgraphpane.set_position((optgraph_width / 100.0) * width)

        # Bottom pane
        codepane_width = float(Config.get('diode', 'layout', 'codepane_width'))
        perfpane_width = float(Config.get('diode', 'layout', 'perfpane_width'))
        codepane.set_position((codepane_width / 100.0) * width)
        perfpane.set_position((perfpane_width / 100.0) * width)
github spcl / dace / dace / graph / nodes.py View on Github external
def expand(self, sdfg, *args, **kwargs):
        """Create and perform the expansion transformation for this library
           node."""
        implementation = self.implementation
        library_name = type(self)._dace_library_name
        try:
            config_implementation = Config.get("library", library_name,
                                               "default_implementation")
        except KeyError:
            # Non-standard libraries are not defined in the config schema, and
            # thus might not exist in the config.
            config_implementation = None
        if config_implementation is not None:
            try:
                config_override = Config.get("library", library_name,
                                             "override")
                if config_override:
                    if implementation is not None:
                        warnings.warn(
                            "Overriding explicitly specified "
                            "implementation {} for {} with {}.".format(
                                implementation, self.label,
                                config_implementation))
                    implementation = config_implementation
            except KeyError:
                config_override = False
        # If not explicitly set, try the node default
        if implementation is None:
            implementation = type(self).default_implementation
            # If no node default, try library default
            if implementation is None:
github spcl / dace / dace / sdfg / sdfg.py View on Github external
def _get_optimizer_class(class_override):
    """ Imports and returns a class string defined in the configuration
        (under "optimizer.interface") or overridden in the input
        class_override argument. Empty string, False, or failure to find the
        class skips the process.

        @note: This method uses pydoc to locate the class.
    """
    clazz = class_override
    if class_override is None:
        clazz = Config.get("optimizer", "interface")

    if clazz == "" or clazz is False or str(clazz).strip() == "":
        return None

    result = locate(clazz)
    if result is None:
        warnings.warn('Optimizer interface class "%s" not found' % clazz)

    return result
github spcl / dace / dace / codegen / targets / xilinx.py View on Github external
def __init__(self, *args, **kwargs):
        fpga_vendor = Config.get("compiler", "fpga_vendor")
        if fpga_vendor.lower() != "xilinx":
            # Don't register this code generator
            return
        super().__init__(*args, **kwargs)
github spcl / dace / dace / sdfg.py View on Github external
def _get_optimizer_class(class_override):
    """ Imports and returns a class string defined in the configuration
        (under "optimizer.interface") or overridden in the input
        class_override argument. Empty string, False, or failure to find the
        class skips the process.

        @note: This method uses pydoc to locate the class.
    """
    clazz = class_override
    if class_override is None:
        clazz = Config.get('optimizer', 'interface')

    if clazz == '' or clazz == False:
        return None

    result = locate(clazz)
    if result is None:
        print('WARNING: Optimizer interface class "%s" not found' % clazz)

    return result