Example #1
0
    def create_arrays(self, ignore=None, supplied=None):
        """
        Create any necessary arrays on the solver. 

        Arguments
        ---------
            ignore : list
                List of array names to ignore.
            supplied : dictionary
                A dictionary of supplied arrays to create
                on the solver, keyed by name. Note that
                these arrays will not be initialised by
                montblanc, it is the responsibility of the
                user to initialise them.
        """
        if ignore is None:
            ignore = []

        if supplied is None:
            supplied = {}

        reified_arrays = self.arrays(reify=True)
        create_arrays = self._arrays_to_create(reified_arrays,
                                               ignore=ignore,
                                               supplied=supplied)

        # Create local arrays on the cube
        create_local_arrays_on_cube(self,
                                    create_arrays,
                                    array_stitch=generic_stitch,
                                    array_factory=np.empty)

        self._validate_supplied_arrays(reified_arrays, supplied)

        # Stitch the supplied arrays onto the cube
        generic_stitch(self, supplied)

        # Get our data source
        data_source = self._slvr_cfg[Options.DATA_SOURCE]

        # Initialise the arrays that we have created,
        # but not the supplied or ignored arrays
        for name, array in create_arrays.iteritems():
            cpu_ary = getattr(self, name)

            if data_source == Options.DATA_SOURCE_TEST:
                value = array.get(Options.DATA_SOURCE_TEST, None)
                self.init_array(name, cpu_ary, value)
            elif data_source == Options.DATA_SOURCE_EMPTY:
                pass
            else:
                self.init_array(name, cpu_ary,
                                array.get(Options.DATA_SOURCE_DEFAULT, None))
Example #2
0
    def create_arrays(self, ignore=None, supplied=None):
        """
        Create any necessary arrays on the solver. 

        Arguments
        ---------
            ignore : list
                List of array names to ignore.
            supplied : dictionary
                A dictionary of supplied arrays to create
                on the solver, keyed by name. Note that
                these arrays will not be initialised by
                montblanc, it is the responsibility of the
                user to initialise them.
        """
        if ignore is None:
            ignore = []

        if supplied is None:
            supplied = {}

        reified_arrays = self.arrays(reify=True)
        create_arrays = self._arrays_to_create(reified_arrays,
            ignore=ignore, supplied=supplied)

        # Create local arrays on the cube
        create_local_arrays_on_cube(self, create_arrays,
            array_stitch=generic_stitch,
            array_factory=np.empty)

        self._validate_supplied_arrays(reified_arrays, supplied)

        # Stitch the supplied arrays onto the cube
        generic_stitch(self, supplied)

        # Get our data source
        data_source = self._slvr_cfg[Options.DATA_SOURCE]

        # Initialise the arrays that we have created,
        # but not the supplied or ignored arrays
        for name, array in create_arrays.iteritems():
            cpu_ary = getattr(self, name)

            if data_source == Options.DATA_SOURCE_TEST:
                value = array.get(Options.DATA_SOURCE_TEST, None)
                self.init_array(name, cpu_ary, value)
            elif data_source == Options.DATA_SOURCE_EMPTY:
                pass
            else:
                self.init_array(name, cpu_ary,
                    array.get(Options.DATA_SOURCE_DEFAULT, None))    
Example #3
0
    def create_arrays(self, ignore=None, supplied=None):
        """
        Create any necessary arrays on the solver. 

        Arguments
        ---------
            ignore : list
                List of array names to ignore.
            supplied : dictionary
                A dictionary of supplied arrays to create
                on the solver, keyed by name. Note that
                these arrays will not be initialised by
                montblanc, it is the responsibility of the
                user to initialise them.
        """

        import pycuda.driver as cuda

        if ignore is None:
            ignore = []

        if supplied is None:
            supplied = {}

        reified_arrays = self.arrays(reify=True)
        create_arrays = self._arrays_to_create(reified_arrays,
            ignore=ignore, supplied=supplied)

        with self.context:
            # Create local arrays on the cube
            create_local_arrays_on_cube(self, create_arrays,
                array_stitch=generic_stitch,
                array_factory=gpuarray_factory)

            self._validate_supplied_arrays(reified_arrays, supplied)

            # Stitch the supplied arrays onto the cube
            generic_stitch(self, supplied)

            # Get our data source
            data_source = self._slvr_cfg[Options.DATA_SOURCE]

            for name, array in create_arrays.iteritems():
                self.initialise_gpu_array(name, array, data_source)
Example #4
0
    def create_arrays(self, ignore=None, supplied=None):
        """
        Create any necessary arrays on the solver. 

        Arguments
        ---------
            ignore : list
                List of array names to ignore.
            supplied : dictionary
                A dictionary of supplied arrays to create
                on the solver, keyed by name. Note that
                these arrays will not be initialised by
                montblanc, it is the responsibility of the
                user to initialise them.
        """

        import pycuda.driver as cuda

        if ignore is None:
            ignore = []

        if supplied is None:
            supplied = {}

        reified_arrays = self.arrays(reify=True)
        create_arrays = self._arrays_to_create(reified_arrays, ignore=ignore, supplied=supplied)

        with self.context:
            # Create local arrays on the cube
            create_local_arrays_on_cube(
                self, create_arrays, array_stitch=generic_stitch, array_factory=gpuarray_factory
            )

            self._validate_supplied_arrays(reified_arrays, supplied)

            # Stitch the supplied arrays onto the cube
            generic_stitch(self, supplied)

            # Get our data source
            data_source = self._slvr_cfg[Options.DATA_SOURCE]

            for name, array in create_arrays.iteritems():
                self.initialise_gpu_array(name, array, data_source)