Strumenti Utente

Strumenti Sito


magistraleinformaticanetworking:spm:exercise1617spm

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Prossima revisione
Revisione precedente
magistraleinformaticanetworking:spm:exercise1617spm [12/10/2016 alle 13:48 (8 anni fa)] – creata Marco Daneluttomagistraleinformaticanetworking:spm:exercise1617spm [12/10/2016 alle 15:36 (8 anni fa)] (versione attuale) – [Hints] Marco Danelutto
Linea 7: Linea 7:
 Check the correctness of the result against result computed sequentially. Check the correctness of the result against result computed sequentially.
 Plot scalability curve for the program. Plot scalability curve for the program.
 +
 +==== Hints ====
 +
 +  * use <code>int atoi(char *)</code> to convert the command line arguments to integers
 +<code> 
 +  int main(int argc, char * argv[]) {
 +    int n = atoi(argv[1]);
 +    int m = atoi(argv[2]); 
 +    ...
 +  }
 +</code>
 +
 +  * use the <code>std::chrono</code> library to get time before and after the parallel computation and to compute the elapsed time:
 +<code>
 +  std::chrono::time_point<std::chrono::system_clock> start, end;
 +  start = std::chrono::system_clock::now();
 +  ...
 +  end = std::chrono::system_clock::now();
 +  std::chrono::duration<double> elapsed_seconds = end-start;
 +</code>
 +
 +
 +  * use plain <code>rand</code> to generate random numbers in the two matrixes:
 +<code>
 +  srand(123);
 +  for(....) {
 +      ... = ((float) (rand() % MAX)) / ((float) RAND_MAX);
 +</code>
 +  
 +  
 +====== Average neighbours =====
 +Write a program that generates an N by N matrix A and then executed a number Niter of iterations where at each iteration A[i][j] is substituted by the average of A[i][j] and the four neighbours (north, south, east and west). At the borders, the missing elements in the neighbourhood have to be assumed to be 0. All the new A[i][j] values must be computed summing up values **at the current iteration** for the neighbours. 
 +Computation of the single iteration should be parallelized using threads. 
magistraleinformaticanetworking/spm/exercise1617spm.1476280091.txt.gz · Ultima modifica: 12/10/2016 alle 13:48 (8 anni fa) da Marco Danelutto

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki