 #include "gpugas.h"
 
 
-struct BFSBase
+//nvcc doesn't like the __device__ variable to be a static member inside BFS
+//so these are both outside.
+int g_iterationCount;
+__device__ __constant__ int g_iterationCountGPU;
+
+
+struct BFS
 {
   struct VertexData
   {

};


//How can we factor these correctly?
//The __device__ qualifier can not be made template-conditional, so template
//based workarounds are not possible.
int g_iterationCount;
__device__ __constant__ int g_iterationCountGPU;

struct BFSHost : public BFSBase
{
  static bool apply(VertexData* vert, int dist)
  {
    if( vert->depth == -1 )
    {
      vert->depth = g_iterationCount;
      return true;
    }
    return false;
  }
};


struct BFSDev : public BFSBase
{
  __device__
  static bool apply(VertexData* vert, int dist)
  {
    if( vert->depth == -1 )
    {
      vert->depth = g_iterationCountGPU;
      return true;
    }
    return false;
  }
};


int main(int argc, char** argv)

  //run on host
  {
    //initialize vertex data
    std::vector<BFS::VertexData> vertexData(nVertices);
    for( int i = 0; i < nVertices; ++i )
      vertexData[i].depth = -1; 

    GASEngineRef<BFS> engine;
    engine.setGraph(nVertices, &vertexData[0], srcs.size(), 0, &srcs[0], &dsts[0]);
    engine.setActive(sourceVertex, sourceVertex+1);
    g_iterationCount = 0;
