Beispiel #1
0
Object cuda_computeCapability(Object self, int nparts, int *argcv,
        Object *argv, int flags) {
    cuInit(0);
    int deviceCount = 0;
    cuDeviceGetCount(&deviceCount);
    if (deviceCount == 0) {
        raiseError("No CUDA devices found");
    }
    CUdevice cuDevice;
    int major, minor;
    cuDeviceComputeCapability(&major, &minor, cuDevice);
    return alloc_Float64(major + minor / 10.0);
}
Beispiel #2
0
Object cuda_cores(Object self, int nparts, int *argcv,
        Object *argv, int flags) {
    cuInit(0);
    int deviceCount = 0;
    cuDeviceGetCount(&deviceCount);
    if (deviceCount == 0) {
        raiseError("No CUDA devices found");
    }
    CUdevice cuDevice;
    int mpcount;
    cuDeviceGetAttribute(&mpcount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
            cuDevice);
    int major, minor;
    cuDeviceComputeCapability(&major, &minor, cuDevice);
    mpcount *= coreMultiplicand(major, minor);
    return alloc_Float64(mpcount);
}
Beispiel #3
0
Object cuda_FloatArray_at(Object self, int nparts, int *argcv,
        Object *argv, int flags) {
    int n = integerfromAny(argv[0]);
    struct CudaFloatArray *a = (struct CudaFloatArray *)self;
    return alloc_Float64(a->data[n]);
}
Beispiel #4
0
Object math_abs(Object self, int nparams, int *argcv, Object *argv, int flags) {
    
    return alloc_Float64(fabs(*(double*) argv[0]->data));
}
Beispiel #5
0
Object math_pi(Object self, int nparams, int *argcv, Object *argv, int flags) {
    
    return alloc_Float64((double)3.141592653589793);
}
Beispiel #6
0
Object math_random(Object self, int nparams, int *argcv, Object *argv, int flags) {

    return alloc_Float64((double)rand() / RAND_MAX);
}