Rate This Document
Findability
Accuracy
Completeness
Readability

API Calling Example

This section provides sample code for calling HMPP interface functions to help you quickly get started with the library.

  1. Create a test.cpp file.
  2. Add the following code to the test.cpp file.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    #include <stdio.h>
    #include <stdlib.h>
    #include "hmpp.h"
    #define BUFFER_SIZE_T 500
    void AddExample() {
        uint32_t *src1 = HMPPS_Malloc_32u(BUFFER_SIZE_T);
        uint32_t *src2 = HMPPS_Malloc_32u(BUFFER_SIZE_T);
        uint32_t *dst = HMPPS_Malloc_32u(BUFFER_SIZE_T);
        int32_t i, result;
    
        if (src1 == NULL || src2 == NULL || dst == NULL) {
            return;
        }
        for (i = 0; i < BUFFER_SIZE_T; ++i) {
             src1[i] = i;
             src2[i] = i + 1;
        }
        
        result = HMPPS_Add_32u(src1, src2, dst, BUFFER_SIZE_T);
        printf("result = %d \n dst = ", result);
        for (i = 0; i < BUFFER_SIZE_T; i++) {
            printf("%d ", dst[i]);
        }
        printf("\n");
    
        HMPPS_Free(src1);
        HMPPS_Free(src2);
        HMPPS_Free(dst);
    }
    
    1
    2
    3
    4
    int main(void){
        AddExample();
        return 0;
    }
    

Example of Compiling and Executing the File

  1. Compile the file.
    1
    g++ test.cpp -o test -L /usr/local/kml/lib/ -lkfft -lkfftf -L /usr/local/kml/lib/kvml/single -lkvml -lkm -lm -L /usr/local/kml/lib/kblas/locking -lkblas -L /usr/local/lib/HMPP -lHMPP_signal -lHMPP_core -lpthread
    
  2. Execute the file.
    1
    ./test