ArrayFire: unified/basic.cpp (original) (raw)

#include

#include

#include

using namespace af;

std::vector input(100);

double unifRand() { return rand() / double(RAND_MAX); }

void testBackend() {

}

int main(int, char**) {

std::generate(input.begin(), input.end(), unifRand);

try {

printf("Trying CPU Backend\n");

testBackend();

printf("Caught exception when trying CPU backend\n");

fprintf(stderr, "%s\n", e.what());

}

try {

printf("Trying CUDA Backend\n");

testBackend();

printf("Caught exception when trying CUDA backend\n");

fprintf(stderr, "%s\n", e.what());

}

try {

printf("Trying OpenCL Backend\n");

testBackend();

printf("Caught exception when trying OpenCL backend\n");

fprintf(stderr, "%s\n", e.what());

}

return 0;

}

A multi dimensional data container.

Generic object that represents size and shape.

An ArrayFire exception class.

virtual const char * what() const

Returns an error message for the exception in a string format.

@ f32

32-bit floating point values

@ AF_BACKEND_CUDA

CUDA Compute Backend.

@ AF_BACKEND_OPENCL

OpenCL Compute Backend.

@ AF_BACKEND_CPU

CPU a.k.a sequential algorithms.

array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)

C++ Interface to generate an array with elements set to a specified value.

AFAPI void setBackend(const Backend bknd)