Sorry, that was just some pseudocode. I was trying to avoid posting the actual code, but I guess I will at this point since I’m not getting anywhere. The
__device__ EnvInterpSpaceHashEntry_t* CreateNewHashEntry(EnvInterpSpaceHashEntry_t StateTable[][25], int* BinTable, EnvInterpSpaceHashEntry_t* HashEntryIn, int* entries, EnvInterpSpaceHashEntry_t* IDTable[MAXSTATES])
{
int i;
// don't think that this is needed
HashEntryIn->stateID = *(entries);
i = GETHASHBIN(HashEntryIn);
int numElemBin = BinTable[i];
StateTable[i][numElemBin].stateID = HashEntryIn->stateID;
StateTable[i][numElemBin].time = HashEntryIn->time;
StateTable[i][numElemBin].rootPosX = HashEntryIn->rootPosX;
StateTable[i][numElemBin].rootPosZ = HashEntryIn->rootPosZ;
StateTable[i][numElemBin].rootOrientY = HashEntryIn->rootOrientY;
StateTable[i][numElemBin].interp_weight = HashEntryIn->interp_weight;
StateTable[i][numElemBin].graphNode = HashEntryIn->graphNode;
StateTable[i][numElemBin].curveCorresp = HashEntryIn->curveCorresp;
StateTable[i][numElemBin].closestPathPt = HashEntryIn->closestPathPt;
StateTable[i][numElemBin].constrCounter = HashEntryIn->constrCounter;
StateTable[i][numElemBin].interpCounter = HashEntryIn->interpCounter;
BinTable[i]++;
(*entries)++;
**********IDTable[HashEntryIn->stateID] = &StateTable[i][numElemBin];***********
return HashEntryIn;
}
__device__ int addHashTable(EnvInterpSpaceHashEntry_t StateTable[][25], int* BinTable, EnvInterpSpaceHashEntry_t* HashEntryIn, int* entries, EnvInterpSpaceHashEntry_t* IDTable[MAXSTATES])
{
EnvInterpSpaceHashEntry_t* OutHashEntry;
//add the outcome
if((OutHashEntry = GetHashEntry(StateTable, BinTable, HashEntryIn)) == NULL)
{
//have to create a new entry
OutHashEntry = CreateNewHashEntry(StateTable, BinTable, HashEntryIn, entries,IDTable);
}
return OutHashEntry->stateID;
}
__global__ void GPUSearch(int *entries, int *lastID, unsigned short int *tt)
{
SearchStateSpace_t pSearchStateSpace;
CreateSearchStateSpace(&pSearchStateSpace);
int rootPosX, rootPosZ, rootOrientY;
discretizeRootPos(WALK_START_ROOT_POS_X, rootPosX);
discretizeRootPos(WALK_START_ROOT_POS_Z, rootPosZ);
discretizeAngles(WALK_START_ROOT_ORIENT_Y, rootOrientY);
gNode startNode;
gNode goalNode;
startNode.motNum = 0;
startNode.posNum = 0;
goalNode.motNum = 0;
goalNode.posNum = 0;
//int entries;
*(entries) = 0;
typedef EnvInterpSpaceHashEntry_t EnvInterpHashTable_t [HASHTABLESIZE][BINSIZE];
EnvInterpHashTable_t Coord2IDTable;
int BinTable[HASHTABLESIZE];
EnvInterpSpaceHashEntry_t *ID2CoordTable[MAXSTATES];
initBinTable(BinTable);
EnvInterpSpaceHashEntry_t hashEntryStart;
SetHashEntry(hashEntryStart, nMotionEndTime+1000,
rootPosX, rootPosZ, rootOrientY,
0, startNode, 0, 0, 0, 0);
EnvInterpSpaceHashEntry_t hashEntryGoal;
SetHashEntry(hashEntryGoal, nMotionEndTime + 2000,
0, 0, 0,
0, goalNode, 0, 0, 0, 0);
int stateIDStart = addHashTable(Coord2IDTable,BinTable,&hashEntryStart,entries,ID2CoordTable);
int stateIDGoal = addHashTable(Coord2IDTable,BinTable,&hashEntryGoal,entries, ID2CoordTable);
************* *(tt) = Coord2IDTable[1][0].time; //this line works fine
//tt = &(ID2CoordTable[0]->time); //this line causes the crash **************
[B]/* if i do this, the code works fine...
ID2CoordTable[0] = &Coord2IDTable[1][0];
*(tt) = ID2CoordTable[0]->time; */[/B]
*(lastID) = stateIDGoal;
//*(lastID) = myTemp;
//*(lastID) = 8;
}
So what I can’t figure out is what happens to the array when it gets passed in to addHashTable. For some reason, the addresses are no longer valid after the call returns. Sorry if this is sloppy. I really have to run out right now, but figured I’d post this. Thanks Mark!
EDIT: I didn’t realize that I couldn’t put bold within the CODE tags, so I put asterisks on the lines I’m having problems with.