From c83beaa9021b2f9dad4de9a3918768480bb1a1bc Mon Sep 17 00:00:00 2001
From: Jonathan Pastor <jonathancmoa@gmail.com>
Date: Tue, 10 Sep 2019 11:44:34 +0200
Subject: [PATCH] add 'cpuset_mapping' property to yaml file

---
 .../lille/clusters/chifflet/chifflet.yaml     |  1 +
 .../lille/clusters/chifflot/chifflot.yaml     |  1 +
 .../nancy/clusters/graffiti/graffiti.yaml     |  1 +
 .../nancy/clusters/graphique/graphique.yaml   |  1 +
 .../sites/nancy/clusters/grele/grele.yaml     |  1 +
 .../sites/nancy/clusters/grimani/grimani.yaml |  1 +
 lib/refrepo/gen/oar-properties.rb             | 47 +++----------------
 7 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/input/grid5000/sites/lille/clusters/chifflet/chifflet.yaml b/input/grid5000/sites/lille/clusters/chifflet/chifflet.yaml
index f3c2c1362ee..3f24de1d143 100644
--- a/input/grid5000/sites/lille/clusters/chifflet/chifflet.yaml
+++ b/input/grid5000/sites/lille/clusters/chifflet/chifflet.yaml
@@ -17,6 +17,7 @@ nodes:
       max_walltime: 0
     processor:
       microarchitecture: Broadwell
+    cpuset_mapping: round-robin
     performance:
       core_flops: 15730000000
       node_flops: 419500000000
diff --git a/input/grid5000/sites/lille/clusters/chifflot/chifflot.yaml b/input/grid5000/sites/lille/clusters/chifflot/chifflot.yaml
index 7eb94606b4a..289249afb6a 100644
--- a/input/grid5000/sites/lille/clusters/chifflot/chifflot.yaml
+++ b/input/grid5000/sites/lille/clusters/chifflot/chifflot.yaml
@@ -17,6 +17,7 @@ nodes:
       max_walltime: 0
     processor:
       microarchitecture: Skylake
+    cpuset_mapping: round-robin
     performance:
       core_flops: 16360000000
       node_flops: 408900000000
diff --git a/input/grid5000/sites/nancy/clusters/graffiti/graffiti.yaml b/input/grid5000/sites/nancy/clusters/graffiti/graffiti.yaml
index 4ad3b0e4901..fb7c6e9b40a 100755
--- a/input/grid5000/sites/nancy/clusters/graffiti/graffiti.yaml
+++ b/input/grid5000/sites/nancy/clusters/graffiti/graffiti.yaml
@@ -9,6 +9,7 @@ nodes:
   graffiti-[1-13]:
     processor:
       microarchitecture: Skylake
+    cpuset_mapping: round-robin
     supported_job_types:
        deploy: true
        besteffort: true
diff --git a/input/grid5000/sites/nancy/clusters/graphique/graphique.yaml b/input/grid5000/sites/nancy/clusters/graphique/graphique.yaml
index fdc1ea254a3..29a9d553e94 100644
--- a/input/grid5000/sites/nancy/clusters/graphique/graphique.yaml
+++ b/input/grid5000/sites/nancy/clusters/graphique/graphique.yaml
@@ -19,6 +19,7 @@ nodes:
       besteffort: true
     processor:
       microarchitecture: Haswell
+    cpuset_mapping: round-robin
     storage_devices:
       sda:
         interface: SCSI
diff --git a/input/grid5000/sites/nancy/clusters/grele/grele.yaml b/input/grid5000/sites/nancy/clusters/grele/grele.yaml
index 1db7e316b50..b47e9f618cc 100644
--- a/input/grid5000/sites/nancy/clusters/grele/grele.yaml
+++ b/input/grid5000/sites/nancy/clusters/grele/grele.yaml
@@ -27,6 +27,7 @@ nodes:
         available: false
     processor:
       microarchitecture: Broadwell
+    cpuset_mapping: round-robin
     network_adapters:
       eth0:
         enabled: true
diff --git a/input/grid5000/sites/nancy/clusters/grimani/grimani.yaml b/input/grid5000/sites/nancy/clusters/grimani/grimani.yaml
index 2e1e61f0510..20e5c640cf7 100644
--- a/input/grid5000/sites/nancy/clusters/grimani/grimani.yaml
+++ b/input/grid5000/sites/nancy/clusters/grimani/grimani.yaml
@@ -27,6 +27,7 @@ nodes:
         available: false
     processor:
       microarchitecture: Haswell
+    cpuset_mapping: round-robin
     storage_devices:
       sda:
         interface: SATA
diff --git a/lib/refrepo/gen/oar-properties.rb b/lib/refrepo/gen/oar-properties.rb
index 7bdc599a4e6..75108eea44d 100644
--- a/lib/refrepo/gen/oar-properties.rb
+++ b/lib/refrepo/gen/oar-properties.rb
@@ -9,32 +9,6 @@ class MissingProperty < StandardError; end
 
 MiB = 1024**2
 
-# CPU distribution can be: round-robin | continuous
-PER_CLUSTER_CPUSET_MAPPING = {
-    "nantes" => {
-        "econome" => "continuous",
-        "ecotype" => "continuous",
-    },
-    "nancy" => {
-        "graoully" => "continuous",
-        "graffiti" => "round-robin",
-        "graphique" => "round-robin",
-        "graphite" => "continuous",
-        "grcinq" => "continuous",
-        "grele" => "round-robin",
-        "grimani" => "round-robin",
-        "grimoire" => "continuous",
-        "grisou" => "continuous",
-        "grvingt" => "continuous",
-    },
-    "lille" => {
-        "chetemi" => "continuous",
-        "chiclet" => "continuous",
-        "chifflet" => "round-robin",
-        "chifflot" => "round-robin",
-    }
-}
-
 # CPU distribution can be: round-robin | continuous
 DEFAULT_CPUSET_MAPPING = "continuous"
 
@@ -1145,6 +1119,9 @@ def extract_clusters_description(clusters, site_name, options, input_files_hiera
     gpu_count = first_node.key?("gpu_devices") ? first_node["gpu_devices"].length : 0
 
     cpu_model = "#{first_node['processor']['model']} #{first_node['processor']['version']}"
+    cpuset_mapping = first_node.key?("cpuset_mapping") ? first_node["cpuset_mapping"] : DEFAULT_CPUSET_MAPPING
+    # Detect how 'GPUSETs' are distributed over CPUs/GPUs of servers of this cluster
+    gpuset_mapping = DEFAULT_GPUSET_MAPPING
 
     ############################################
     # (2-b) Detect existing resource_ids and {CPU, CORE, CPUSET, GPU}'s IDs
@@ -1242,16 +1219,6 @@ def extract_clusters_description(clusters, site_name, options, input_files_hiera
       variables[:current_ids] = phys_rsc_ids
     end
 
-    # Detect how 'CPUSETs' are distributed over CPUs of servers of this cluster
-    if PER_CLUSTER_CPUSET_MAPPING.key? site_name and PER_CLUSTER_CPUSET_MAPPING[site_name].key?(cluster_name)
-      cpuset_attribution_policy = PER_CLUSTER_CPUSET_MAPPING[site_name][cluster_name]
-    else
-      cpuset_attribution_policy = DEFAULT_CPUSET_MAPPING
-    end
-
-    # Detect how 'GPUSETs' are distributed over CPUs/GPUs of servers of this cluster
-    gpuset_attribution_policy = DEFAULT_GPUSET_MAPPING
-
     # Some cluster (econome) have attributed resources according to the "alpha-numerical" order of nodes
     # ([1, 11, 12, ..., 3] instead of [1, 2, 3, 4, ...]). Here we preserve to order of existing nodes of the cluster
     if is_a_new_cluster
@@ -1291,7 +1258,7 @@ def extract_clusters_description(clusters, site_name, options, input_files_hiera
         gpu_idx += 1
       end
 
-      if cpuset_attribution_policy == 'continuous'
+      if cpuset_mapping == 'continuous'
         cpuset = 0
       end
 
@@ -1363,7 +1330,7 @@ def extract_clusters_description(clusters, site_name, options, input_files_hiera
           ############################################
           # (2-d) Associate a cpuset to each core
           ############################################
-          if cpuset_attribution_policy == 'continuous'
+          if cpuset_mapping == 'continuous'
             row[:cpuset] = cpuset
           else
             # CPUSETs starts at 0
@@ -1376,7 +1343,7 @@ def extract_clusters_description(clusters, site_name, options, input_files_hiera
           # (2-e) [if cluster with GPU] Associate a gpuset to each core
           ############################################
           if not numa_gpus.empty?
-            if gpuset_attribution_policy == 'continuous'
+            if gpuset_mapping == 'continuous'
               gpu_idx = core_index0 / (phys_rsc_map["core"][:per_server_count] / numa_gpus.length)
             else
               gpu_idx = core_index0 % numa_gpus.length
@@ -1395,7 +1362,7 @@ def extract_clusters_description(clusters, site_name, options, input_files_hiera
 
           core_idx += 1
 
-          if cpuset_attribution_policy == 'continuous'
+          if cpuset_mapping == 'continuous'
             cpuset += 1
           end
 
-- 
GitLab