Libra C++ API, programming both CPUs and GPUs.


Modules

 Libra C++ functions

Classes

class  gVar
class  gVar

Hello World - Matrix Multiplication

Our HelloWorld program starts like this:
#if 1
#include <iostream>
#include <conio.h>
// Libra
#include <Libra.h>    // C and C++ API

int main(int argc, char** argv)
{
        const int N = 2048;
        long long flopCount;
        double startTime, time, gflops;

        gVar A, B, C;
First we initialize Libra by calling libra_Init().
        if (libra_Init(argc, argv) != 0)
                return 1;
Then we create two matrices A and B of dimensions NxN.
        libra_SetDefaultDataType(GFLOAT32);

        /* Create two N by N matrices. */
        A = ones(N);
        B = A;
We then perform dense matrix multiplication (SGEMM) and time it.
        startTime = libra_GetTime();

        /* Perform matrix multiplication */
        C = A * B;
        
        time = libra_GetTime() - startTime;
        printf("Total time : %g%s", time*1000, " milliseconds\n");

        /* Compute a performance measurement. Gigaflop / s. */
        flopCount = (2*N-1)*N*(long long)N;
        gflops = flopCount / time / 1e9;
        printf("%g%s", gflops, " GFlop/s.\n");
After printing measurements our program ends and calls libra_Shutdown().
        libra_Shutdown();

        printf("\nPress a key to exit...\n");
        _getch();

        return 0;
}

Generated on Mon Jun 7 18:23:26 2010 for Libra by  doxygen 1.5.2