Skip to content

Commit

Permalink
checking Linkcompile
Browse files Browse the repository at this point in the history
  • Loading branch information
Nizben committed Nov 6, 2024
1 parent 5cd0f72 commit f6cc393
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 179 deletions.
6 changes: 3 additions & 3 deletions keopscore/keopscore/binders/LinkCompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from keopscore.utils.code_gen_utils import get_hash_name
from keopscore.utils.misc_utils import KeOps_Error, KeOps_Message

base_config = ConfigNew() # instanciate ConfigNew
cpp_flags = base_config.get_cpp_flags()
get_build_folder = base_config.get_build_folder()
config = ConfigNew() # instanciate ConfigNew
cpp_flags = config.get_cpp_flags()
get_build_folder = config.get_build_folder()

class LinkCompile:
"""
Expand Down
161 changes: 0 additions & 161 deletions keopscore/keopscore/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,161 +0,0 @@
import sys
import shutil
from pathlib import Path
import os

# Import the configuration classes
from base_config import ConfigNew
from Platform import DetectPlatform
from cuda import CUDAConfig
from openmp import OpenMPConfig

def main():
# Define status indicators
check_mark = '✅'
cross_mark = '❌'

# Create instances of the configuration classes
platform_detector = DetectPlatform()
cuda_config = CUDAConfig()
openmp_config = OpenMPConfig()
config = ConfigNew() # Base configuration

# Header
print("\nKeOps Configuration and System Health Check")
print("=" * 60)

# General Information
print(f"\nGeneral Information")
print("-" * 60)
platform_detector.print_os()
platform_detector.print_python_version()
platform_detector.print_env_type()

# Python Executable Path
python_path = Path(sys.executable)
python_path_exists = python_path.exists()
python_status = check_mark if python_path_exists else cross_mark
print(f"Python Executable: {python_path} {python_status}")

# Environment Path
env_path = os.environ.get('PATH', '')
print(f"System PATH Environment Variable:")
print(env_path)

# Compiler Configuration
print(f"\nCompiler Configuration")
print("-" * 60)
compiler_path = shutil.which(config.cxx_compiler) if config.cxx_compiler else None
compiler_available = compiler_path is not None
compiler_status = check_mark if compiler_available else cross_mark
config.print_cxx_compiler()
print(f"C++ Compiler Path: {compiler_path or 'Not Found'} {compiler_status}")
if not compiler_available:
print(f" {cross_mark} Compiler '{config.cxx_compiler}' not found on the system.")

# OpenMP Support
openmp_status = check_mark if openmp_config.get_use_OpenMP() else cross_mark
print(f"\nOpenMP Support")
print("-" * 60)
openmp_config.print_use_OpenMP()
if openmp_config.get_use_OpenMP():
openmp_lib_path = openmp_config.openmp_lib_path or 'Not Found'
print(f"OpenMP Library Path: {openmp_lib_path}")
else:
print(f" {cross_mark} OpenMP support is disabled or not available.")

# CUDA Support
cuda_status = check_mark if cuda_config.get_use_cuda() else cross_mark
print(f"\nCUDA Support")
print("-" * 60)
cuda_config.print_use_cuda()
if cuda_config.get_use_cuda():
print(f"CUDA Version: {cuda_config.cuda_version}")
print(f"Number of GPUs: {cuda_config.n_gpus}")
print(f"GPU Compile Flags: {cuda_config.gpu_compile_flags}")
# CUDA Include Path
cuda_include_path = cuda_config.get_cuda_include_path
cuda_include_status = check_mark if cuda_include_path else cross_mark
print(f"CUDA Include Path: {cuda_include_path or 'Not Found'} {cuda_include_status}")

# Attempt to find CUDA compiler
nvcc_path = shutil.which('nvcc')
nvcc_status = check_mark if nvcc_path else cross_mark
print(f"CUDA Compiler (nvcc): {nvcc_path or 'Not Found'} {nvcc_status}")
if not nvcc_path:
print(f" {cross_mark} CUDA compiler 'nvcc' not found in PATH.")
else:
# CUDA is disabled; display the CUDA message
print(f" {cross_mark} {cuda_config.cuda_message}")

# Conda or Virtual Environment Paths
print(f"\nEnvironment Paths")
print("-" * 60)
env_type = platform_detector.get_env_type()
if env_type.startswith("conda"):
conda_env_path = Path(os.environ.get('CONDA_PREFIX', ''))
conda_env_status = check_mark if conda_env_path.exists() else cross_mark
print(f"Conda Environment Path: {conda_env_path} {conda_env_status}")
elif env_type == "virtualenv":
venv_path = Path(sys.prefix)
venv_status = check_mark if venv_path.exists() else cross_mark
print(f"Virtualenv Path: {venv_path} {venv_status}")
else:
print("Not using Conda or Virtualenv.")

# Paths and Directories
print(f"\nPaths and Directories")
print("-" * 60)
# Check if paths exist
paths = [
('Base Directory Path', Path(config.base_dir_path)),
('Template Path', Path(config.template_path)),
('Bindings Source Directory', Path(config.bindings_source_dir)),
('KeOps Cache Folder', Path(config.keops_cache_folder)),
('Default Build Path', Path(config.default_build_path)),
]
for name, path in paths:
path_exists = path.exists()
status = check_mark if path_exists else cross_mark
print(f"{name}: {path} {status}")
if not path_exists:
print(f"Path '{path}' does not exist.")

# JIT Binary
config.print_jit_binary()
jit_binary_path = Path(config.jit_binary)
jit_binary_exists = jit_binary_path.exists()
jit_binary_status = check_mark if jit_binary_exists else cross_mark
print(f"JIT Binary Exists: {'Yes' if jit_binary_exists else 'No'} {jit_binary_status}")

# Environment Variables
print(f"\nEnvironment Variables")
print("-" * 60)
config.print_environment_variables()

# Conclusion
print("\nConfiguration Status Summary")
print("=" * 60)
# Determine overall status
issues = []
if not compiler_available:
issues.append(f"C++ compiler '{config.cxx_compiler}' not found.{cross_mark}")
if not openmp_config.get_use_OpenMP():
issues.append(f"OpenMP support is disabled or not available.{cross_mark}")
if cuda_config.get_use_cuda():
nvcc_path = shutil.which('nvcc')
if not nvcc_path:
issues.append(f"CUDA compiler 'nvcc' not found.{cross_mark}")
if not cuda_config.get_cuda_include_path:
issues.append(f"CUDA include path not found.{cross_mark}")
if not Path(config.keops_cache_folder).exists():
issues.append(f"KeOps cache folder '{config.keops_cache_folder}' does not exist.")
if issues:
print(f"Some configurations are missing or disabled:{cross_mark}")
for issue in issues:
print(f"{issue}")
else:
print(f"{check_mark} All configurations are properly set up.")

if __name__ == "__main__":
main()
163 changes: 148 additions & 15 deletions keopscore/keopscore/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,154 @@ def print_environment_variables(self):
if __name__ == "__main__":
# Create an instance of the configuration class
config = ConfigNew()

# Print common configuration information
print("\nCommon Configuration Information")
print("=" * 40)
config.print_base_dir_path()
config.print_template_path()
config.print_bindings_source_dir()
config.print_keops_cache_folder()
config.print_default_build_folder_name()
config.print_default_build_path()
config.print_jit_binary()
from Platform import DetectPlatform
from cuda import CUDAConfig
from openmp import OpenMPConfig

# Define status indicators
check_mark = '✅'
cross_mark = '❌'

# Create instances of the configuration classes
platform_detector = DetectPlatform()
cuda_config = CUDAConfig()
openmp_config = OpenMPConfig()
config = ConfigNew() # Base configuration

# Header
print("\nKeOps Configuration and System Health Check")
print("=" * 60)

# General Information
print(f"\nGeneral Information")
print("-" * 60)
platform_detector.print_os()
platform_detector.print_python_version()
platform_detector.print_env_type()

# Python Executable Path
python_path = Path(sys.executable)
python_path_exists = python_path.exists()
python_status = check_mark if python_path_exists else cross_mark
print(f"Python Executable: {python_path} {python_status}")

# Environment Path
env_path = os.environ.get('PATH', '')
print(f"System PATH Environment Variable:")
print(env_path)

# Compiler Configuration
print(f"\nCompiler Configuration")
print("-" * 60)
compiler_path = shutil.which(config.cxx_compiler) if config.cxx_compiler else None
compiler_available = compiler_path is not None
compiler_status = check_mark if compiler_available else cross_mark
config.print_cxx_compiler()
config.print_cpp_env_flags()
config.print_compile_options()
config.print_cpp_flags()
config.print_disable_pragma_unrolls()
print(f"C++ Compiler Path: {compiler_path or 'Not Found'} {compiler_status}")
if not compiler_available:
print(f" {cross_mark} Compiler '{config.cxx_compiler}' not found on the system.")

# OpenMP Support
openmp_status = check_mark if openmp_config.get_use_OpenMP() else cross_mark
print(f"\nOpenMP Support")
print("-" * 60)
openmp_config.print_use_OpenMP()
if openmp_config.get_use_OpenMP():
openmp_lib_path = openmp_config.openmp_lib_path or 'Not Found'
print(f"OpenMP Library Path: {openmp_lib_path}")
else:
print(f" {cross_mark} OpenMP support is disabled or not available.")

# CUDA Support
cuda_status = check_mark if cuda_config.get_use_cuda() else cross_mark
print(f"\nCUDA Support")
print("-" * 60)
cuda_config.print_use_cuda()
if cuda_config.get_use_cuda():
print(f"CUDA Version: {cuda_config.cuda_version}")
print(f"Number of GPUs: {cuda_config.n_gpus}")
print(f"GPU Compile Flags: {cuda_config.gpu_compile_flags}")
# CUDA Include Path
cuda_include_path = cuda_config.get_cuda_include_path
cuda_include_status = check_mark if cuda_include_path else cross_mark
print(f"CUDA Include Path: {cuda_include_path or 'Not Found'} {cuda_include_status}")

# Attempt to find CUDA compiler
nvcc_path = shutil.which('nvcc')
nvcc_status = check_mark if nvcc_path else cross_mark
print(f"CUDA Compiler (nvcc): {nvcc_path or 'Not Found'} {nvcc_status}")
if not nvcc_path:
print(f" {cross_mark} CUDA compiler 'nvcc' not found in PATH.")
else:
# CUDA is disabled; display the CUDA message
print(f" {cross_mark} {cuda_config.cuda_message}")

# Conda or Virtual Environment Paths
print(f"\nEnvironment Paths")
print("-" * 60)
env_type = platform_detector.get_env_type()
if env_type.startswith("conda"):
conda_env_path = Path(os.environ.get('CONDA_PREFIX', ''))
conda_env_status = check_mark if conda_env_path.exists() else cross_mark
print(f"Conda Environment Path: {conda_env_path} {conda_env_status}")
elif env_type == "virtualenv":
venv_path = Path(sys.prefix)
venv_status = check_mark if venv_path.exists() else cross_mark
print(f"Virtualenv Path: {venv_path} {venv_status}")
else:
print("Not using Conda or Virtualenv.")

# Paths and Directories
print(f"\nPaths and Directories")
print("-" * 60)
# Check if paths exist
paths = [
('Base Directory Path', Path(config.base_dir_path)),
('Template Path', Path(config.template_path)),
('Bindings Source Directory', Path(config.bindings_source_dir)),
('KeOps Cache Folder', Path(config.keops_cache_folder)),
('Default Build Path', Path(config.default_build_path)),
]
for name, path in paths:
path_exists = path.exists()
status = check_mark if path_exists else cross_mark
print(f"{name}: {path} {status}")
if not path_exists:
print(f"Path '{path}' does not exist.")

# JIT Binary
config.print_jit_binary()
jit_binary_path = Path(config.jit_binary)
jit_binary_exists = jit_binary_path.exists()
jit_binary_status = check_mark if jit_binary_exists else cross_mark
print(f"JIT Binary Exists: {'Yes' if jit_binary_exists else 'No'} {jit_binary_status}")

# Environment Variables
print(f"\nEnvironment Variables")
print("-" * 60)
config.print_environment_variables()

# Conclusion
print("\nConfiguration Status Summary")
print("=" * 60)
# Determine overall status
issues = []
if not compiler_available:
issues.append(f"C++ compiler '{config.cxx_compiler}' not found.{cross_mark}")
if not openmp_config.get_use_OpenMP():
issues.append(f"OpenMP support is disabled or not available.{cross_mark}")
if cuda_config.get_use_cuda():
nvcc_path = shutil.which('nvcc')
if not nvcc_path:
issues.append(f"CUDA compiler 'nvcc' not found.{cross_mark}")
if not cuda_config.get_cuda_include_path:
issues.append(f"CUDA include path not found.{cross_mark}")
if not Path(config.keops_cache_folder).exists():
issues.append(f"KeOps cache folder '{config.keops_cache_folder}' does not exist.")
if issues:
print(f"Some configurations are missing or disabled:{cross_mark}")
for issue in issues:
print(f"{issue}")
else:
print(f"{check_mark} All configurations are properly set up.")

0 comments on commit f6cc393

Please sign in to comment.