Conjugate gradient implementation in C
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
cpu linesearch counter bug fixed Jul 30, 2013
openCL linesearch counter bug fixed Jul 30, 2013 Minor Update Jul 29, 2013


Conjugate gradient implementation in C. This is a port of fmincg.m in Octave. There are two implementations of fmincg in C included here. The one in cpu/ is suitable for execution on the CPU. The second in openCL/ is suited to execution as an openCL kernel.

When using openCL, often the cost function and gradient evaluation is performed on an openCL target such as the GPU. If the fmincg minimizer is run on the host CPU, the latency of the data trasfer between the host(CPU) and the device(GPU) may become a bottleneck. So it is desirable to run the minimizer as an openCL kernel. However, openCL kernels cannot call other openCL kernels. The implementation of fmincg in openCL/ is written in such a way that the state of the fmincg minimizer is kept entirely in memory and can be resumed after cost function computation.


  • GCC toolchain
  • OpenCL driver
  • PyOpenCL

The last two are needed only for the openCL implementation.


See cpu/example.c and openCL/ for examples on how to use the minimizer.