|
LQ Newbie
Registered: Feb 2008
Posts: 5
Rep:
|
Parallel Graphics SDL MPI: No available video device
Hello everyone,
I have configured a 1-master-4-client i.e. 5 node cluster using Linux Fedora 7. Everything is working fine. Even simple MPI program like the one below is working fine.
*****************************************
#include <stdio.h>
#include <mpi.h>
int main(int argc, char *argv[]) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello, world! I am %d of %d\n", rank, size);
MPI_Finalize();
return 0;
}
*****************************************
The problem is with parallel graphics.
I have mounted the monitors of the four clients as a 2x2 matrix, with node numbers starting from top left corner and moving clockwise.
Like this,
1 2
4 3
My code, using both MPI and SDL libraries, should display an image in its entirety on the server, while on each client it should zoom and display only one quarter of the image. After many sweating hours, I could just display the image on nodes 1 and 3 while nodes 2 and 4 refuse to display and error message that it gives after few seconds of display is "No available video device" both for nodes 2 and 4.
Please help.
The code is:
*****************************************
#include <stdio.h>
#include <mpi.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_rotozoom.h>
void HandleEvent(){
SDL_Event event;
int done = 0;
while(!done){
if( SDL_PollEvent(&event) ){
switch(event.type){
case SDL_KEYDOWN:
done = 1;
break;
}
}
else
SDL_Delay(10);
}
}
void display(char *img, int rank){
SDL_Surface *screen, *image, *zoomedimage;
SDL_Rect dstRect;
float zoomX,zoomY;
if(SDL_Init(SDL_INIT_VIDEO) == -1){
printf("Error in init in node %d : %s\n",rank,SDL_GetError());
exit(100);
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(1024,768,32,SDL_FULLSCREEN);
if( screen == NULL){
printf("Error in screen in node %d : %s\n",rank,SDL_GetError());
exit(2);
}
image = IMG_Load(img);
if(image == NULL){
printf("Error loading image in node %d : %s\n",rank,SDL_GetError());
exit(3);
}
zoomX = (float)(2048.0 / image->w);
zoomY = (float)(1536.0 / image->h);
zoomedimage = zoomSurface(image,zoomX,zoomY,SMOOTHING_ON);
dstRect.w = zoomedimage->w;
dstRect.h = zoomedimage->h;
switch(rank){
case 1:
dstRect.x = 0;
dstRect.y = 0;
break;
case 2:
dstRect.x = -1024;
dstRect.y = 0;
break;
case 3:
dstRect.x = -1024;
dstRect.y = -768;
break;
case 4:
dstRect.x = 0;
dstRect.y = -768;
break;
}
if(rank == 0)
SDL_BlitSurface(image,NULL,screen,NULL);
else
SDL_BlitSurface(zoomedimage,NULL,screen,&dstRect);
SDL_UpdateRect(screen,0,0,0,0);
HandleEvent();
if(rank == 0)
SDL_FreeSurface(image);
else
SDL_FreeSurface(zoomedimage);
}
int main(int argc, char *argv[]) {
int rank, size, nameLength, stat;
char proc_name[MPI_MAX_PROCESSOR_NAME],buf[255];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_processor_name(proc_name,&nameLength);
//printf("processor name : %s\n",proc_name);
if(rank!=0){
sprintf(buf,"%s:0.0",proc_name);
stat = setenv("DISPLAY",buf,1);
// printf("status of env in %s : %d\n",proc_name,stat);
printf("$DISPLAY in %s : %s\n",proc_name,getenv("DISPLAY"));
}
display(argv[1],rank);
MPI_Finalize();
return 0;
}
*****************************************
The error message is :
*****************************************
$DISPLAY in client2.cluster5 : client2.cluster5:0.0
Error in init in node 2 : No available video device
$DISPLAY in client4.cluster5 : client4.cluster5:0.0
Error in init in node 4 : No available video device
------------------------------------------------------------------------
One of the processes started by mpirun has exited with a nonzero exit
code. This typically indicates that the process finished in error.
If your process did not finish in error, be sure to include a "return
0" or "exit(0)" in your C code before exiting the application.
PID 2624 failed on node n2 (192.168.0.12) with exit status 100.
------------------------------------------------------------------------
$DISPLAY in client1.cluster5 : client1.cluster5:0.0
$DISPLAY in client3.cluster5 : client3.cluster5:0.0
*********************************************************
Please Help
Regards,
Amroz.
|