Skip to content

Commit

Permalink
Define backend utility functions (cms-patatrack#40)
Browse files Browse the repository at this point in the history
* Define `is_available` functions for backends

* Add `backends` global variable

* Update version
  • Loading branch information
sbaldu authored May 9, 2024
1 parent d06fd6f commit cbb194c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
32 changes: 31 additions & 1 deletion CLUEstering/CLUEstering.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,47 @@
sys.path.insert(1, join(path, 'lib'))
import CLUE_Convolutional_Kernels as clue_kernels
import CLUE_CPU_Serial as cpu_serial

backends = ["cpu serial"]
tbb_found = exists(str(*glob(join(path, 'lib/CLUE_CPU_TBB*.so'))))
if tbb_found:
import CLUE_CPU_TBB as cpu_tbb
backends.append("cpu tbb")
cuda_found = exists(str(*glob(join(path, 'lib/CLUE_GPU_CUDA*.so'))))
if cuda_found:
import CLUE_GPU_CUDA as gpu_cuda
backends.append("gpu cuda")
hip_found = exists(str(*glob(join(path, 'lib/CLUE_GPU_HIP*.so'))))
if hip_found:
import CLUE_GPU_HIP as gpu_hip
backends.append("gpu hip")


def is_tbb_available():
"""
Returns True if the library is compiled with TBB support, False otherwise.
"""

return tbb_found


def is_cuda_available():
"""
Returns True if the library is compiled with CUDA support, False otherwise.
"""

return cuda_found


def is_hip_available():
"""
Returns True if the library is compiled with HIP support, False otherwise.
"""

return hip_found


def test_blobs(n_samples: int, n_dim: int , n_blobs: int = 4, mean: float = 0,
def test_blobs(n_samples: int, n_dim: int, n_blobs: int = 4, mean: float = 0,
sigma: float = 0.5, x_max: float = 30, y_max: float = 30) -> pd.DataFrame:
"""
Returns a dataframe containing randomly generated 2-dimensional or 3-dimensional blobs.
Expand Down
3 changes: 2 additions & 1 deletion CLUEstering/alpaka/AlpakaCore/alpakaWorkDiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ namespace cms::alpakatools {
*/
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC inline constexpr bool once_per_grid(TAcc const& acc) {
return alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc) == Vec<alpaka::Dim<TAcc>>::zeros();
return alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc) ==
Vec<alpaka::Dim<TAcc>>::zeros();
}

/*
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
from setuptools import setup

__version__ = "2.2.0"
__version__ = "2.2.1"
this_directory = Path(__file__).parent
long_description = (this_directory/'README.md').read_text()

Expand Down

0 comments on commit cbb194c

Please sign in to comment.