Skip to content

Commit

Permalink
DeviceMemoryUsage: only use on Nvidia, use ProcessLogger for version.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Aug 26, 2024
1 parent 0d680df commit ff04638
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mirgecom/logging_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
.. autofunction:: logmgr_set_time
"""

import logging

from logpyle import (LogQuantity, PostLogQuantity, LogManager,
MultiPostLogQuantity, add_run_info,
add_general_quantities, add_simulation_quantities)
Expand All @@ -55,6 +57,9 @@
import grudge.op as oper
from typing import List


logger = logging.getLogger(__name__)

MemPoolType = Union[cl.tools.MemoryPool, cl.tools.SVMPool]


Expand Down Expand Up @@ -114,7 +119,8 @@ def logmgr_add_device_name(logmgr: LogManager, queue: cl.CommandQueue): # noqa:
def logmgr_add_device_memory_usage(logmgr: LogManager, queue: cl.CommandQueue) \
-> None:
"""Add the OpenCL device memory usage to the log."""
if not queue or not (queue.device.type & cl.device_type.GPU):
from pyopencl.characterize import nv_compute_capability
if not queue or nv_compute_capability(queue.device) is None:
return
logmgr.add_quantity(DeviceMemoryUsage())

Expand Down Expand Up @@ -192,8 +198,10 @@ def add_package_versions(mgr: LogManager, path_to_version_sh: Optional[str] = No
warn("Could not find emirge's version.sh.")

else:
from pytools import ProcessLogger
try:
output = subprocess.check_output(path_to_version_sh)
with ProcessLogger(logger, "emirge's version.sh"):
output = subprocess.check_output(path_to_version_sh)
except OSError as e:
warn("Could not record emirge's package versions: " + str(e))

Expand Down

0 comments on commit ff04638

Please sign in to comment.