#!/usr/bin/env guile
!#
;;
;; Verbose cache test - check if caching is working
;;
(use-modules (opencog) (opencog exec))
(use-modules (opencog sensory) (opencog opencl))
(use-modules (ice-9 format))
(define (get-time-ms)
(let ((t (gettimeofday)))
(+ (* (car t) 1000.0) (/ (cdr t) 1000.0))))
;; Force output immediately
(setvbuf (current-output-port) 'none)
(format #t "\n=== Starting test at ~a ===\n\n" (strftime "%H:%M:%S" (localtime (current-time))))
;; Check initial state
(format #t "Checking cache before test:\n")
(system "ls -la ~/.cache/opencog/opencl/*/*.bin 2>/dev/null || echo ' No cache files found'")
(newline)
;; First open
(format #t "Opening kernel (check logs for compile vs cache)...\n")
(define t0 (get-time-ms))
(define gpu (OpenclNode "opencl://:/tmp/pmfg-kernel.cl"))
(cog-execute! (SetValue gpu (Predicate "*-open-*") (Type 'FloatValue)))
(define t1 (get-time-ms))
(format #t "Open took: ~,2f seconds\n\n" (/ (- t1 t0) 1000.0))
;; Check cache after
(format #t "Checking cache after open:\n")
(system "ls -la ~/.cache/opencog/opencl/*/*.bin 2>/dev/null || echo ' No cache files found'")
(newline)
(format #t "=== Done ===\n")