zoukankan      html  css  js  c++  java
  • Windows 运行时加载动态库

    下面是一个运行时加载nvcuda.dll,并检测当前驱动版本最大支持的CUDA版本的例子。

    #include "cuda.h"
    #include <stdio.h>
    #include <Windows.h>
    
    typedef CUresult (__cdecl *CU_DriverGetVersion)(int *);
    
    int main()
    {
        HINSTANCE nvcudalib;
        nvcudalib = LoadLibrary(TEXT("nvcuda.dll"));
    
        if(nvcudalib) {
            int cudaVersion = 0;
            CU_DriverGetVersion mycuDriverGetVersion
                    = (CU_DriverGetVersion)GetProcAddress(nvcudalib, "cuDriverGetVersion");
            CUresult res = mycuDriverGetVersion(&cudaVersion);
            if(res == CUDA_SUCCESS) {
                int major = cudaVersion / 1000;
                int minor = (cudaVersion % 1000) / 10;
                printf("The latest CUDA version by your driver is %d.%d
    ", major, minor);
            }
            else {
                printf("Unkonwn Error.");
            }
            FreeLibrary(nvcudalib);
        }
        else {
            printf("Load nvcuda.dll error.");
        }
    
        getchar();
        return 0;
    }
    
    
  • 相关阅读:
    cookie和session会话技术
    hdoj 1176 免费馅饼
    nyoj 14 会场安排问题
    hdoj 1575 Tr A
    poj 1163 The Triangle
    hdoj 2157 How many ways??
    贪心Poj1328
    贪心 序列
    差分约束Poj 3169 Layout
    差分约束Poj3159 Candies
  • 原文地址:https://www.cnblogs.com/pplxlee/p/11419776.html
Copyright © 2011-2022 走看看