Ejemplo n.º 1
0
//--------------------------------------------------------------------------
//-------- execute ---------------------------------------------------------
//--------------------------------------------------------------------------
void
AssembleElemSolverAlgorithm::execute()
{
  stk::mesh::BulkData & bulk_data = realm_.bulk_data();

  // set any data
  const size_t activeKernelsSize = activeKernels_.size();
  for ( size_t i = 0; i < activeKernelsSize; ++i )
    activeKernels_[i]->setup(*realm_.timeIntegrator_);

  run_algorithm(bulk_data, [&](SharedMemData& smdata)
  {
      set_zero(smdata.simdrhs.data(), smdata.simdrhs.size());
      set_zero(smdata.simdlhs.data(), smdata.simdlhs.size());

      // call supplemental; gathers happen inside the elem_execute method
      for ( size_t i = 0; i < activeKernelsSize; ++i )
        activeKernels_[i]->execute( smdata.simdlhs, smdata.simdrhs, smdata.simdPrereqData );

      for(int simdElemIndex=0; simdElemIndex<smdata.numSimdElems; ++simdElemIndex) {
        extract_vector_lane(smdata.simdrhs, simdElemIndex, smdata.rhs);
        extract_vector_lane(smdata.simdlhs, simdElemIndex, smdata.lhs);
        apply_coeff(nodesPerEntity_, smdata.elemNodes[simdElemIndex],
                    smdata.scratchIds, smdata.sortPermutation, smdata.rhs, smdata.lhs, __FILE__);
      }
  });
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: thornb/pj3
int main(int argc,char *argv[]) {

    std::ifstream input_file;
    input_file.open("processes.txt");

    if (!(input_file.is_open())) {
        std::cerr << "Could not open file!\n";
        return 1;
    }

    //Load all processes and their data from the input file
    std::vector<Process> all_vec = parseFile(input_file, n);

    //Open output file to put algorithm stats into it
    std::ofstream output_file;
    output_file.open("simout.txt", std::ofstream::out | std::ofstream::trunc);

    run_algorithm("SRT", "First-Fit", all_vec, output_file);
    run_algorithm("SRT", "Next-Fit", all_vec, output_file);
    run_algorithm("SRT", "Best-Fit", all_vec, output_file);

    run_algorithm("RR", "First-Fit", all_vec, output_file);
    run_algorithm("RR", "Next-Fit", all_vec, output_file);
    run_algorithm("RR", "Best-Fit", all_vec, output_file);

    //Memory test

    /*
    int memory_size = 256;


    Memory m(memory_size, "First-Fit");

    
    m.first_fit('A', 32, 0);
    m.first_fit('B', 12, 0);

    m.removeMem('A', 32);

    m.first_fit('C', 50, 0);

    m.first_fit('D', 12, 0);

    m.printMem(0);
    
//===============================
    
    m.next_fit('A', 32, 0);
    m.next_fit('B', 12, 0);

    m.removeMem('A', 32);

    m.next_fit('C', 50, 0);

    m.next_fit('D', 12, 0);

    m.printMem(0);
    
    
//===============================

    m.best_fit('A', 32, 0);
    m.best_fit('B', 12, 0);

    m.best_fit('C', 15, 0);

    m.best_fit('D', 12, 0);

    m.removeMem('A', 32);

    m.removeMem('C', 15);

    m.best_fit('E', 14, 0);

    m.printMem(0);
    */

}
Ejemplo n.º 3
0
int main(int argc, char const *argv[]) {
    char *files[] = {
        "unsortedArray0100.dat",
        "unsortedArray0200.dat",
        "unsortedArray0300.dat",
        "unsortedArray0400.dat",
        "unsortedArray0500.dat",
        "unsortedArray0600.dat",
        "unsortedArray0700.dat",
        "unsortedArray0800.dat",
        "unsortedArray0900.dat",
        "unsortedArray1000.dat"
    };

    char *algorithms[] = {
        "BubbleSorted",
        "QuickSorted",
        "HeapSorted",
        "MergeSorted"
    };

    char *output_files[] = {
        "bubbleSorted.dat",
        "quickSorted.dat",
        "heapSorted.dat",
        "mergeSorted.dat"
    };

    int i, j, k;

    for(k = 0; k < 4; k ++) {
        for (i = 0; i < 10; i++) {
            int size = (i + 1) * 100;

            int *arr = read_from_file(files[i], size);
            if(NULL == arr) {
                return 1;
            }

            start_timer();

            printf("Unsorted Array:\n");

            for (j = 0; j < size; j++) {
                printf("%d%s", arr[j], j == size - 1 ? "\n" : " ");
            }

            run_algorithm(k, arr, size);
            printf("%s Array %d Elements\n", algorithms[k], size);

            for (j = 0; j < size; j++) {
                printf("%d%s", arr[j], j == size - 1 ? "\n" : " ");
            }

            double elapsedTime = stop_timer();
            printf("Elapsed time: %lf ms.\n", elapsedTime );

            FILE *out = fopen(output_files[k], "a+");
            fwrite(arr, sizeof(int), size, out);
            fclose(out);

            free(arr);
        }
    }

    return 0;
}