/// <summary>
    ///   This method must be called (only) once before calling StartRun.
    ///   `graph` and `gpuHelper` (if useGPU is true) are initialized here.
    ///    If the config is invalid, it throws an error.
    /// </summary>
    public void Initialize()
    {
        if (config == null)
        {
            throw new InvalidOperationException("config is missing");
        }

        graph = new CalculatorGraph(config.text);

        if (shouldUseGPU())
        {
            var gpuResources = new StatusOrGpuResources().ConsumeValue();
            graph.SetGpuResources(gpuResources).AssertOk();

            gpuHelper = new GlCalculatorHelper();
            gpuHelper.InitializeForTest(graph.GetGpuResources());
        }
    }