From d420b55f949759460851447061b232abd1df7bff Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Sun, 22 Mar 2026 22:33:27 +0100 Subject: [PATCH 1/3] Modify timing to use CUDA and track GPU memory Updated timing measurement to include GPU memory usage. --- test/suite/solve/test_canonical.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/suite/solve/test_canonical.jl b/test/suite/solve/test_canonical.jl index 1c4a060bd..4cda85c8a 100644 --- a/test/suite/solve/test_canonical.jl +++ b/test/suite/solve/test_canonical.jl @@ -118,7 +118,7 @@ function test_canonical() OptimalControl.solve( pb.ocp, normalized_init, disc, mod, sol; display=false ) # warmup - timed_result = @timed begin + timed_result = CUDA.@timed begin OptimalControl.solve( pb.ocp, normalized_init, disc, mod, sol; display=false ) @@ -127,7 +127,7 @@ function test_canonical() # Extract results solve_result = timed_result.value solve_time = timed_result.time - memory_bytes = timed_result.bytes + memory_bytes = timed_result.cpu_bytes + timed_result.gpu_bytes success = OptimalControl.successful(solve_result) obj = success ? OptimalControl.objective(solve_result) : 0.0 From 9305d0fb19364ad6ccbf9c4e2bf7a22e343fbb1b Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Sun, 22 Mar 2026 22:47:00 +0100 Subject: [PATCH 2/3] Replace CUDA.@timed with @timed for timing --- test/suite/solve/test_canonical.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/suite/solve/test_canonical.jl b/test/suite/solve/test_canonical.jl index 4cda85c8a..b3132e769 100644 --- a/test/suite/solve/test_canonical.jl +++ b/test/suite/solve/test_canonical.jl @@ -118,7 +118,7 @@ function test_canonical() OptimalControl.solve( pb.ocp, normalized_init, disc, mod, sol; display=false ) # warmup - timed_result = CUDA.@timed begin + timed_result = @timed begin OptimalControl.solve( pb.ocp, normalized_init, disc, mod, sol; display=false ) @@ -127,7 +127,7 @@ function test_canonical() # Extract results solve_result = timed_result.value solve_time = timed_result.time - memory_bytes = timed_result.cpu_bytes + timed_result.gpu_bytes + memory_bytes = timed_result.bytes success = OptimalControl.successful(solve_result) obj = success ? OptimalControl.objective(solve_result) : 0.0 @@ -206,7 +206,7 @@ function test_canonical() gpu_solver[2]; display=false, ) # warmup - timed_result = @timed begin + timed_result = CUDA.@timed begin OptimalControl.solve( pb.ocp, normalized_init, @@ -220,7 +220,7 @@ function test_canonical() # Extract results solve_result = timed_result.value solve_time = timed_result.time - memory_bytes = timed_result.bytes + memory_bytes = timed_result.cpu_bytes + timed_result.gpu_bytes success = OptimalControl.successful(solve_result) obj = success ? OptimalControl.objective(solve_result) : 0.0 From dadbda3e32712a341776a53541d76f2825ca1967 Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Sun, 22 Mar 2026 22:51:38 +0100 Subject: [PATCH 3/3] Update modeler instantiation for CUDA backend --- test/suite/builders/test_options_forwarding.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/suite/builders/test_options_forwarding.jl b/test/suite/builders/test_options_forwarding.jl index 83e80d673..d01b7c6f5 100644 --- a/test/suite/builders/test_options_forwarding.jl +++ b/test/suite/builders/test_options_forwarding.jl @@ -54,7 +54,7 @@ function test_options_forwarding() if is_cuda_on() Test.@testset "backend (CUDA)" begin Test.@test begin - modeler = OptimalControl.Exa(backend=CUDA.CUDABackend()) + modeler = OptimalControl.Exa{OptimalControl.GPU}(backend=CUDA.CUDABackend()) nlp = OptimalControl.nlp_model(docp, normalized_init, modeler) # With CUDA backend, x0 should be CUDA array nlp.meta.x0 isa CUDA.CuArray