Skip to content
This repository has been archived by the owner on Mar 15, 2019. It is now read-only.

Commit

Permalink
changed device info to store on GPU memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Robert Rudolph committed Apr 21, 2011
1 parent 59e1f4a commit c5fc2a0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
34 changes: 34 additions & 0 deletions common/rudyGL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#ifndef __RUDY_GL_H__
#define __RUDY_GL_H__

#ifdef _WIN64
#define GLUT_NO_LIB_PRAGMA
#pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
#pragma comment (lib, "glut64.lib") /* link with Win64 GLUT lib */
#endif //_WIN64


#ifdef _WIN32
/* On Windows, include the local copy of glut.h and glext.h */
#include "GL/glut.h"
#include "GL/glext.h"

#define GET_PROC_ADDRESS( str ) wglGetProcAddress( str )

#else

/* On Linux, include the system's copy of glut.h, glext.h, and glx.h */
#if defined(__APPLE__) || defined(MACOSX)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include <GL/glext.h>
#include <GL/glx.h>
#endif
#define GET_PROC_ADDRESS( str ) glXGetProcAddress( (const GLubyte *)str )

#endif //_WIN32


#endif //__RUDY_GL_H__
13 changes: 7 additions & 6 deletions src/rudyCUDA_deviceInfo.cu
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

rudyCUDA_deviceInfo * rudyCUDA_deviceInfo_gather( void) {
int i;
rudyCUDA_deviceInfo * devices = (rudyCUDA_deviceInfo*) malloc( sizeof( rudyCUDA_deviceInfo));
rudyCUDA_deviceInfo * devices;
HANDLE_ERROR( cudaMalloc( (rudyCUDA_deviceInfo**) &devices, sizeof( rudyCUDA_deviceInfo)));
HANDLE_ERROR( cudaGetDeviceCount( &( devices->deviceCount)));
devices->devicePropertiesArray = (cudaDeviceProp**) malloc( sizeof( cudaDeviceProp*) * devices->deviceCount);
HANDLE_ERROR( cudaMalloc( (cudaDeviceProp**) &devices->devicePropertiesArray, sizeof( cudaDeviceProp*) * devices->deviceCount));
for( i= 0; i< devices->deviceCount; i++) {
devices->devicePropertiesArray[i] = (cudaDeviceProp*) malloc( sizeof( cudaDeviceProp));
HANDLE_ERROR( cudaMalloc( (cudaDeviceProp***) &devices->devicePropertiesArray[i], sizeof( cudaDeviceProp)));
HANDLE_ERROR( cudaGetDeviceProperties( devices->devicePropertiesArray[i], i));
}
return devices;
Expand All @@ -21,12 +22,12 @@ rudyCUDA_deviceInfo * rudyCUDA_deviceInfo_gather( void) {
void rudyCUDA_deviceInfo_free( rudyCUDA_deviceInfo * devices) {
int i;
for( i= 0; i< devices->deviceCount; i++) {
free( devices->devicePropertiesArray[i]);
cudaFree( devices->devicePropertiesArray[i]);
devices->devicePropertiesArray[i] = NULL;
}
free( devices->devicePropertiesArray);
cudaFree( devices->devicePropertiesArray);
devices->devicePropertiesArray = NULL;
free( devices);
cudaFree( devices);
devices = NULL;
}

Expand Down

0 comments on commit c5fc2a0

Please sign in to comment.