Esempio n. 1
0
bool LoadGPUVectorFromFile(std::string &filename, TType &data)
{
  std::string extension = utils::GetFileExtension(filename);
  std::cout << "trying to load data from: " << filename << " | Extension: " << extension << std::endl;

  std::vector<typename TType::value_type> dataHost;  
  if (extension.compare(".bin") == 0)
  {
   if (!agile::readVectorFile(filename.c_str(), dataHost))
    {
      return false;
    }
    data.assignFromHost(dataHost.begin(), dataHost.end());
    std::cout << "norm vector: " << agile::norm1(data) << std::endl;
  }
  else if (extension.compare(".cfl") == 0)
  {
    long dimensions[4];//Dimension dimsread; // = op.dims;
    //for (int i=0; i < 4; i++)
    //   dimensions[i]=1;

    utils::ReadCflHeader(filename, dimensions);
    
    unsigned N = dimensions[0];
    for (int i=1; i < 4; i++)
      N=N*dimensions[i];

    //unsigned N = dimsread.width*dimsread.height*dimsread.depth*dimsread.coils;
    std::cout << "N= " << N << std::endl;
    //if (!agile::readCflFile(filename.c_str(), N, dataHost))
    //{
    //  return false;
    //}
    //data.assignFromHost(dataHost.begin(), dataHost.end());
    //std::cout << "norm vector: " << agile::norm1(data) << std::endl;
    return false;
  }
  else
    return false;
return true;
}