20 lines
1,004 B
C++
20 lines
1,004 B
C++
#include "altai_cuda_runtime.h"
|
|
#include <iostream>
|
|
int main() try {
|
|
using namespace knp_altai_cuda;
|
|
Runtime r;
|
|
r.initialize(0);
|
|
NeuronState state{0,0,0,3,0,0,0,2|4|8};
|
|
long long input[2]={4,0}, absolute[2]={4,0}, events[2]={1,0};
|
|
auto neurons=r.allocate(sizeof(state),&state), pending=r.allocate(sizeof(input),input),
|
|
abs=r.allocate(sizeof(absolute),absolute), ev=r.allocate(sizeof(events),events),
|
|
spikes=r.allocate(1), error=r.allocate(4);
|
|
int n=1,slots=2; unsigned long long step=0;
|
|
void *args[]={&neurons,&pending,&abs,&ev,&spikes,&error,&n,&slots,&step};
|
|
r.launch(r.population_kernel,1,args);
|
|
unsigned char spike=0;
|
|
checked(cuMemcpyDtoH(&spike,spikes,1));
|
|
checked(cuMemcpyDtoH(&state,neurons,sizeof(state)));
|
|
if (spike!=1 || state.potential!=0 || state.activity!=INT64_MAX) return 2;
|
|
std::cout << "CUDA NVRTC/Driver kernel OK: spike=1 potential=0\n";
|
|
} catch(const std::exception &e) { std::cerr<<e.what()<<'\n';return 1; }
|