Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1.  
  2. execute {
  3.     for (var t=1;t<=nTasks;t++) {
  4.         num_of_threads = 0;
  5.         for (var h=1;h<=nThreads;h++)
  6.         num_of_threads += TH[t][h];
  7.         num_threads_of_task[t] = num_of_threads;
  8.         writeln("Task " + t + " has " + num_threads_of_task[t] + "threads");
  9.     }
  10. };
  11.  
  12. execute {
  13.     for (var c=1;c<=nCPUs;c++) {
  14.         num_of_cores = 0;
  15.         for (var k=1;k<=nCores;k++)
  16.         num_of_cores += CK[c][k];
  17.         num_cores_of_cpu[c] = num_of_cores;
  18.         writeln("CPU " + c + " has " + num_cores_of_cpu[c] + "cores");
  19.     }
  20. };
  21.  
  22.  
  23.  
  24. // Objective
  25. minimize z;
  26.  
  27. subject to{
  28.     // Constraint 1, todos hilos han de ser ejecutado en 1 solo core
  29.     forall(h in H)
  30.     sum(k in K) x_hk[h,k] == 1;
  31.     // Constraint 2, todos hilos de una tarea han de ser asignados a los cores de un solo cpu
  32.     forall(t in T)
  33.     forall(c in C)
  34.     sum(h in H) sum(k in K) TH[t,h] * CK[c, k] * x_hk[h, k] == num_threads_of_task[t] * x_tc[t,c];
  35.     // Constraint 3, la carga de un core no puede superar a rc
  36.     forall(c in C, k in K)
  37.     if (CK[c, k] == 1)
  38.     sum(h in H) rh[h] * x_hk[h,k] <= rc[c];
  39.     // Constraint 4
  40.     forall(c in C)
  41.     z >= (1/(rc[c] * num_cores_of_cpu[c])) * sum(h in H) sum(k in K) rh[h] * CK[c, k] * x_hk[h,k];
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement