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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
//CUDA EDUCATION //CUDA Device Management | cudaLimitPrintfFifoSize | cudaLimitStackSize | cudaLimitMallocHeapSize | A quick overview of device management variables in CUDA //Website: cudaeducation.com //Twitter: @cudaeducation //Email: cudaeducation@gmail.com //YouTube: Cuda Education | Please subscribe //Slack: https://bit.ly/2NBBG4h | Join the workspace //Mailing List: Visit cudaeducation.com to join our mailing list //Donate: Visit cudaeducation.com to donate //DISCLAIMER: Use at your own risk. This code is for teaching purposes only! CUDA Education does not guarantee the accuracy of this code in any way. This code should not be used in a production or commercial environment. Any liabilities or loss resulting from the use of this code, in whole or in part, will not be the responsibility of CUDA Education. //All rights reserved. This code is the property of CUDA Education. Please contact CUDA Education at cudaeducation@gmail.com if you would like to use this code in any way, shape or form. #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void cuda_education_device_management() { //CUDA EDUCATION //Website: cudaeducation.com //Twitter: @cudaeducation //Email: cudaeducation@gmail.com //YouTube: Cuda Education | Please subscribe //Donate: Visit cudaeducation.com to donate to the cause } int main() { //initialize size variable size_t size; //START PRINT BUFFER SIZE //set print buffer size //this must be set before launching any kernels cudaDeviceSetLimit(cudaLimitPrintfFifoSize, 1); cudaDeviceGetLimit(&size, cudaLimitPrintfFifoSize); printf("Printf size found to be %d\n", (int)size); //END PRINT BUFFER SIZE //START STACK SIZE //set the size of stack //this must be set before launching any kernels cudaDeviceSetLimit(cudaLimitStackSize, 1); cudaDeviceGetLimit(&size, cudaLimitStackSize); printf("Stack size found to be %d\n", (int)size); //END STACK SIZE //START HEAP SIZE //set the heap size //this must be set before launching any kernels cudaDeviceSetLimit(cudaLimitMallocHeapSize, 1); cudaDeviceGetLimit(&size, cudaLimitMallocHeapSize); printf("Malloc Heap Size found to be %d\n", (int)size); //END HEAP SIZE //get the nVidia GPU running CUDA ready int cuda_education_device = 0; //set the device to be used for CUDA execution cudaSetDevice(cuda_education_device); //launch the CUDA kernel //cuda_education_grid and BLOCK are used as launch parameters cuda_education_device_management << <1, 1 >> > (); //practice good housekeeping by resetting the device when you are done cudaDeviceReset(); //CUDA EDUCATION //Website: cudaeducation.com //Twitter: @cudaeducation //Email: cudaeducation@gmail.com //YouTube: Cuda Education //Donate: Visit cudaeducation.com to donate to the cause } |
Teaching & Consulting sessions available cudaeducation@gmail.com