tests/cuda4.1sdk/tests/simpleMultiGPU/simpleMultiGPU.cpp
int findCudaDevice(int argc, const char **argv)
{
    cudaDeviceProp deviceProp;
    int devID = 0;
    // If the command-line has a device number specified, use it
    if (checkCmdLineFlag(argc, argv, "device")) {
        devID = getCmdLineArgumentInt(argc, argv, "device=");
        if (devID < 0) {
            printf("Invalid command line parameters\n");
            exit(-1);
        } else {
            devID = gpuDeviceInit(devID);
            if (devID < 0) {
                printf("exiting...\n");
                shrQAFinishExit(argc, (const char **)argv, QA_FAILED);
                exit(-1);
            }
        }
    } else {
        // Otherwise pick the device with highest Gflops/s
        devID = gpuGetMaxGflopsDeviceId();
        checkCudaErrors( cudaSetDevice( devID ) );
        checkCudaErrors( cudaGetDeviceProperties(&deviceProp, devID) );
        printf("> Using CUDA device [%d]: %s\n", devID, deviceProp.name);
    }
    return devID;
}
// Initialization code to find the best CUDA Device
Initialization code to find the best CUDA Device
Initialization code to find the best CUDA Device
int findCudaDevice(int argc, const char **argv)
{
    cudaDeviceProp deviceProp;
    int devID = 0;
    if (checkCmdLineFlag(argc, argv, "device")) {
        devID = getCmdLineArgumentInt(argc, argv, "device=");
        if (devID < 0) {
            printf("Invalid command line parameters\n");
            exit(-1);
        } else {
            devID = gpuDeviceInit(devID);
            if (devID < 0) {
                printf("exiting...\n");
                shrQAFinishExit(argc, (const char **)argv, QA_FAILED);
                exit(-1);
            }
        }
    } else {
        devID = gpuGetMaxGflopsDeviceId();
        checkCudaErrors( cudaSetDevice( devID ) );
        checkCudaErrors( cudaGetDeviceProperties(&deviceProp, devID) );
        printf("> Using CUDA device [%d]: %s\n", devID, deviceProp.name);
    }
    return devID;
}
int findCudaDevice ( int argc , const char * * argv ) { cudaDeviceProp deviceProp ; int devID = 0 ; if ( checkCmdLineFlag ( argc , argv , " " ) ) { devID = getCmdLineArgumentInt ( argc , argv , " " ) ; if ( devID < 0 ) { printf ( " \n " ) ; exit ( -1 ) ; } else { devID = gpuDeviceInit ( devID ) ; if ( devID < 0 ) { printf ( " \n " ) ; shrQAFinishExit ( argc , ( const char * * ) argv , QA_FAILED ) ; exit ( -1 ) ; } } } else { devID = gpuGetMaxGflopsDeviceId ( ) ; checkCudaErrors ( cudaSetDevice ( devID ) ) ; checkCudaErrors ( cudaGetDeviceProperties ( & deviceProp , devID ) ) ; printf ( " \n " , devID , deviceProp . name ) ; } return devID ; }
Initialization code to find the best CUDA Device
Initialization code to find the best CUDA Device
// If the command-line has a device number specified, use it // Otherwise pick the device with highest Gflops/s