gpu : cost function