Skip to content

Instantly share code, notes, and snippets.

@mantaionut
Created March 14, 2024 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mantaionut/e4c588e2f5273f75e8eb286a54f20c69 to your computer and use it in GitHub Desktop.
Save mantaionut/e4c588e2f5273f75e8eb286a54f20c69 to your computer and use it in GitHub Desktop.
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdio.h>
#include <chrono>
#include <iostream>
__global__ void vectorized_elementwise_kernel(int N) {
}
inline void benchmarkTest(int iterations)
{
double elapsed_time = 0;
for (int i = 0; i < iterations; i++)
{
auto start = std::chrono::steady_clock::now();
vectorized_elementwise_kernel
<< <8, 128, 0, nullptr >> > (4000);
auto end = std::chrono::steady_clock::now();
elapsed_time += std::chrono::duration<double>(end - start).count();
}
std::cout << "benchmark iterations " << iterations << " took " << elapsed_time << "\n";
}
int main()
{
cudaError_t cudaStatus;
cudaStatus = cudaSetDevice(0);
benchmarkTest(750);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment