Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch: make sure Device get thread config from host #2468

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
activate-environment: devito
environment-file: environment-dev.yml
auto-activate-base: false
python-version: 3.11

- name: Install dependencies
run: |
Expand Down
16 changes: 9 additions & 7 deletions devito/arch/archinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ def numa_domains(self):
def threads_per_core(self):
return self.cores_logical // self.cores_physical

@property
def cores_physical_per_numa_domain(self):
return self.cores_physical // self.numa_domains

@property
def memtotal(self):
"""Physical memory size in bytes, or None if unknown."""
Expand Down Expand Up @@ -734,10 +738,6 @@ def numa_domains(self):
warning("NUMA domain count autodetection failed")
return 1

@property
def cores_physical_per_numa_domain(self):
return self.cores_physical // self.numa_domains

@cached_property
def memtotal(self):
return psutil.virtual_memory().total
Expand Down Expand Up @@ -804,13 +804,15 @@ def _detect_isa(self):

class Device(Platform):

def __init__(self, name, cores_logical=1, cores_physical=1, isa='cpp',
def __init__(self, name, cores_logical=None, cores_physical=None, isa='cpp',
max_threads_per_block=1024, max_threads_dimx=1024,
max_threads_dimy=1024, max_threads_dimz=64):
super().__init__(name)

self.cores_logical = cores_logical
self.cores_physical = cores_physical
cpu_info = get_cpu_info()

self.cores_logical = cores_logical or cpu_info['logical']
self.cores_physical = cores_physical or cpu_info['physical']
self.isa = isa

self.max_threads_per_block = max_threads_per_block
Expand Down
11 changes: 10 additions & 1 deletion tests/test_gpu_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
SubDimension, SubDomain, SubDomainSet, TimeFunction,
Operator, configuration, switchconfig, TensorTimeFunction,
Buffer)
from devito.arch import get_gpu_info
from devito.arch import get_gpu_info, get_cpu_info, Device, Cpu64
from devito.exceptions import InvalidArgument
from devito.ir import (Conditional, Expression, Section, FindNodes, FindSymbols,
retrieve_iteration_tree)
Expand Down Expand Up @@ -47,6 +47,15 @@ def custom_compiler(self):
op.apply(time_M=10)
assert np.all(u.data[1] == 11)

def test_host_threads(self):
plat = configuration['platform']

assert isinstance(plat, Device)

nth = plat.cores_physical
assert nth == get_cpu_info()['physical']
assert nth == Cpu64("test").cores_physical


class TestCodeGeneration:

Expand Down
Loading