src/Pure/System/host.scala
changeset 79608 f1df99019b50
parent 79602 9ba800f12785
child 79618 50376abd132d
equal deleted inserted replaced
79607:118504de9d0d 79608:f1df99019b50
   120         case _ => None
   120         case _ => None
   121       }
   121       }
   122     }
   122     }
   123     catch { case ERROR(_) => None }
   123     catch { case ERROR(_) => None }
   124 
   124 
   125   def num_cpus(ssh: SSH.System = SSH.Local): Int =
       
   126     if (ssh.is_local) Runtime.getRuntime.availableProcessors
       
   127     else {
       
   128       val command =
       
   129         if (ssh.isabelle_platform.is_macos) "sysctl -n hw.ncpu" else "nproc"
       
   130       val result = ssh.execute(command).check
       
   131       Library.trim_line(result.out) match {
       
   132         case Value.Int(n) => n
       
   133         case _ => 1
       
   134       }
       
   135     }
       
   136 
       
   137   object Info {
   125   object Info {
   138     def init(
   126     def init(
   139       hostname: String = SSH.LOCAL,
   127       hostname: String = SSH.LOCAL,
   140       ssh: SSH.System = SSH.Local,
   128       ssh: SSH.System = SSH.Local,
   141       score: Option[Double] = None
   129       score: Option[Double] = None
   142     ): Info = Info(hostname, numa_nodes(ssh = ssh), num_cpus(ssh = ssh), score)
   130     ): Info = Info(hostname, numa_nodes(ssh = ssh), Multithreading.num_processors(ssh = ssh), score)
   143   }
   131   }
   144 
   132 
   145   sealed case class Info(
   133   sealed case class Info(
   146     hostname: String,
   134     hostname: String,
   147     numa_nodes: List[Int],
   135     numa_nodes: List[Int],