(k(1,:))<1)));
            else
                ids = false(1,size(x,2));
            end
        else
            ids=[];
        end
    else
        ids = [];
    end
    
    %% If one of the nnls-sub-problems k is finished (id(k)==true), transfer k from the GPU to the output array
    %  and delete it from the current job description
    if max(ids(:))
        if ~isempty(opts.gpu_id)
            X(:,rds(ids)) = gather(x(:,ids));
        else
            X(:,rds(ids)) = x(:,ids);
        end
        rd