home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / lib / mathlib / libblas / ludec / fast.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.4 KB  |  186 lines

  1. /* *****************************************************************************
  2. *
  3. * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. *
  6. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  7. * the contents of this file may not be disclosed to third parties, copied or
  8. * duplicated in any form, in whole or in part, without the prior written
  9. * permission of Silicon Graphics, Inc.
  10. *
  11. * RESTRICTED RIGHTS LEGEND:
  12. * Use, duplication or disclosure by the Government is subject to restrictions
  13. * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  14. * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  15. * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  16. * rights reserved under the Copyright Laws of the United States.
  17. *
  18. ***************************************************************************** */
  19. #include <gl.h>
  20. #include <device.h>
  21. #include <math.h>
  22. #include "fast.h"
  23. #include "event.h"
  24.  
  25. extern int mainmenu, quitmenu;
  26.  
  27. void display();
  28.  
  29. int do_exit;
  30. int ask_quit;
  31.  
  32. int max_size, this_size;
  33. int this_proc;
  34.  
  35. double *mat;
  36. int *ipvt, lda, info;
  37.  
  38. double this_time, this_flop;
  39.  
  40. void InitFast();
  41. double second();
  42.  
  43. fast (progname)
  44. char *progname;
  45. {
  46.     InitFast();
  47.     Init(progname);
  48.  
  49.     do_exit = FALSE;
  50.  
  51.     display();
  52.     
  53.     while(! do_exit) {
  54.         event();
  55.     }
  56. }
  57.  
  58. ShowFast()
  59. {
  60.     char str[32];
  61.  
  62.    viewport(0,600,0,600);
  63.  
  64.     color (oBLACK);
  65.     clear ();
  66.  
  67.      color (oGREEN);
  68.     ortho2(0,600,0, 600);
  69.     cmov2i( 250, 570);
  70.     sprintf( str, "SIZE = %d", max_size);
  71.     charstr(str);
  72.  
  73.     if( this_size != 0  && this_size != max_size){ 
  74.     color (oCYAN);
  75.     cmov2i( 150, 20);
  76.     sprintf( str, "Running on %d Procs -  %d / %d", this_proc, this_size,
  77.         max_size);
  78.     charstr(str);
  79.     }
  80.     if( this_size == max_size){ 
  81.     color (oCYAN);
  82.     cmov2i( 65, 20);
  83.     sprintf( str, "LU Factorization --- %.2f Seconds --- %.2f Mflops", this_time,
  84.         this_flop);
  85. /*
  86.  
  87.     sprintf( str, "LU Factorization --- %.2f Seconds ", this_time);
  88. */
  89.     charstr(str);
  90.     }
  91.     viewport( 50, 550, 50, 550);
  92.     ortho2(0, max_size+1,0, max_size+1);
  93.     DrawFast();
  94. }
  95.  
  96. void do_quit()
  97. {
  98.     if(mat)
  99.         free(mat);
  100.     gexit();
  101.     exit(0);
  102. }
  103.  
  104.  
  105. void do_rightmouse()
  106. {
  107.     ask_quit = 0;
  108.  
  109.     dopup(mainmenu);
  110.  
  111.     if(ask_quit)
  112.     dopup(quitmenu);
  113.  
  114. }
  115.  
  116. void display()
  117. {
  118.     ShowFast();
  119.     swapbuffers();
  120. }
  121.  
  122. void do_resize(){
  123.     
  124.     lda = max_size + 1;
  125.     
  126.     if( mat){ 
  127.     mat  = (double *)realloc( mat, max_size * lda * sizeof(double));
  128.     ipvt = (int *)realloc( ipvt, max_size * sizeof(int));
  129.     }
  130.     else{ 
  131.     mat  = (double *)malloc( max_size * lda * sizeof(double));
  132.     ipvt = (int *)malloc( max_size * sizeof(int));
  133.     }
  134.  
  135.     matgen_( mat, &lda, &max_size);
  136.  
  137.     this_size = 0;
  138.     display();
  139. }
  140. void size300(){
  141.  
  142.     max_size = 300;
  143.     do_resize();
  144. }
  145.  
  146. void size500(){
  147.  
  148.     max_size = 500;
  149.     do_resize();
  150. }
  151.  
  152. void this_run(){
  153.  
  154.     this_time = second();
  155.     dgefa_( mat, &lda, &max_size, ipvt, &info);
  156.     this_time = second() - this_time;
  157.     this_flop = (1e-6 * 2./3.) * (max_size*max_size*max_size) / this_time;
  158.     display();
  159. }
  160.  
  161. void that_run(){
  162.  
  163.     this_time = second();
  164.     dgetrf_( &max_size, &max_size, mat, &lda, ipvt, &info);
  165.     this_time = second() - this_time;
  166.     this_flop = (1e-6 * 2./3.) * (max_size*max_size*max_size) / this_time;
  167.     display();
  168. }
  169.  
  170. void update_(int *k){
  171.     this_size = *k;
  172.  
  173.     display();
  174. }
  175.  
  176. void this_quit(){
  177.  
  178.     ask_quit = 1;
  179. }
  180. void InitFast(){
  181.  
  182.          this_proc = 1;
  183. #pragma  this_proc = mp_numthreads_();
  184.          max_size = 300;
  185. }
  186.