Hi All,
When I try to run my code using the device mode I get this error:
Unhandled exception at 0x1000feed in PSO_GPU.exe: 0xC0000005: Access violation writing location 0x01000600.
This error is happening in the third line inside the main function :cudaMalloc((void **) &S_d->sdVar, SD * sizeof(SDVAR ));
I am using Visual C++ 2005 and Geforce GTX 285 (Driver Version 6.14.11.8120)
It seems I am missing something before calling the cudaMalloc, but I don’t know what it’s.
Your help is really appreciated.
–OA
[codebox]int main ()
{
Swarm * S_d ;
cudaMalloc((void **) &S_d, sizeof(Swarm));
//printf("Size of SDVAR= %d\n",sizeof(SDVAR));
cudaMalloc((void **) &S_d->sdVar, SD * sizeof(SDVAR ));
cudaMalloc((void **) &S_d->pVar, (N*N*NUM_TRX)*sizeof(PVAR ));
cudaMalloc((void **) &S_d->tVar, (N*N*NUM_TRX)*sizeof(TVAR ));
}[/codebox][codebox]#ifndef SWARM_HEADER_H
#define SWARM_HEADER_H
#include “Constants.h”
typedef struct
{
int * X_sd;
}SDVAR;
typedef struct
{
float * X_Power;
}PVAR;
typedef struct
{
float * X_Theta;
}TVAR;
typedef struct
{
float * penalty;
}SDPENALTY;
typedef struct
{
float * channelCapacity;
}OUTTOPOLOGY;
typedef struct
{
SDVAR ** sdVar;
PVAR ** pVar;
TVAR ** tVar;
SDVAR ** V_sdVar;
PVAR ** V_pVar;
TVAR ** V_tVar;
SDVAR ** pl_sdVar;
PVAR ** pl_pVar;
TVAR ** pl_tVar;
int * pg_sdVar;
float * pg_pVar;
float * pg_tVar;
SDPENALTY ** sdPenalty;
OUTTOPOLOGY ** _outputTopology;
float * plFitness;
int swarmSize;
float bestSwarmFitness; // best ever fitness
int trial;
}Swarm;
/////////////////////////////////////////////////////////////////////////////////////////////////////[/codebox]