Last active
August 29, 2015 14:21
-
-
Save pavanky/bc872a1f3336cf58236d to your computer and use it in GitHub Desktop.
ArrayFire convolve2 benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************* | |
* Copyright (c) 2014, ArrayFire | |
* All rights reserved. | |
* | |
* This file is distributed under 3-clause BSD license. | |
* The complete license agreement can be obtained at: | |
* http://arrayfire.com/licenses/BSD-3-Clause | |
********************************************************/ | |
#include <arrayfire.h> | |
#include <cstdio> | |
#include <cstdlib> | |
using namespace af; | |
int main(int argc, char *argv[]) | |
{ | |
try { | |
// Select a device and display arrayfire info | |
int device = argc > 1 ? atoi(argv[1]) : 0; | |
af::setDevice(device); | |
af::info(); | |
const int iters = 10; | |
af::array image = af::randu(15000, 400); | |
af::array ker = af::randu(64, 32); | |
af::sync(); | |
timer::start(); | |
for (int i = 0; i < iters; i++) { | |
af::array out = convolve2(image, ker); | |
} | |
af::sync(); | |
printf("Time taken: %lfs\n", timer::stop() / iters); | |
} catch (af::exception& e) { | |
fprintf(stderr, "%s\n", e.what()); | |
throw; | |
} | |
#ifdef WIN32 // pause in Windows | |
if (!(argc == 2 && argv[1][0] == '-')) { | |
printf("hit [enter]..."); | |
fflush(stdout); | |
getchar(); | |
} | |
#endif | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment