GeNN  3.3.0
GPU enhanced Neuronal Networks (GeNN)
utils.h File Reference

This file contains standard utility functions provide within the NVIDIA CUDA software development toolkit (SDK). The remainder of the file contains a function that defines the standard neuron models. More...

#include <cstdlib>
#include <iostream>
#include <string>
#include <cuda.h>
#include <cuda_runtime.h>

Go to the source code of this file.

Macros

#define _UTILS_H_
 macro for avoiding multiple inclusion during compilation More...
 
#define CHECK_CU_ERRORS(call)   call
 Macros for catching errors returned by the CUDA driver and runtime APIs. More...
 
#define CHECK_CUDA_ERRORS(call)
 
#define B(x, i)   ((x) & (0x80000000 >> (i)))
 Bit tool macros. More...
 
#define setB(x, i)   x= ((x) | (0x80000000 >> (i)))
 Set the bit at the specified position i in x to 1. More...
 
#define delB(x, i)   x= ((x) & (~(0x80000000 >> (i))))
 Set the bit at the specified position i in x to 0. More...
 
#define USE(expr)   do { (void)(expr); } while (0)
 Miscellaneous macros. More...
 

Functions

CUresult cudaFuncGetAttributesDriver (cudaFuncAttributes *attr, CUfunction kern)
 Function for getting the capabilities of a CUDA device via the driver API. More...
 
void gennError (const string &error)
 Function called upon the detection of an error. Outputs an error message and then exits. More...
 
size_t theSize (const string &type)
 Tool for determining the size of variable types on the current architecture. More...
 
void writeHeader (CodeStream &os)
 Function to write the comment header denoting file authorship and contact details into the generated code. More...
 

Detailed Description

This file contains standard utility functions provide within the NVIDIA CUDA software development toolkit (SDK). The remainder of the file contains a function that defines the standard neuron models.

Macro Definition Documentation

◆ _UTILS_H_

#define _UTILS_H_

macro for avoiding multiple inclusion during compilation

◆ B

#define B (   x,
 
)    ((x) & (0x80000000 >> (i)))

Bit tool macros.

Extract the bit at the specified position i from x

◆ CHECK_CU_ERRORS

#define CHECK_CU_ERRORS (   call)    call

Macros for catching errors returned by the CUDA driver and runtime APIs.

◆ CHECK_CUDA_ERRORS

#define CHECK_CUDA_ERRORS (   call)
Value:
{ \
cudaError_t error = call; \
if (error != cudaSuccess) \
{ \
cerr << __FILE__ << ": " << __LINE__; \
cerr << ": cuda runtime error " << error << ": "; \
cerr << cudaGetErrorString(error) << endl; \
exit(EXIT_FAILURE); \
} \
}

◆ delB

#define delB (   x,
 
)    x= ((x) & (~(0x80000000 >> (i))))

Set the bit at the specified position i in x to 0.

◆ setB

#define setB (   x,
 
)    x= ((x) | (0x80000000 >> (i)))

Set the bit at the specified position i in x to 1.

◆ USE

#define USE (   expr)    do { (void)(expr); } while (0)

Miscellaneous macros.

Silence 'unused parameter' warnings

Function Documentation

◆ cudaFuncGetAttributesDriver()

CUresult cudaFuncGetAttributesDriver ( cudaFuncAttributes *  attr,
CUfunction  kern 
)

Function for getting the capabilities of a CUDA device via the driver API.

◆ gennError()

void gennError ( const string &  error)
inline

Function called upon the detection of an error. Outputs an error message and then exits.

◆ theSize()

size_t theSize ( const string &  type)

Tool for determining the size of variable types on the current architecture.

◆ writeHeader()

void writeHeader ( CodeStream os)

Function to write the comment header denoting file authorship and contact details into the generated code.