Komrade: own the means of computation version 0.9 released

We are pleased to announce the first release of Komrade, an open-source high-level template library for developing CUDA applications with an interface similar to the C++ Standard Template Library (STL). We believe Komrade can enhance developer productivity without sacrificing speed or flexibility.

The komrade::host_vector and komrade::device_vector containers simplify memory management and transfers between host and device. Komrade provides efficient templated algorithms for:

    sorting - komrade::sort and komrade::sort_by_key

    transformations - komrade::transform

    reductions - komrade::reduce and komrade::transform_reduce

    scans - komrade::inclusive_scan and komrade::transform_inclusive_scan

    And many more!

Refer to http://code.google.com/p/komrade/wiki/Documentation for a complete listing.

As the following example shows, Komrade applications are concise and readable.


#include <komrade/host_vector.h>

#include <komrade/device_vector.h>

#include <komrade/generate.h>

#include <komrade/sort.h>


int main(void)


// generate random data on the host

komrade::host_vector<int> h_vec(20);

komrade::generate(h_vec.begin(), h_vec.end(), rand);

// transfer to device and sort

komrade::device_vector<int> d_vec = h_vec;

komrade::sort(d_vec.begin(), d_vec.end());

return 0;



Komrade provides high-level primitives for composing interesting computations.

This example computes the norm of a vector.


#include <komrade/transform_reduce.h>

#include <komrade/functional.h>

#include <komrade/device_vector.h>

#include <komrade/host_vector.h>


// square computes the square of a number f(x) -> x*x


struct square


__host__ __device__

T operator()(const T& x) const { 

    return x * x;



int main(void)


// initialize host array

float x[4] = {1.0, 2.0, 3.0, 4.0};

// transfer to device

komrade::device_vector<float> d_x(x, x + 4);

// setup arguments

square<float>        unary_op;

komrade::plus<float> binary_op;

float init = 0;

// compute norm

float norm = std::sqrt( komrade::transform_reduce(d_x.begin(), d_x.end(), unary_op, init, binary_op) );

std::cout << norm << std::endl;

return 0;



Download Komrade here, and check out the tutorial to get started.

Komrade is open source under the Apache 2.0 license and available now @ http://komrade.googlecode.com

Komrade requires CUDA 2.2 beta, which is available to registered developers. See [topic=“92580”]this thread[/topic] for details.

Cool! How long have you been developing it for?

Wow, what a delightful surprise!
Thanks for sharing it with the community. Basic libraries are extremely important to CUDA development, so this is a great service.

Could you give a short comparison to CUDPP, discussing usage differences and also speed/efficiency?

I think this is an excellent project. Perhaps you should also consider distributing it with the CUDA SDK/Toolkit (and documentation). I was hoping that nVidia would similarly turn CUBLAS and CUFFT into open-source projects at some point, but I don’t think it’ll ever happen now that they’ve removed the source from public downloads.

In any case, I think this will make it very easy to add some basic CUDA functionality to a program, which means you’ll attract that many more developers to the platform.

As far as I know this is because the code as published is non-compiling. It is still available at the developer site (so it is still available without restrictions). They are waiting for an OK from their legal department to ship the compiling version.