Changes between Version 61 and Version 62 of DRM4G/Tutorial


Ignore:
Timestamp:
Jun 28, 2016 9:14:28 AM (6 years ago)
Author:
carlos
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DRM4G/Tutorial

    v61 v62  
    234234== Array Job ==
    235235
    236 * C code :
    237 {{{
    238 #!cpp
    239 #include <stdio.h>
    240 #include <string.h>
    241 #include <stdlib.h>
    242 
    243 int main (int argc, char** args)
    244 {
    245   int task_id;
    246   int total_tasks;
    247   long long int n;
    248   long long int i;
    249 
    250   double l_sum, x, h;
    251 
    252   task_id = atoi(args[1]);
    253   total_tasks = atoi(args[2]);
    254   n = atoll(args[3]);
    255 
    256   fprintf(stderr, "task_id=%d total_tasks=%d n=%lld\n", task_id, total_tasks, n);
    257 
    258   h = 1.0/n;
    259 
    260   l_sum = 0.0;
    261 
    262   for (i = task_id; i < n; i += total_tasks)
    263   {
    264     x = (i + 0.5)*h;
    265     l_sum += 4.0/(1.0 + x*x);
    266   }
    267 
    268   l_sum *= h;
    269 
    270   printf("%0.12g\n", l_sum);
    271 
    272   return 0;
    273 }
    274 }}}
     236* C binary pi
    275237
    276238* DRM4G job template :
     
    280242STDOUT_FILE = stdout_file.${TASK_ID}
    281243STDERR_FILE = stderr_file.${TASK_ID}
    282 INPUT_FILES = pi.c, pi.sh
     244INPUT_FILES = pi_serial.c, pi.sh
    283245}}}
    284246
     
    287249#!sh
    288250#!/bin/bash
    289 gcc -o pi pi.c
    290 chmod +x ./pi
    291 ./pi $@
     251chmod +x ./pi_serial
     252./pi_serial $@
    292253}}}
    293254