fprintf('\n=== GPU Forward-Compatibility enablement (R2024b) ===\n');
parallel.gpu.enableCUDAForwardCompatibility(true);
fprintf('Forward Compatibility: ENABLED\n');
fprintf(2,'[ERROR] Could not enable Forward Compatibility: %s\n', ME.message);
n = gpuDeviceCount("available");
fprintf('CUDA devices detected by MATLAB: %d\n', n);
fprintf(2,'[ERROR] gpuDeviceCount() failed: %s\n', ME.message);
fprintf(2,['[WARN] MATLAB sees no available CUDA devices.\n' ...
' Check NVIDIA driver (Studio), nvidia-smi, and GPU preference for MATLAB.exe.\n']);
fprintf('Selected GPU: %s | ComputeCapability=%s | DriverModel=%s\n', ...
dev.Name, dev.ComputeCapability, dev.DriverModel);
fprintf('TotalMemory: %.2f GB | AvailableMemory: %.2f GB\n', ...
dev.TotalMemory/2^30, dev.AvailableMemory/2^30);
fprintf(2,'[ERROR] gpuDevice(1) failed: %s\n', ME.message);
fprintf('\nWarm-up and benchmark (GEMM %dx%d, single precision)\n', sz, sz);
A = gpuArray.rand(sz,'single');
fprintf('GPU time (second run): %.3f s\n', tGPU);
xCPU = rand(sz,'single');
tCPU = timeit(@() xCPU'*xCPU);
fprintf('CPU time: %.3f s | speedup ~ x%.2f\n', tCPU, tCPU/max(tGPU,eps));
fprintf(2,'[WARN] Benchmark failed (non-critical): %s\n', ME.message);
fprintf('\nFinal status: GPU ready with Forward Compatibility enabled.\n');
fprintf('Tip: add the command to startup.m to automate in future sessions.\n');