Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] Fix for multiple initialization of ALF


  • To: VSIPL++ Developers List <vsipl++@xxxxxxxxxxxxxxxx>
  • Subject: [patch] Fix for multiple initialization of ALF
  • From: Don McCoy <don@xxxxxxxxxxxxxxxx>
  • Date: Tue, 13 May 2008 11:26:05 -0600

This patch fixes a problem when using the Cell/B.E. Math Library (CML),
in that ALF was being initialized twice.  The default behavior is
preserved.  The conditional VSIP_IMPL_HAVE_CML must be defined in order
to use CML's initialization and finalization methods.

Committed after approval off-list.

Regards,

-- 
Don McCoy
don (at) CodeSourcery
(888) 776-0262 / (650) 331-3385, x712

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 207599)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2008-05-13  Don McCoy  <don@xxxxxxxxxxxxxxxx>
+
+	* src/vsip/opt/cbe/ppu/alf.hpp: Initialize ALF through CML if
+	  available (according to VSIP_IMPL_HAVE_CML).
+
 2008-05-05  Stefan Seefeld  <stefan@xxxxxxxxxxxxxxxx>
 
 	* m4/cbe.m4: Fix handling of with_cbe_sdk_sysroot.
Index: src/vsip/opt/cbe/ppu/alf.hpp
===================================================================
--- src/vsip/opt/cbe/ppu/alf.hpp	(revision 207599)
+++ src/vsip/opt/cbe/ppu/alf.hpp	(working copy)
@@ -17,6 +17,10 @@
 # error "vsip/opt files cannot be used as part of the reference impl."
 #endif
 
+#ifdef VSIP_IMPL_HAVE_CML
+#include <cml/ppu/cml.h>
+#endif
+
 #include <vsip/core/config.hpp>
 #include <vsip/core/metaprogramming.hpp>
 #include <vsip/support.hpp>
@@ -137,6 +141,9 @@
   ALF(unsigned int num_accelerators)
     : num_accelerators_(num_accelerators)
   {
+#ifdef VSIP_IMPL_HAVE_CML
+    cml_init();
+#else
     int status = alf_init(0, &alf_);
     assert(status >= 0);
     if (num_accelerators) 
@@ -144,8 +151,16 @@
       set_num_accelerators(num_accelerators);
       assert(status >= 0);
     }
+#endif
   }
-  ~ALF() { alf_exit(&alf_, ALF_EXIT_POLICY_WAIT, -1);}
+  ~ALF() 
+  { 
+#ifdef VSIP_IMPL_HAVE_CML
+    cml_fini();
+#else
+    alf_exit(&alf_, ALF_EXIT_POLICY_WAIT, -1);
+#endif
+  }
   void set_num_accelerators(unsigned int n) { alf_num_instances_set(alf_, n);}
   unsigned int num_accelerators() const { return num_accelerators_;}