def _generate(self): """ Overrides default code generation. This function is called during the code generation procedure. """ # Filter definition filter_definition, filter_pyx_definition = self._filter_definition() # Convolve_code if not self.multiple: convolve_code, sum_code = self._generate_convolve_code() else: convolve_code, sum_code = self._generate_bank_code() if Global._check_paradigm("openmp"): self._generate_omp(filter_definition, filter_pyx_definition, convolve_code, sum_code) elif Global._check_paradigm("cuda"): raise Global.ANNarchyException( "Convolution is not available on CUDA devices yet.", True) else: raise NotImplementedError
def _check_storage_formats(projections): """ ANNarchy 4.7 introduced a set of sparse matrix formats. Some of them are not implemented for all paradigms or might not support specific optimizations. """ for proj in projections: # Most of the sparse matrix formats are not trivially invertable and therefore we can not implement # spiking models with them if proj.synapse_type.type == "spike" and proj._storage_format in [ "ell", "ellr", "coo", "hyb" ]: raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is not allowed for spiking synapses.", True) # Dense format is not implemented for GPUs and spiking models if proj._storage_format == "dense" and proj.synapse_type.type == "spike" and Global._check_paradigm( "cuda"): raise Global.ANNarchyException( "Dense representation is not available for spiking models on GPUs yet.", True) # For some of the sparse matrix formats we don't implemented plasticity yet. if proj.synapse_type.type == "spike" and proj._storage_format in [ "dense" ] and not isinstance(proj.synapse_type, DefaultSpikingSynapse): raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is only allowed for default spiking synapses yet.", True) # For some of the sparse matrix formats we don't implemented plasticity yet. if proj.synapse_type.type == "rate" and proj._storage_format in [ "coo", "hyb" ] and not isinstance(proj.synapse_type, DefaultRateCodedSynapse): raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is only allowed for default rate-coded synapses yet.", True) # OpenMP disabled? if proj._storage_format in ["bsr" ] and Global.config["num_threads"] > 1: raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is not available for OpenMP yet.", True) # Single weight optimization available? if proj._has_single_weight() and proj._storage_format in ["dense"]: raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is not allowed for single weight projections.", True) # Slicing available? if isinstance(proj.post, PopulationView) and proj._storage_format in ["dense"]: raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is not allowed for PopulationViews as target.", True) # In some cases we don't allow the usage of non-unifom delay if (proj.max_delay > 1 and proj.uniform_delay == -1): if Global._check_paradigm("cuda"): raise Global.ANNarchyException( "Using non-uniform delays is not available for CUDA devices.", True) else: if proj._storage_format == "ellr": raise Global.ANNarchyException( "Using 'storage_format=" + proj._storage_format + "' is and non-uniform delays is not implemented.", True) if Global._check_paradigm("cuda") and proj._storage_format == "lil": proj._storage_format = "csr" Global._info( "LIL-type projections are not available for GPU devices ... default to CSR" ) if Global._check_paradigm("cuda") and proj._storage_format == "ell": Global._info( "We would recommend to use ELLPACK-R (format=ellr) on GPUs.")
def _generate_cuda(self): raise Global.ANNarchyException( "The DecodingProjection is not available on CUDA devices.", True)