Skip to content

Commit

Permalink
Modify templates
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbabu committed Jun 22, 2023
1 parent 3f35690 commit 920ea74
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 41 deletions.
44 changes: 22 additions & 22 deletions pynestml/codegeneration/resources_nest_gpu/@NEURON_NAME@.cu.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* aeif_psc_exp.cu
* {{ neuronName }}.cu
*
* This file is part of NEST GPU.
*
Expand All @@ -23,16 +23,16 @@
#include <config.h>
#include <cmath>
#include <iostream>
#include "aeif_psc_exp_kernel.h"
#include "{{ neuronName }}_kernel.h"
#include "rk5.h"
#include "aeif_psc_exp.h"
#include "{{ neuronName }}.h"

namespace aeif_psc_exp_ns
namespace {{ neuronName }}_ns
{

__device__
void NodeInit(int n_var, int n_param, double x, float *y, float *param,
aeif_psc_exp_rk5 data_struct)
{{ neuronName }}_rk5 data_struct)
{
//int array_idx = threadIdx.x + blockIdx.x * blockDim.x;
int n_port = (n_var-N_SCAL_VAR)/N_PORT_VAR;
Expand Down Expand Up @@ -62,7 +62,7 @@ void NodeInit(int n_var, int n_param, double x, float *y, float *param,

__device__
void NodeCalibrate(int n_var, int n_param, double x, float *y,
float *param, aeif_psc_exp_rk5 data_struct)
float *param, {{ neuronName }}p_rk5 data_struct)
{
//int array_idx = threadIdx.x + blockIdx.x * blockDim.x;
//int n_port = (n_var-N_SCAL_VAR)/N_PORT_VAR;
Expand All @@ -78,25 +78,25 @@ void NodeCalibrate(int n_var, int n_param, double x, float *y,

__device__
void NodeInit(int n_var, int n_param, double x, float *y,
float *param, aeif_psc_exp_rk5 data_struct)
float *param, {{ neuronName }}_rk5 data_struct)
{
aeif_psc_exp_ns::NodeInit(n_var, n_param, x, y, param, data_struct);
{{ neuronName }}_ns::NodeInit(n_var, n_param, x, y, param, data_struct);
}

__device__
void NodeCalibrate(int n_var, int n_param, double x, float *y,
float *param, aeif_psc_exp_rk5 data_struct)
float *param, {{ neuronName }}_rk5 data_struct)

{
aeif_psc_exp_ns::NodeCalibrate(n_var, n_param, x, y, param, data_struct);
{{ neuronName }}_ns::NodeCalibrate(n_var, n_param, x, y, param, data_struct);
}

using namespace aeif_psc_exp_ns;
using namespace {{ neuronName }}_ns;

int aeif_psc_exp::Init(int i_node_0, int n_node, int n_port,
int {{ neuronName }}::Init(int i_node_0, int n_node, int n_port,
int i_group, unsigned long long *seed) {
BaseNeuron::Init(i_node_0, n_node, n_port, i_group, seed);
node_type_ = i_aeif_psc_exp_model;
node_type_ = i_{{ neuronName }}_model;
n_scal_var_ = N_SCAL_VAR;
n_port_var_ = N_PORT_VAR;
n_scal_param_ = N_SCAL_PARAM;
Expand All @@ -108,12 +108,12 @@ int aeif_psc_exp::Init(int i_node_0, int n_node, int n_port,

group_param_ = new float[N_GROUP_PARAM];

scal_var_name_ = aeif_psc_exp_scal_var_name;
port_var_name_= aeif_psc_exp_port_var_name;
scal_param_name_ = aeif_psc_exp_scal_param_name;
port_param_name_ = aeif_psc_exp_port_param_name;
group_param_name_ = aeif_psc_exp_group_param_name;
//rk5_data_struct_.node_type_ = i_aeif_psc_exp_model;
scal_var_name_ = {{ neuronName }}_scal_var_name;
port_var_name_= {{ neuronName }}_port_var_name;
scal_param_name_ = {{ neuronName }}_scal_param_name;
port_param_name_ = {{ neuronName }}_port_param_name;
group_param_name_ = {{ neuronName }}_group_param_name;
//rk5_data_struct_.node_type_ = i_{{ neuronName }}_model;
rk5_data_struct_.i_node_0_ = i_node_0_;

SetGroupParam("h_min_rel", 1.0e-3);
Expand Down Expand Up @@ -141,7 +141,7 @@ int aeif_psc_exp::Init(int i_node_0, int n_node, int n_port,
return 0;
}

int aeif_psc_exp::Calibrate(double time_min, float time_resolution)
int {{ neuronName }}::Calibrate(double time_min, float time_resolution)
{
h_min_ = h_min_rel_* time_resolution;
h_ = h0_rel_* time_resolution;
Expand All @@ -151,12 +151,12 @@ int aeif_psc_exp::Calibrate(double time_min, float time_resolution)
}

template <>
int aeif_psc_exp::UpdateNR<0>(long long it, double t1)
int {{ neuronName }}::UpdateNR<0>(long long it, double t1)
{
return 0;
}

int aeif_psc_exp::Update(long long it, double t1) {
int {{ neuronName }}::Update(long long it, double t1) {
UpdateNR<MAX_PORT_NUM>(it, t1);

return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* aeif_psc_exp.h
* {{ neuronName }}.h
*
* This file is part of NEST GPU.
*
Expand Down Expand Up @@ -42,7 +42,7 @@ Current-based exponential integrate-and-fire neuron model
Description
+++++++++++

aeif_psc_exp is the adaptive exponential integrate and fire neuron
{{ neuronName }} is the adaptive exponential integrate and fire neuron
according to [1]_, with postsynaptic currents in the form of
truncated exponentials.

Expand Down Expand Up @@ -145,18 +145,18 @@ EndUserDocs */

#define MAX_PORT_NUM 20

struct aeif_psc_exp_rk5
struct {{ neuronName }}_rk5
{
int i_node_0_;
};

class aeif_psc_exp : public BaseNeuron
class {{ neuronName }} : public BaseNeuron
{
public:
RungeKutta5<aeif_psc_exp_rk5> rk5_;
RungeKutta5<{{ neuronName }}_rk5> rk5_;
float h_min_;
float h_;
aeif_psc_exp_rk5 rk5_data_struct_;
{{ neuronName }}_rk5 rk5_data_struct_;

int Init(int i_node_0, int n_neuron, int n_port, int i_group,
unsigned long long *seed);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* aeif_psc_exp_kernel.h
* {{ neuronName }}_kernel.h
*
* This file is part of NEST GPU.
*
Expand Down Expand Up @@ -31,13 +31,13 @@
#include <cmath>
#include "spike_buffer.h"
#include "node_group.h"
#include "aeif_psc_exp.h"
#include "{{ neuronName }}.h"

#define MIN(a,b) (((a)<(b))?(a):(b))

extern __constant__ float NESTGPUTimeResolution;

namespace aeif_psc_exp_ns
namespace {{ neuronName }}_ns
{
enum ScalVarIndexes {
i_I_syn_ex = 0,
Expand Down Expand Up @@ -73,14 +73,14 @@ enum GroupParamIndexes {
N_GROUP_PARAM
};

const std::string aeif_psc_exp_scal_var_name[N_SCAL_VAR] = {
const std::string {{ neuronName }}_scal_var_name[N_SCAL_VAR] = {
"I_syn_ex",
"I_syn_in",
"V_m",
"w"
};

const std::string aeif_psc_exp_scal_param_name[N_SCAL_PARAM] = {
const std::string {{ neuronName }}_scal_param_name[N_SCAL_PARAM] = {
"tau_syn_ex",
"tau_syn_in",
"V_th",
Expand All @@ -99,7 +99,7 @@ const std::string aeif_psc_exp_scal_param_name[N_SCAL_PARAM] = {
"den_delay"
};

const std::string aeif_psc_exp_group_param_name[N_GROUP_PARAM] = {
const std::string {{ neuronName }}_group_param_name[N_GROUP_PARAM] = {
"h_min_rel",
"h0_rel"
};
Expand Down Expand Up @@ -143,7 +143,7 @@ const std::string aeif_psc_exp_group_param_name[N_GROUP_PARAM] = {
template<int NVAR, int NPARAM> //, class DataStruct>
__device__
void Derivatives(double x, float *y, float *dydx, float *param,
aeif_psc_exp_rk5 data_struct)
{{ neuronName }}_rk5 data_struct)
{
float I_syn_tot = 0.0;
I_syn_tot += I_syn_ex - I_syn_in;
Expand All @@ -164,7 +164,7 @@ __device__
__device__
void ExternalUpdate
(double x, float *y, float *param, bool end_time_step,
aeif_psc_exp_rk5 data_struct)
{{ neuronName }}_rk5 data_struct)
{
if ( V_m < -1.0e3) { // numerical instability
printf("V_m out of lower bound\n");
Expand Down Expand Up @@ -207,18 +207,18 @@ int Update(long long it, double t1);
template<int NVAR, int NPARAM>
__device__
void Derivatives(double x, float *y, float *dydx, float *param,
aeif_psc_exp_rk5 data_struct)
{{ neuronName }}_rk5 data_struct)
{
aeif_psc_exp_ns::Derivatives<NVAR, NPARAM>(x, y, dydx, param,
{{ neuronName }}_ns::Derivatives<NVAR, NPARAM>(x, y, dydx, param,
data_struct);
}

template<int NVAR, int NPARAM>
__device__
void ExternalUpdate(double x, float *y, float *param, bool end_time_step,
aeif_psc_exp_rk5 data_struct)
{{ neuronName }}_rk5 data_struct)
{
aeif_psc_exp_ns::ExternalUpdate<NVAR, NPARAM>(x, y, param,
{{ neuronName }}_ns::ExternalUpdate<NVAR, NPARAM>(x, y, param,
end_time_step,
data_struct);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{#-
NeuronHeader_rk5.h.jinja2
{{neuronName}}_rk5.h.jinja2
This file is part of NEST.
Expand Down

0 comments on commit 920ea74

Please sign in to comment.