import numpy as np
from vgpu_cache import VGPUCache
import time

c = VGPUCache()
t = np.random.rand(100).astype(np.float32)

# Warmup to compile the kernels
x = c.cos(t)
y = c.sin(t)
i=0
while True:
    x = c.cos(t)
    y = c.sin(t)
    
    # Use cache methods instead of operators (+, -, **) to force GPU routing
    x_sq = c.multiply(x, x)
    y_sq = c.multiply(y, y)
    sum_sq = c.add(x_sq, y_sq)
    diff = c.subtract(np.float32(1.0), sum_sq)
    
    result = c.sum(diff)
    
    if i%1000==0:
        print(f"Result: {result} | {c.report()}")
    i+=1
#    time.sleep(0.1) # Prevent flooding terminal interrupts
