コード例 #1
0
  void computeEnergy(SystemInterface &s) {
    dds_float box[3];
    int per[3];
    for (int i=0;i<3;i++)
    {
     box[i]=s.box()[i];
     per[i] = (PERIODIC(i));
    }
    DipolarDirectSum_kernel_wrapper_energy(k,s.npart_gpu(),
					 s.rGpuBegin(), s.dipGpuBegin(), box,per,(&(((CUDA_energy*)s.eGpu())->dipolar)));
 };
コード例 #2
0
  DipolarDirectSum(SystemInterface &s) {

	k = coulomb.Dbjerrum;

	if(!s.requestFGpu())
      std::cerr << "DipolarDirectSum needs access to forces on GPU!" << std::endl;

    if(!s.requestRGpu())
      std::cerr << "DipolarDirectSum needs access to positions on GPU!" << std::endl;
    
    if(!s.requestDipGpu())
      std::cerr << "DipolarDirectSum needs access to dipoles on GPU!" << std::endl;

  }; 
コード例 #3
0
ファイル: Mesh.hpp プロジェクト: mrdooz/codename_ch
inline void Mesh::render(SystemInterface& system) 
{
  system.set_input_layout(input_layout_);

  const UINT offset = 0;
  g_d3d_device->IASetIndexBuffer(index_buffer_, index_buffer_format_, 0);
  g_d3d_device->IASetVertexBuffers(0, 1, &vertex_buffer_, &vertex_buffer_stride_, &offset);
  g_d3d_device->DrawIndexed(index_count_, 0, 0);
}
コード例 #4
0
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
  MPI_Init(&argc, &argv);
#endif
  time_t begin_time = time(nullptr);
  std::string in_type = "exodusII";

  bool ok = false;
  codename = argv[0];
  size_t ind = codename.find_last_of("/", codename.size());
  if (ind != std::string::npos)
    codename = codename.substr(ind+1, codename.size());

  try {
    SystemInterface::show_version();
    Ioss::Init::Initializer io;

    SystemInterface interface;
    ok = interface.parse_options(argc, argv);

    if (ok) {
      std::string in_file = interface.input_file();
      std::string output_file = interface.output_file();

      OUTPUT << "Input:    '" << in_file  << "', Type: " << in_type  << '\n';
      OUTPUT << "Output:   '" << output_file << "', Type: matlab script\n\n";

      ok = file_info(in_file, in_type, interface);
    }
    std::string success = ok ? "successful" : "unsuccessful";
    OUTPUT << "\n" << codename << " execution " << success << ".\n";
  }
  catch (std::exception &e) {
    std::cerr << "ERROR: (EXOMATLAB) Standard exception: " << e.what() << std::endl;
  }
  time_t end_time = time(nullptr);
  add_to_log(codename.c_str(), (int)(end_time - begin_time));
#ifdef HAVE_MPI
  MPI_Finalize();
#endif
  return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
コード例 #5
0
  void computeForces(SystemInterface &s) {
    dds_float box[3];
    int per[3];
    for (int i=0;i<3;i++)
    {
     box[i]=s.box()[i];
     per[i] = (PERIODIC(i));
    }
    DipolarDirectSum_kernel_wrapper_force(k,s.npart_gpu(),
					 s.rGpuBegin(), s.dipGpuBegin(), s.fGpuBegin(),s.torqueGpuBegin(),box,per);
  };
コード例 #6
0
bool Excn::ExodusFile::create_output(const SystemInterface& si)
  // Create output file...
{
  outputFilename_ = si.outputName_;

  int mode = EX_CLOBBER | exodusMode_;
  if (si.ints_64_bit())
    mode |= EX_ALL_INT64_DB;
  
  std::cout << "Output:   '" << outputFilename_ << "'" << std::endl;
  outputId_ = ex_create(outputFilename_.c_str(), mode,
			&cpuWordSize_, &ioWordSize_);
  if (outputId_ < 0) {
    std::cerr << "Cannot open file '" << outputFilename_ << "'" << std::endl;
    return false;
  }
  std::cout << "IO Word size is " << ioWordSize_ << " bytes.\n";
  ex_set_max_name_length(outputId_, maximumNameLength_);
  return true;
}
コード例 #7
0
  virtual void computeForces(SystemInterface &s) {
	printf("Trace HarmonicWell computeForces 1");
    HarmonicWell_kernel_wrapper(x,y,z,k,s.npart_gpu(),
					 s.rGpuBegin(), s.fGpuBegin());
  };
コード例 #8
0
bool Excn::ExodusFile::create_output(const SystemInterface& si, int cycle)
  // Create output file...
{
  std::string curdir = si.cwd();
  std::string file_prefix = si.basename();
  std::string output_suffix = si.output_suffix();

  outputFilename_ = file_prefix;
  if (!output_suffix.empty()) {
    outputFilename_ += "." + output_suffix;
  }

  if(curdir.length() && outputFilename_[0] != '/') {
    outputFilename_ = curdir + "/" + outputFilename_;
  }

  if (si.subcycle() > 1) {
    Excn::ParallelDisks::Create_IO_Filename(outputFilename_,
					    cycle, si.subcycle());
  }

  // See if output file should be opened in netcdf4 format...
  // Did user specify it via -netcdf4 or -large_model argument...
  int mode = 0;
  
  if (si.use_netcdf4()) {
    mode |= EX_NETCDF4;
  } else if (ex_large_model(fileids_[0]) == 1) {
    mode |= EX_LARGE_MODEL;
  }
  
  mode |= mode64bit_;
  
  if (si.int64()) {
    mode |= EX_ALL_INT64_DB;
    mode |= EX_ALL_INT64_API;
  }

  if (si.append()) {
    std::cout << "Output:   '" << outputFilename_ << "' (appending)" << std::endl;
    float version = 0.0;
    mode |= EX_WRITE;
    outputId_ = ex_open(outputFilename_.c_str(), mode, 
			&cpuWordSize_, &ioWordSize_, &version);
  } else {
    mode |= EX_CLOBBER;
    if (si.compress_data() > 0) {
      // Force netcdf-4 if compression is specified...
      mode |= EX_NETCDF4;
    }
    std::cout << "Output:   '" << outputFilename_ << "'" << std::endl;
    outputId_ = ex_create(outputFilename_.c_str(), mode,
			  &cpuWordSize_, &ioWordSize_);
  }
  if (outputId_ < 0) {
    std::cerr << "Cannot open file '" << outputFilename_ << "'" << std::endl;
    return false;
  }

  if (si.compress_data() > 0) {
    ex_set_option(outputId_, EX_OPT_COMPRESSION_LEVEL, si.compress_data());
    ex_set_option(outputId_, EX_OPT_COMPRESSION_SHUFFLE, 1);
  }

  // EPU Can add a name of "processor_id_epu" which is 16 characters long.
  // Make sure maximumNameLength_ is at least that long...
  
  if (maximumNameLength_ < 16)
    maximumNameLength_ = 16;
  ex_set_option(outputId_, EX_OPT_MAX_NAME_LENGTH, maximumNameLength_);

  int int_size = si.int64() ? 8 : 4;
  std::cout << "IO Word sizes: "
	    << ioWordSize_ << " bytes floating point and "
	    << int_size << " bytes integer.\n";
  return true;
}
コード例 #9
0
bool Excn::ExodusFile::initialize(const SystemInterface& si, int start_part, int part_count)
{
  processorCount_ = si.processor_count(); // Total number processors
  partCount_      = part_count;      // Total parts we are processing
  startPart_      = start_part;      // Which one to start with
  SMART_ASSERT(partCount_ + startPart_ <= processorCount_)(partCount_)(startPart_)(processorCount_);
  
  // EPU always wants entity (block, set, map) ids as 64-bit quantities...
  mode64bit_ = EX_IDS_INT64_API;
  if (si.int64()) {
    mode64bit_ |= EX_ALL_INT64_API;

    // For output...
    mode64bit_ |= EX_ALL_INT64_DB;
  }

  // See if we can keep files open 
  int max_files = get_free_descriptor_count();
  if (partCount_ <= max_files) {
    keepOpen_ = true;
    if (si.debug() & 1)
      std::cout << "Files kept open... (Max open = " << max_files << ")\n\n";
  } else {
    keepOpen_ = false;
    std::cout << "Single file mode... (Max open = " << max_files << ")\n"
	      << "Consider using the -subcycle option for faster execution...\n\n";
  }

  fileids_.resize(processorCount_);
  filenames_.resize(processorCount_);

  std::string curdir = si.cwd();
  std::string file_prefix = si.basename();
  std::string exodus_suffix = si.exodus_suffix();
  
  std::string root_dir = si.root_dir();
  std::string sub_dir  = si.sub_dir();

  ParallelDisks disks;
  disks.Raid_Offset(si.raid_offset());
  disks.Number_of_Raids(si.raid_count());

  float version = 0.0;

  // create exo names
  for(int p = 0; p < partCount_; p++) {
    std::string name = file_prefix;
    if (!exodus_suffix.empty()) {
      name += "." + exodus_suffix;
    }

    int proc = p + startPart_;
    disks.rename_file_for_mp(root_dir, sub_dir, name, proc,
			     processorCount_); 
    filenames_[p] = name;

    if (p == 0) {
      int cpu_word_size  = sizeof(float);
      int io_word_size_var   = 0;
      int mode = EX_READ;
      mode |= mode64bit_;
      int exoid = ex_open(filenames_[p].c_str(),
			  mode, &cpu_word_size,
			  &io_word_size_var, &version);
      if (exoid < 0) {
	std::cerr << "Cannot open file '" << filenames_[p] << "'" << std::endl;
	return false;
      }

      int int64db = ex_int64_status(exoid) & EX_ALL_INT64_DB;
      if (int64db) {
	// If anything stored on input db as 64-bit int, then output db will have
	// everything stored as 64-bit ints and all API functions will use 64-bit
	mode64bit_ |= EX_ALL_INT64_API;
	mode64bit_ |= EX_ALL_INT64_DB;
      }
      
      int max_name_length = ex_inquire_int(exoid, EX_INQ_DB_MAX_USED_NAME_LENGTH);
      if (max_name_length > maximumNameLength_)
	maximumNameLength_ = max_name_length;

      ex_close(exoid);

      if (io_word_size_var < (int)sizeof(float))
	io_word_size_var = sizeof(float);

      ioWordSize_ = io_word_size_var;
      cpuWordSize_ = io_word_size_var;
    }

    if (keepOpen_ || p == 0) {
      int io_word_size_var   = 0;
      int mode = EX_READ;
      // All entity ids (block, sets) are read/written as 64-bit...
      mode |= mode64bit_;
      fileids_[p] = ex_open(filenames_[p].c_str(),
			    mode, &cpuWordSize_,
			    &io_word_size_var, &version);
      if (fileids_[p] < 0) {
	std::cerr << "Cannot open file '" << filenames_[p] << "'" << std::endl;
	return false;
      }
      ex_set_max_name_length(fileids_[p], maximumNameLength_);
      SMART_ASSERT(ioWordSize_ == io_word_size_var)(ioWordSize_)(io_word_size_var);
    }
    
    if (si.debug()&64 || p==0 || p==partCount_-1) {
      std::cout << "Input(" << p << "): '" << name.c_str() << "'" << std::endl;
      if (!(si.debug()&64) && p==0)
	std::cout << "..." << std::endl;
    }
  }

  if (mode64bit_ & EX_ALL_INT64_DB) {
    std::cout << "Input files contain 8-byte integers.\n";
    si.set_int64();
  }

  return true;
}
コード例 #10
0
bool Excn::ExodusFile::initialize(const SystemInterface& si)
{
  // See if we can keep files open 
  size_t max_files = get_free_descriptor_count();
  if (si.inputFiles_.size() <= max_files) {
    keepOpen_ = true;
    if (si.debug() & 1)
      std::cout << "Files kept open... (Max open = " << max_files << ")\n\n";
  } else {
    keepOpen_ = false;
    std::cout << "Single file mode... (Max open = " << max_files << ")\n"
	      << "Consider using the -subcycle option for faster execution...\n\n";
  }

  float version = 0.0;

  // create exo names
  filenames_.resize(si.inputFiles_.size());
  fileids_.resize(si.inputFiles_.size());
  
  int int_byte_size_api = 4;
  if (si.ints_64_bit())
    int_byte_size_api = 8;
  
  int overall_max_name_length = 0;
  for(size_t p = 0; p < si.inputFiles_.size(); p++) {
    std::string name = si.inputFiles_[p];

    filenames_[p] = name;

    if (p == 0) {
      int cpu_word_size  = sizeof(float);
      int io_wrd_size   = 0;
      int exoid = ex_open(filenames_[p].c_str(),
			  EX_READ, &cpu_word_size,
			  &io_wrd_size, &version);
      if (exoid < 0) {
	std::cerr << "Cannot open file '" << filenames_[p] << "'" << std::endl;
	return false;
      }

      int max_name_length = ex_inquire_int(exoid, EX_INQ_DB_MAX_USED_NAME_LENGTH);
      if (max_name_length > overall_max_name_length)
	overall_max_name_length = max_name_length;

      ex_close(exoid);

      if (io_wrd_size < (int)sizeof(float))
	io_wrd_size = sizeof(float);

      ioWordSize_ = io_wrd_size;
      cpuWordSize_ = io_wrd_size;

      if (ex_int64_status(exoid & EX_ALL_INT64_DB) || si.ints_64_bit()) {
	exodusMode_ = EX_ALL_INT64_API;
      }
    }

    if (keepOpen_ || p == 0) {
      int io_wrd_size   = 0;
      int mode = EX_READ | exodusMode_;

      fileids_[p] = ex_open(filenames_[p].c_str(),
			    mode, &cpuWordSize_,
			    &io_wrd_size, &version);
      if (fileids_[p] < 0) {
	std::cerr << "Cannot open file '" << filenames_[p] << "'" << std::endl;
	return false;
      }

      SMART_ASSERT(ioWordSize_ == io_wrd_size)(ioWordSize_)(io_wrd_size);
    }
    
    std::cout << "Part " << p+1 << ": '" << name.c_str() << "'" << std::endl;
  }

  maximumNameLength_ = overall_max_name_length;
  for(size_t p = 0; p < si.inputFiles_.size(); p++) {
    ex_set_max_name_length(fileids_[p], maximumNameLength_);
  }

  return true;
}