from numba import cuda
import numpy as np

@cuda.jit
def cuda_hello_kernel(arr):
    """Simple CUDA kernel that modifies an array"""
    idx = cuda.grid(1)
    if idx < arr.size:
        arr[idx] = idx

def print_hello_cuda():
    # Initialize CUDA
    if not cuda.is_available():
        print("CUDA is not available. Please check your GPU and CUDA installation.")
        return
    
    # Create a small array
    arr = np.zeros(10, dtype=np.int32)
    
    # Configure the blocks
    threadsperblock = 256
    blockspergrid = (arr.size + (threadsperblock - 1)) // threadsperblock
    
    # Run the kernel
    cuda_hello_kernel[blockspergrid, threadsperblock](arr)
    
    # Print results
    print("Hello from CUDA!")
    print("Modified array:", arr) 