PROBLEM WITH culaDeviceSpotrf CULA's device * interface.

News and announcements related to CULA development and releases.

PROBLEM WITH culaDeviceSpotrf CULA's device * interface.

Postby konstantinos » Mon Jun 01, 2015 9:30 am

I cant find the error.
Any additional suggestions you may have would be welcome.



* This example is meant to show a typical program flow when using CULA's device
* interface.
*
* 1. Allocate matrices
* 2. Initialize CULA
* 3. Initialize the A matrix to zero
* 4. Copy the A matrix to the device a matrix
* 4. Call culaDeviceSpotrf(cholesky factorization) on the matrix a
* 5. Copies the results back to the host
* 6. Call culaShutdown
*
* After each CULA operation, the status of CULA is checked. On failure, an
* error message is printed and the program exits.
*
* Note: this example performs the QR factorization on a matrix of zeros, the
* result of which is a matrix of zeros, due to the omission of ones across the
* diagonal of the upper-diagonal unitary Q.
*
* Note: this example requires the CUDA toolkit to compile.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <cula_lapack_device.h>

#include <cuda_runtime.h>
#ifdef _MSC_VER
# pragma comment(lib, "cudart.lib")
#endif


void checkStatus(culaStatus status)
{
char buf[256];

if(!status)
return;

culaGetErrorInfoString(status, culaGetErrorInfo(), buf, sizeof(buf));
printf("%s\n", buf);

culaShutdown();
exit(EXIT_FAILURE);
}


void checkCudaError(cudaError_t err)
{
if(!err)
return;

printf("%s\n", cudaGetErrorString(err));

culaShutdown();
exit(EXIT_FAILURE);
}


int main(int argc, char** argv)
{

int M = 3;

int N = M;

cudaError_t err;
culaStatus status;

// point to host memory
float* A = NULL;


// point to device memory
float* a = NULL;


printf("Allocating Matrices\n");

A = (float*)malloc(M*N*sizeof(float));
if(!A )
exit(EXIT_FAILURE);


err = cudaMalloc((void**)&a, M*N*sizeof(*A));
checkCudaError(err);



printf("Initializing CULA\n");
status = culaInitialize();
checkStatus(status);




err = cudaMemcpy(a, A, M*N*sizeof(float), cudaMemcpyHostToDevice);
checkCudaError(err);

printf("Calling culaDeviceSpotrf\n");

status = culaDeviceSpotrf( 'L', M*N, a, M*N);
checkStatus(status);


err = cudaMemcpy(A, a, M*N*sizeof(float), cudaMemcpyDeviceToHost);
checkCudaError(err);


printf("Shutting down CULA\n");
culaShutdown();

cudaFree(a);

free(A);


return EXIT_SUCCESS;
}
konstantinos
 
Posts: 1
Joined: Mon May 11, 2015 10:31 am

Return to News and Announcements

Who is online

Users browsing this forum: No registered users and 2 guests

cron