#include #include __global__ void myKernel() { // Kernel code goes here } int main() { // Set the device (GPU) cudaSetDevice(0); // Get device properties cudaDeviceProp prop; cudaGetDeviceProperties(&prop, 0); // Set kernel parameters (adjust as needed) int numThreadsPerBlock = 256; int numBlocks = 16; // Compute occupancy int activeWarps; int maxWarps; cudaOccupancyMaxActiveBlocksPerMultiprocessor(&activeWarps, myKernel, numThreadsPerBlock, 0); maxWarps = prop.maxThreadsPerMultiProcessor / prop.warpSize; // Compute occupancy ratio float occupancy = (float)activeWarps / maxWarps; printf("Occupancy: %f\n", occupancy); return 0; }