Example #1
0
 /*
  * Load input files for the job assignment
  */
 void SlotHandler::LoadAssignment(JobAssignment * a_ptr) {
   // Set the file retrieval date started
   auto start = std::chrono::system_clock::now();
   a_ptr->set_load_start_date(get_time_as_str(start));
   // Start retrieving files
   s_manager_->node()->LoadFiles(a_ptr);
   // set the file retrieval time
   a_ptr->set_load_time(get_elapsed_seconds(start));
 }
Example #2
0
 /*
  * Execute the assignment in a subprocess
  */
 bool SlotHandler::ExecuteAssignment(JobAssignment * a_ptr) {
   stdout_.clear();
   LOG_INFO("Arguments for " + std::to_string(a_ptr->job()->id())
            + ": " + a_ptr->job()->args());
   // Set the date started
   auto start = std::chrono::system_clock::now();
   a_ptr->set_exec_start_date(get_time_as_str(start));
   //subprocess = popen(("taskset -c " + std::to_string(cpu_id)
   // + " " + assignment->get_job()->get_args()).c_str(), "r");
   subprocess_ = popen(a_ptr->job()->args_cstr(), "r");
   if (subprocess_ == nullptr) {
     stdout_ = "subprocess was null";
     a_ptr->set_ret_code(-1);
     a_ptr->set_std_out(stdout_);
     return false;
   }
   // Create the stdout buffer
   char buffer[SBUFSIZE];
   // retrieve to the stdout buffer
   while (fgets(buffer, SBUFSIZE, subprocess_) != nullptr) {
     stdout_ += buffer; 
   }
   // Wait for the subprocess to close
   int status = pclose(subprocess_);
   subprocess_ = nullptr;
   a_ptr->set_run_time(get_elapsed_seconds(start));
   LOG_INFO("stdout for " + std::to_string(a_ptr->job()->id())
            + " was: " + stdout_);
   LOG_INFO("status for " + std::to_string(a_ptr->job()->id())
            + " was: " + std::to_string(status));
   int ret_code = WEXITSTATUS(status);
   a_ptr->set_ret_code(ret_code);
   a_ptr->set_std_out(stdout_);
   if (status == -1) {
     //Error reported by pclose() -- termination status not available
     LOG_INFO("Process failed for " + std::to_string(a_ptr->job()->id())
              + " with no return code");
     return false;
   } else {
     // Use macros described under Wait() to inspect `status' in order
     // to determine success/failure of command executed by popen()
     LOG_INFO("Return code for " + std::to_string(a_ptr->job()->id())
              + " was: " + std::to_string(ret_code));
     if(ret_code == 0){
       // set the runtime
       return true;
     } else {
       // subprocess failed
       LOG_INFO("Process failed for "
                + std::to_string(a_ptr->job()->id())
                + " with return code: " + std::to_string(ret_code));
       return false;
     }
   }
 }
Example #3
0
int main (int argc, char* argv[])
{
    for(int i = 0; i < N; i++) {
        r[N] = random() % 256;
        g[N] = random() % 256;
        b[N] = random() % 256;
    }
    std::cout<< "Convert " << N << " pixels RGB to gray." << std::endl;

    reset_and_start_stimer();
    for(int i = 0; i < ITERATIONS; i++) {
        serial_rgb2gray(r, g, b, gray);
    }
    double dt = get_elapsed_seconds();
    std::cout<< "serial version: " << dt << " seconds" << std::endl;

    reset_and_start_stimer();
    for(int i = 0; i < ITERATIONS; i++) {
        svec4_rgb2gray(r, g, b, gray);
    }
    double dt2 = get_elapsed_seconds();
    std::cout<< "svec4 version: " << dt2 << " seconds" << std::endl;

    reset_and_start_stimer();
    for(int i = 0; i < ITERATIONS; i++) {
        svec4_rgb2gray_ptr(r, g, b, gray);
    }
    double dt3 = get_elapsed_seconds();
    std::cout<< "svec4 ptr ld/st version: " << dt3 << " seconds" << std::endl;

#ifdef __ALTIVEC__
    reset_and_start_stimer();
    for(int i = 0; i < ITERATIONS; i++) {
        intrinsics_rgb2gray(r, g, b, gray);
    }
    double dt5 = get_elapsed_seconds();
    std::cout<< "Intrinsics version: " << dt5 << " seconds" << std::endl;
#endif

#ifdef __SSE4_2__
    reset_and_start_stimer();
    for(int i = 0; i < ITERATIONS; i++) {
        sse_rgb2gray(r, g, b, gray);
    }
    double dt6 = get_elapsed_seconds();
    std::cout<< "SSE version: " << dt6 << " seconds" << std::endl;
#endif

    reset_and_start_stimer();
    for(int i = 0; i < ITERATIONS; i++) {
        svec4_rgb2gray_fma(r, g, b, gray);
    }
    double dt4 = get_elapsed_seconds();
    std::cout<< "svec4 fma version: " << dt4 << " seconds" << std::endl;


    return 0;
}