Skip to content

Commit

Permalink
fix: upgrade hwloc (#1766)
Browse files Browse the repository at this point in the history
* fix: upgrade hwloc

* feat: re-enable CI for pull requests

---------

Co-authored-by: nemo <[email protected]>
  • Loading branch information
jmg-duarte and cryptonemo authored Nov 18, 2024
1 parent 3c83391 commit 1a7cff3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

#on: [pull_request, push]
on: [push]
on: [pull_request, push]
#on: [push]

# Cancel a job if there's a new on on the same branch started.
# Based on https://stackoverflow.com/questions/58895283/stop-already-running-workflow-job-in-github-actions/67223051#67223051
Expand Down
24 changes: 19 additions & 5 deletions storage-proofs-porep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs"
readme = "README.md"

[dependencies]
filecoin-hashers = { workspace = true, features = ["poseidon", "sha256"]}
filecoin-hashers = { workspace = true, features = ["poseidon", "sha256"] }
fr32.workspace = true
sha2raw.workspace = true
storage-proofs-core.workspace = true
Expand All @@ -28,7 +28,7 @@ ff.workspace = true
generic-array.workspace = true
glob = "0.3.0"
hex.workspace = true
hwloc = { version = "0.5.0", optional = true }
hwloc = { version = "2.2.0", optional = true, package = "hwloc2" }
lazy_static.workspace = true
libc = "0.2"
log.workspace = true
Expand All @@ -53,7 +53,11 @@ sha2 = { workspace = true, features = ["compress", "asm"] }
sha2 = { workspace = true, features = ["compress"] }

[dev-dependencies]
filecoin-hashers = { workspace = true, features = ["poseidon", "sha256", "blake2s"]}
filecoin-hashers = { workspace = true, features = [
"poseidon",
"sha256",
"blake2s",
] }
# Sorted alphabetically
criterion.workspace = true
fil_logger.workspace = true
Expand All @@ -63,8 +67,18 @@ tempfile.workspace = true

[features]
default = ["opencl", "multicore-sdr"]
cuda = ["storage-proofs-core/cuda", "filecoin-hashers/cuda", "neptune/cuda", "bellperson/cuda"]
opencl = ["storage-proofs-core/opencl", "filecoin-hashers/opencl", "neptune/opencl", "bellperson/opencl"]
cuda = [
"storage-proofs-core/cuda",
"filecoin-hashers/cuda",
"neptune/cuda",
"bellperson/cuda",
]
opencl = [
"storage-proofs-core/opencl",
"filecoin-hashers/opencl",
"neptune/opencl",
"bellperson/opencl",
]
isolated-testing = []
multicore-sdr = ["hwloc"]
# This feature enables a fixed number of discarded rows for TreeR. The `FIL_PROOFS_ROWS_TO_DISCARD`
Expand Down
16 changes: 9 additions & 7 deletions storage-proofs-porep/src/stacked/vanilla/cores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ use std::convert::TryInto;
use std::sync::{Mutex, MutexGuard};

use anyhow::{format_err, Result};
use hwloc::{Bitmap, ObjectType, Topology, TopologyObject, CPUBIND_THREAD};
use hwloc::{Bitmap, CpuBindFlags, ObjectType, Topology, TopologyObject};
use lazy_static::lazy_static;
use log::{debug, warn};
use storage_proofs_core::settings::SETTINGS;

type CoreUnit = Vec<CoreIndex>;
lazy_static! {
pub static ref TOPOLOGY: Mutex<Topology> = Mutex::new(Topology::new());
pub static ref TOPOLOGY: Mutex<Topology> =
Mutex::new(Topology::new().expect("failed to initialize and load cpu topology"));
pub static ref CORE_GROUPS: Option<Vec<Mutex<CoreUnit>>> = {
let num_producers = &SETTINGS.multicore_sdr_producers;
let cores_per_unit = num_producers + 1;
Expand Down Expand Up @@ -69,7 +70,8 @@ impl Drop for Cleanup {
if let Some(prior) = self.prior_state.take() {
let child_topo = &TOPOLOGY;
let mut locked_topo = child_topo.lock().expect("poisded lock");
let _ = locked_topo.set_cpubind_for_thread(self.tid, prior, CPUBIND_THREAD);
let _ =
locked_topo.set_cpubind_for_thread(self.tid, prior, CpuBindFlags::CPUBIND_THREAD);
}
}
}
Expand All @@ -82,7 +84,7 @@ pub fn bind_core(core_index: CoreIndex) -> Result<Cleanup> {
.map_err(|err| format_err!("failed to get core at index {}: {:?}", core_index.0, err))?;

let cpuset = core
.allowed_cpuset()
.cpuset()
.ok_or_else(|| format_err!("no allowed cpuset for core at index {}", core_index.0,))?;
debug!("allowed cpuset: {:?}", cpuset);
let mut bind_to = cpuset;
Expand All @@ -91,12 +93,12 @@ pub fn bind_core(core_index: CoreIndex) -> Result<Cleanup> {
bind_to.singlify();

// Thread binding before explicit set.
let before = locked_topo.get_cpubind_for_thread(tid, CPUBIND_THREAD);
let before = locked_topo.get_cpubind_for_thread(tid, CpuBindFlags::CPUBIND_THREAD);

debug!("binding to {:?}", bind_to);
// Set the binding.
let result = locked_topo
.set_cpubind_for_thread(tid, bind_to, CPUBIND_THREAD)
.set_cpubind_for_thread(tid, bind_to, CpuBindFlags::CPUBIND_THREAD)
.map_err(|err| format_err!("failed to bind CPU: {:?}", err));

if result.is_err() {
Expand Down Expand Up @@ -239,7 +241,7 @@ fn core_units(cores_per_unit: usize) -> Option<Vec<Mutex<CoreUnit>>> {
.get_cpubind(hwloc::CpuBindFlags::empty())
.unwrap_or_else(|| {
topo.object_at_root()
.allowed_cpuset()
.cpuset()
.unwrap_or_else(hwloc::CpuSet::full)
});

Expand Down

0 comments on commit 1a7cff3

Please sign in to comment.