Beispiel #1
0
void void_rp_grid_eval_tbb(rp_t rp,
                           rp_grid_params_t rp_grid_params,
                           const real* q,  const real* aux, const void* aux_global,
                           const int nx, const  int ny,
                           real* amdq, real* apdq, real* wave,
                           real* wave_speed)
{
  const int num_ghost = rp_grid_params.num_ghost;
  const int num_eqn = rp_grid_params.num_eqn;
  const int num_wave = rp_grid_params.num_wave;

  FieldIndexer fi(nx, ny, num_ghost, num_eqn);
  EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn, num_wave);
  void_grid_eval_tbb_body body(rp, rp_grid_params, 
                               q, aux, aux_global, nx, ny, amdq, apdq, wave, wave_speed);
  void_grid_eval_tbb_boundary boundary(rp, rp_grid_params, 
				       q, aux, aux_global, nx, ny, amdq, apdq, wave, wave_speed);

  tbb::parallel_for(::tbb::blocked_range2d<unsigned,unsigned>(1, efi.num_row_edge_transverse(),
							      1, efi.num_col_edge_transverse()),
		    body);

  tbb::parallel_for(::tbb::blocked_range<unsigned>(1, std::max(efi.num_row_edge_transverse(), efi.num_col_edge_transverse())), 
		    boundary);

}
Beispiel #2
0
  void operator()(const tbb::blocked_range<unsigned>& r) const
  {
    unsigned col, row;
    const int num_ghost = rp_grid_params.num_ghost;
    const int num_eqn = rp_grid_params.num_eqn;
    const int num_aux = rp_grid_params.num_aux;
    const int num_wave = rp_grid_params.num_wave;

    FieldIndexer fi(nx, ny, num_ghost, num_eqn);
    FieldIndexer fi_aux(nx, ny, num_ghost, num_aux);
    EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn, num_wave);

    for(col = r.begin(); col != std::min(r.end(), efi.num_col_edge_transverse()); ++col) {
      row = efi.num_row_edge_transverse();
      rp(q + fi.idx(row - 1, col), q + fi.idx(row, col),
         aux + fi_aux.idx(row - 1, col), aux + fi_aux.idx(row, col), aux_global, 1,
         amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
         wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
    }

    for(row = r.begin(); row != std::min(r.end(), efi.num_row_edge_transverse()); ++row){
      col = efi.num_col_edge_transverse();
      rp(q + fi.idx(row, col - 1), q + fi.idx(row, col),
         aux + fi_aux.idx(row, col - 1), aux + fi_aux.idx(row, col), aux_global, 0,
         amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
         wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));
    }
  }
Beispiel #3
0
void void_rp_grid_eval_omp(rp_t rp,
                           rp_grid_params_t rp_grid_params,
                           const real* q,
                           const real* aux,
                           const void* aux_global,
                           const int nx,
                           const int ny,
                           real* amdq,
                           real* apdq,
                           real* wave,
                           real* wave_speed)
{
  unsigned col, row;
  const int num_ghost = rp_grid_params.num_ghost;
  const int num_eqn = rp_grid_params.num_eqn;
  const int num_aux = rp_grid_params.num_aux;
  const int num_wave = rp_grid_params.num_wave;

  FieldIndexer fi(nx, ny, num_ghost, num_eqn);
  FieldIndexer fi_aux(nx, ny, num_ghost, num_aux);
  EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn, num_wave);

#pragma omp parallel shared(q, aux, amdq, apdq, wave, wave_speed) private(col, row)
  {
#pragma omp for schedule(runtime) nowait
    for(row = 1; row < efi.num_row_edge_transverse(); ++row){
      for(col = 1; col < efi.num_col_edge_normal() + 1; ++col) {
        rp(q + fi.idx(row, col-1), q + fi.idx(row, col),
           aux + fi_aux.idx(row, col-1), aux + fi_aux.idx(row, col), aux_global, 0,
           amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
           wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));

        rp(q + fi.idx(row-1, col), q + fi.idx(row, col),
           aux + fi_aux.idx(row-1, col), aux + fi_aux.idx(row, col), aux_global, 1,
           amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
           wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
      }
    }

#pragma omp for schedule(runtime) nowait
    for(col = 1; col < efi.num_col_edge_transverse(); ++col) {
      row = efi.num_row_edge_transverse();
      rp(q + fi.idx(row - 1, col), q + fi.idx(row, col),
         aux + fi_aux.idx(row - 1, col), aux + fi_aux.idx(row, col), aux_global, 1,
         amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
         wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
    }

#pragma omp for schedule(runtime) nowait
    for(row = 1; row < efi.num_row_edge_transverse(); ++row){
      col = efi.num_col_edge_transverse();
      rp(q + fi.idx(row, col - 1), q + fi.idx(row, col),
         aux + fi_aux.idx(row, col - 1), aux + fi_aux.idx(row, col), aux_global, 0,
         amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
         wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));
    }
  }
}
Beispiel #4
0
// Evaluates void_rp via serial execution
void void_rp_grid_eval_serial(rp_t rp,
                              rp_grid_params_t rp_grid_params,
                              const real* q,
                              const real* aux,
                              const void* aux_global,
                              const int nx,
                              const int ny,
                              real* amdq,
                              real* apdq,
                              real* wave,
                              real* wave_speed)
{
  unsigned col, row;
  const int num_ghost = rp_grid_params.num_ghost;
  const int num_eqn = rp_grid_params.num_eqn;
  const int num_aux = rp_grid_params.num_aux;
  const int num_wave = rp_grid_params.num_wave;

  FieldIndexer fi(nx, ny, num_ghost, num_eqn);
  FieldIndexer fi_aux(nx, ny, num_ghost, num_aux);
  EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn, num_wave);

  for(row = 1; row < efi.num_row_edge_transverse(); ++row){
    for(col = 1; col < efi.num_col_edge_normal() + 1; ++col) {
      rp(q + fi.idx(row, col-1), q + fi.idx(row, col),
         aux + fi_aux.idx(row, col-1), aux + fi_aux.idx(row, col), aux_global, 0,
         amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
         wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));

      rp(q + fi.idx(row-1, col), q + fi.idx(row, col),
         aux + fi_aux.idx(row-1, col), aux + fi_aux.idx(row, col), aux_global, 1,
         amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
         wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
    }
  }

  for(col = 1; col < efi.num_col_edge_transverse(); ++col) {
    row = efi.num_row_edge_transverse();
    rp(q + fi.idx(row - 1, col), q + fi.idx(row, col),
       aux + fi_aux.idx(row - 1, col), aux + fi_aux.idx(row, col), aux_global, 1,
       amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
       wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
  }

  for(row = 1; row < efi.num_row_edge_transverse(); ++row){
    col = efi.num_col_edge_transverse();
    rp(q + fi.idx(row, col - 1), q + fi.idx(row, col),
       aux + fi_aux.idx(row, col - 1), aux + fi_aux.idx(row, col), aux_global, 0,
       amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
       wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));
  }
}
Solver::Solver(int* num_cells, int num_eqn, int num_ghost, int num_wave):
  num_ghost(num_ghost), num_wave(num_wave)
{
  const int nx = num_cells[0];
  const int ny = num_cells[1];
  //const int dim = solution.grid.dim;
  // Outputs on interfaces
  EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn);
  EdgeFieldIndexer wave_efi(nx, ny, num_ghost, num_eqn, num_wave);
  amdq.resize(efi.size());
  apdq.resize(efi.size());
  wave.resize(wave_efi.size());
  wave_speed.resize(wave_efi.size());
}
///////////////////////////
//                       //
//  PACKING OPERATIONS   //
//                       //
///////////////////////////
void
ProjectPackager::runPack()
{

RG_DEBUG << "ProjectPackager::runPack()";

    m_info->setText(tr("Packing project..."));

    // go into spinner mode
    m_progress->setMaximum(0);

    QStringList audioFiles = getAudioFiles();

    // the base tmp directory where we'll assemble all the files
    m_packTmpDirName = QString("%1/rosegarden-project-packager-tmp").arg(QDir::homePath());

    // the data directory where audio and other files will go
    QFileInfo fi(m_filename);
    m_packDataDirName = fi.baseName();

RG_DEBUG << "using tmp data directory: " << m_packTmpDirName << "/" << 
    m_packDataDirName;

    QDir tmpDir(m_packTmpDirName);

    // get the original filename saved by RosegardenMainWindow and the name of
    // the new one we'll be including in the bundle (name isn't changing, path
    // component changes from one to the other)
    // QFileInfo::baseName() given /tmp/foo/bar/rat.rgp returns rat
    //
    // m_filename comes in already having an .rgp extension, but the file
    // was saved .rg
    QString oldName = QString("%1/%2.rg").arg(fi.path()).arg(fi.baseName());
    QString newName = QString("%1/%2.rg").arg(m_packTmpDirName).arg(fi.baseName());

    // if the tmp directory already exists, just hose it
    rmdirRecursive(m_packTmpDirName);

    // make the temporary working directory
    if (tmpDir.mkdir(m_packTmpDirName)) {

    } else {
        puke(tr("<qt><p>Could not create temporary working directory.</p>%1</qt>").arg(m_abortText));
        return;
    }

    m_info->setText(tr("Copying audio files..."));

    // leave spinner mode
    m_progress->setMaximum(100);
    m_progress->setValue(0);

    // count total audio files
    int af = 0;
    QStringList::const_iterator si;
    for (si = audioFiles.constBegin(); si != audioFiles.constEnd(); ++si)
        af++;
    int afStep = ((af == 0) ? 1 : (100 / af));

    // make the data subdir
    tmpDir.mkdir(m_packDataDirName);    

    // copy the audio files (do not remove the originals!)
    af = 0;
    for (si = audioFiles.constBegin(); si != audioFiles.constEnd(); ++si) {

        // comes in with full path and filename
        QString srcFile = (*si);
        QString srcFilePk = QString("%1.pk").arg(srcFile);

        // needs the filename split away from the path, so we can replace the
        // path with the new one
        QFileInfo fi(*si);
        QString filename = QString("%1.%2").arg(fi.baseName()).arg(fi.completeSuffix());

        QString dstFile = QString("%1/%2/%3").arg(m_packTmpDirName).arg(m_packDataDirName).arg(filename);
        QString dstFilePk = QString("%1.pk").arg(dstFile);

RG_DEBUG << "cp " << srcFile << " " << dstFile;
RG_DEBUG << "cp " << srcFilePk << " " << dstFilePk;

        if (!QFile::copy(srcFile, dstFile)) {
            puke(tr("<qt>Could not copy<br>%1<br>  to<br>%2<br><br>Processing aborted.</qt>").arg(srcFile).arg(dstFile));
            return;
        }

        // Try to copy the .wav.pk file derived from transforming the name of
        // the .wav file.  We don't trap the fail condition for this one and
        // allow it to fail silently without complaining or aborting.  If the
        // .wav.pk files are missing, they will be generated again as needed.
        //
        // Legacy .rgp files ship with improperly named .wav.pk files, from
        // a bug in the original rosegarden-project-package script.  You'd wind
        // up with an .rgp that contained, for example:
        //
        //   emergence-rg-0014.wav.pk
        //   RG-AUDIO-0014.wav.pk
        //
        // That is why this version of the project packager doesn't screw around
        // with the original filenames!
        QFile::copy(srcFilePk, dstFilePk);

        m_progress->setValue(afStep * ++af);
    }

    // deal with adding any extra files
    QStringList extraFiles;

    // first, if the composition includes synth plugins, there may be assorted
    // random audio files, soundfonts, and who knows what else in use by these
    // plugins
    //
    // obtain a list of these files, and rewrite the XML to update the referring
    // path from its original source to point to our bundled copy instead
    QString newPath = QString("%1/%2").arg(m_packTmpDirName).arg(m_packDataDirName);
    extraFiles = getPluginFilesAndRewriteXML(oldName, newPath);

    // If we do the above here and add it to extraFiles then if the user has any
    // other extra files to add by hand, it all processes out the same way with
    // no extra bundling code required (unless we want to flac any random extra
    // .wav files, and I say no, let's not get that complicated)

    // Copy the modified .rg file to the working tmp dir

RG_DEBUG << "cp " << oldName << " " << newName;

    // copy m_filename(.rgp) as $tmp/m_filename.rg
    if (!QFile::copy(oldName, newName)) {
        puke(tr("<qt>Could not copy<br>%1<br>  to<br>%2<br><br>Processing aborted.</qt>").arg(oldName).arg(newName));
        return;
    }

    QMessageBox::StandardButton reply = QMessageBox::information(this,
            tr("Rosegarden"),
            tr("<qt><p>Rosegarden can add any number of extra files you may desire to a project package.  For example, you may wish to include an explanatory text file, a soundfont, a bank definition for ZynAddSubFX, or perhaps some cover art.</p><p>Would you like to include any additional files?</p></qt>"),
            QMessageBox::Yes | QMessageBox::No, QMessageBox::No);

    while (reply == QMessageBox::Yes) {

        // it would take some trouble to make the last used paths thing work
        // here, where we're building a list of files from potentially anywhere,
        // so we'll just use the open_file path as it was last set elsewhere,
        // and leave it at that until somebody complains
        QSettings settings;
        settings.beginGroup(LastUsedPathsConfigGroup);
        QString directory = settings.value("open_file", QDir::homePath()).toString();
        settings.endGroup();

        // must iterate over a copy of the QStringList returned by
        // (Q)FileDialog::getOpenFileNames for some reason
        //
        // NOTE: This still doesn't work.  I can only add one filename.
        // Something broken in the subclass of QFileDialog?  Bad code?  I'm just
        // leaving it unresolved for now. One file at a time at least satisfies
        // the bare minimum requirements
        QStringList files =  FileDialog::getOpenFileNames(this, "Open File", directory, tr("All files") + " (*)", 0, 0);
        extraFiles << files;
       
        //!!!  It would be nice to show the list of files already chosen and
        // added, in some nice little accumulator list widget, but this would
        // require doing something more complicated than using QMessageBox
        // static convenience functions, and it's probably just not worth it
        reply =  QMessageBox::information(this,
                tr("Rosegarden"),
                tr("<qt><p>Would you like to include any additional files?</p></qt>"),
                QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
    }

    m_info->setText(tr("Copying plugin data and extra files..."));

    // reset progress bar
    m_progress->setValue(0);

    // count total audio files
    int ef = 0;
    for (si = extraFiles.constBegin(); si != extraFiles.constEnd(); ++si)
        ef++;
    int efStep = ((ef == 0) ? 1 : (100 / ef));

    // copy the extra files (do not remove the originals!)
    // (iterator previously declared)
    ef = 0;
    for (si = extraFiles.constBegin(); si != extraFiles.constEnd(); ++si) {
    
        // each QStringList item from the FileDialog will include the full path
        QString srcFile = (*si);

        // so we cut it up to swap the source dir for the dest dir while leaving
        // the complete filename stuck on the end
        QFileInfo efi(*si);
        QString basename = QString("%1.%2").arg(efi.baseName()).arg(efi.completeSuffix());
        QString dstFile = QString("%1/%2/%3").arg(m_packTmpDirName).arg(m_packDataDirName).arg(basename);

RG_DEBUG << "cp " << srcFile << " " << dstFile;

        if (!QFile::copy(srcFile, dstFile)) {
            puke(tr("<qt>Could not copy<br>%1<br>  to<br>%2<br><br>Processing aborted.</qt>").arg(srcFile).arg(dstFile));
            return;
        }

        m_progress->setValue(efStep * ++ef);
    }

    // and now we have everything discovered, uncovered, added, smothered,
    // scattered and splattered, and we're ready to pack the files and
    // get the hell out of here!
    startAudioEncoder(audioFiles);
}