LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-16-2008, 04:50 AM   #1
amroz
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl - SDL::OpenGL is not displaying graphics mmmmtmmmm Programming 2 09-04-2007 10:27 PM
no parallel device in lpinfo -v rocordial Linux - Hardware 2 04-02-2005 04:10 AM
Any software that can work with a parallel port video capture device? Artanis262 Linux - Software 1 03-13-2005 10:11 AM
HELP! Couldn't initialize SDL: No available video device orktes Linux - Software 6 03-24-2004 02:04 PM
SDL: Could not initialize video zot Linux - Hardware 0 06-24-2003 09:05 AM


All times are GMT -5. The time now is 02:42 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration