home *** CD-ROM | disk | FTP | other *** search
- /* *****************************************************************************
- *
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- *
- ***************************************************************************** */
- #include <gl.h>
- #include <device.h>
- #include <math.h>
- #include "fast.h"
- #include "event.h"
-
- extern int mainmenu, quitmenu;
-
- void display();
-
- int do_exit;
- int ask_quit;
-
- int max_size, this_size;
- int this_proc;
-
- double *mat;
- int *ipvt, lda, info;
-
- double this_time, this_flop;
-
- void InitFast();
- double second();
-
- fast (progname)
- char *progname;
- {
- InitFast();
- Init(progname);
-
- do_exit = FALSE;
-
- display();
-
- while(! do_exit) {
- event();
- }
- }
-
- ShowFast()
- {
- char str[32];
-
- viewport(0,600,0,600);
-
- color (oBLACK);
- clear ();
-
- color (oGREEN);
- ortho2(0,600,0, 600);
- cmov2i( 250, 570);
- sprintf( str, "SIZE = %d", max_size);
- charstr(str);
-
- if( this_size != 0 && this_size != max_size){
- color (oCYAN);
- cmov2i( 150, 20);
- sprintf( str, "Running on %d Procs - %d / %d", this_proc, this_size,
- max_size);
- charstr(str);
- }
- if( this_size == max_size){
- color (oCYAN);
- cmov2i( 65, 20);
- sprintf( str, "LU Factorization --- %.2f Seconds --- %.2f Mflops", this_time,
- this_flop);
- /*
-
- sprintf( str, "LU Factorization --- %.2f Seconds ", this_time);
- */
- charstr(str);
- }
- viewport( 50, 550, 50, 550);
- ortho2(0, max_size+1,0, max_size+1);
- DrawFast();
- }
-
- void do_quit()
- {
- if(mat)
- free(mat);
- gexit();
- exit(0);
- }
-
-
- void do_rightmouse()
- {
- ask_quit = 0;
-
- dopup(mainmenu);
-
- if(ask_quit)
- dopup(quitmenu);
-
- }
-
- void display()
- {
- ShowFast();
- swapbuffers();
- }
-
- void do_resize(){
-
- lda = max_size + 1;
-
- if( mat){
- mat = (double *)realloc( mat, max_size * lda * sizeof(double));
- ipvt = (int *)realloc( ipvt, max_size * sizeof(int));
- }
- else{
- mat = (double *)malloc( max_size * lda * sizeof(double));
- ipvt = (int *)malloc( max_size * sizeof(int));
- }
-
- matgen_( mat, &lda, &max_size);
-
- this_size = 0;
- display();
- }
- void size300(){
-
- max_size = 300;
- do_resize();
- }
-
- void size500(){
-
- max_size = 500;
- do_resize();
- }
-
- void this_run(){
-
- this_time = second();
- dgefa_( mat, &lda, &max_size, ipvt, &info);
- this_time = second() - this_time;
- this_flop = (1e-6 * 2./3.) * (max_size*max_size*max_size) / this_time;
- display();
- }
-
- void that_run(){
-
- this_time = second();
- dgetrf_( &max_size, &max_size, mat, &lda, ipvt, &info);
- this_time = second() - this_time;
- this_flop = (1e-6 * 2./3.) * (max_size*max_size*max_size) / this_time;
- display();
- }
-
- void update_(int *k){
- this_size = *k;
-
- display();
- }
-
- void this_quit(){
-
- ask_quit = 1;
- }
- void InitFast(){
-
- this_proc = 1;
- #pragma this_proc = mp_numthreads_();
- max_size = 300;
- }
-