Merged eb/gcell-wip2 rev 10130:10152 into trunk.
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 22 Dec 2008 04:24:34 +0000 (04:24 +0000)
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 22 Dec 2008 04:24:34 +0000 (04:24 +0000)
This makes several gcell related changes.

{{{
The first two are INCOMPATIBLE CHANGES:

(1) The gcell portion of the code base was reorganized.  As part of that
reorganization, the paths to the include files changed.  They are now
installed under PREFIX/include/gcell instead of directly in PREFIX/include.

This means that all includes of the form:

  #include <gc_foo.h>

should be changed to

  #include <gcell/gc_foo.h>

(2a) If you are directly using gcell-embedspu-libtool or the
$(GCELL_EMBEDSPU_LIBTOOL) variable in your Makefiles, the order of the
two command line arguments was switched.  It's now

  $(GCELL_EMBEDSPU_LIBTOOL) input_file output_file

or equivalently

  $(GCELL_EMBEDSPU_LIBTOOL) $< $@

gcell-embedspu-libtool allows you to convert an SPE executable
into something that libtool will allow you add to a host shared library.

(2b) The name of the symbol created by gcell-embedspu-libtool is now
suffixed with _spx (SPE executable) to reduce the probability of name
collision.  If you have lines like this:

  extern spe_program_handle_t gcell_all;

in your code, you may have to change them to:

  extern spe_program_handle_t gcell_all_spx;

The following changes are enhancements and shouldn't break any
existing code:

(3) We now install two new pkg-config files, gcell.pc and gcell_spu.pc.
These can be used to assist in building gcell code that lives outside
the GNU Radio repository.  The first gives the include and library
paths for the PPE host code, the second is the same info for the the
SPE code.

There is also a new .m4 macro, GR_GCELL, contained in
config/gr_gcell.m4, that uses PKG_CONFIG_MODULES to fish out the
relevant variables.  If you've got standalone code that uses gcell,
you'll probably want to copy this macro (along with our version of
pkg.m4) to your tree and use it.  It sets the following variables:

  GCELL_CFLAGS
  GCELL_CPPFLAGS
  GCELL_INCLUDEDIR
  GCELL_LIBS
  GCELL_SPU_CFLAGS
  GCELL_SPU_CPPFLAGS
  GCELL_SPU_INCLUDEDIR
  GCELL_SPU_LIBS
  GCELL_EMBEDSPU_LIBTOOL

(4) make -j now works in the gcell directory (fixes ticket:242).
}}}

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10153 221aa14e-8319-0410-a670-987f0aec2ac5

326 files changed:
Makefile.common
config/Makefile.am
config/gr_gcell.m4 [new file with mode: 0644]
config/gr_standalone.m4
config/grc_gcell.m4
config/grc_gr_gcell.m4
config/lf_warnings.m4
config/pkg.m4
gcell/Makefile.am
gcell/apps/Makefile.am [new file with mode: 0644]
gcell/apps/benchmark_dma.cc [new file with mode: 0644]
gcell/apps/benchmark_nop.cc [new file with mode: 0644]
gcell/apps/gen_script.py [new file with mode: 0755]
gcell/apps/plot_speedup.py [new file with mode: 0755]
gcell/apps/results-071223 [new file with mode: 0644]
gcell/apps/split_and_avg_results.py [new file with mode: 0755]
gcell/apps/spu/Makefile.am [new file with mode: 0644]
gcell/apps/spu/benchmark_procs.c [new file with mode: 0644]
gcell/apps/test_all.cc [new file with mode: 0644]
gcell/gcell.pc.in
gcell/gcell_spu.pc.in [new file with mode: 0644]
gcell/ibm/Makefile.am [new file with mode: 0644]
gcell/ibm/README [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_add.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_add_return.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_dec.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_dec_and_test.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_dec_if_positive.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_dec_return.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_inc.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_inc_return.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_read.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_set.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_sub.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_sub_and_test.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/atomic_sub_return.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/complete.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/complete_all.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/completion.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/cond.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/cond_broadcast.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/cond_init.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/cond_signal.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/cond_wait.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/init_completion.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/libsync.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/mutex.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/mutex_init.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/mutex_lock.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/mutex_trylock.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/mutex_unlock.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/pdt_libsync.xml [new file with mode: 0644]
gcell/ibm/sync/ppu_source/pdt_libsync_config.xml [new file with mode: 0644]
gcell/ibm/sync/ppu_source/sync_utils.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/trace_libsync.h [new file with mode: 0644]
gcell/ibm/sync/ppu_source/wait_for_completion.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_add.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_add_return.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_dec.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_dec_and_test.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_dec_if_positive.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_dec_return.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_inc.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_inc_return.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_read.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_set.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_sub.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_sub_and_test.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/atomic_sub_return.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/complete.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/complete_all.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/completion.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/cond.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/cond_broadcast.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/cond_init.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/cond_signal.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/cond_wait.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/init_completion.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/libsync.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/mutex.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/mutex_init.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/mutex_lock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/mutex_trylock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/mutex_unlock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/read_lock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/read_trylock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/read_unlock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/rwlock_init.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/sync_irq.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/sync_utils.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/trace_libsync.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/wait_for_completion.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/write_lock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/write_trylock.h [new file with mode: 0644]
gcell/ibm/sync/spu_source/write_unlock.h [new file with mode: 0644]
gcell/include/Makefile.am [new file with mode: 0644]
gcell/include/gcell/Makefile.am [new file with mode: 0644]
gcell/include/gcell/compiler.h [new file with mode: 0644]
gcell/include/gcell/gc_aligned_alloc.h [new file with mode: 0644]
gcell/include/gcell/gc_atomic.h [new file with mode: 0644]
gcell/include/gcell/gc_cdefs.h [new file with mode: 0644]
gcell/include/gcell/gc_declare_proc.h [new file with mode: 0644]
gcell/include/gcell/gc_jd_queue.h [new file with mode: 0644]
gcell/include/gcell/gc_jd_queue_data.h [new file with mode: 0644]
gcell/include/gcell/gc_jd_stack.h [new file with mode: 0644]
gcell/include/gcell/gc_job_desc.h [new file with mode: 0644]
gcell/include/gcell/gc_job_desc_private.h [new file with mode: 0644]
gcell/include/gcell/gc_job_manager.h [new file with mode: 0644]
gcell/include/gcell/gc_logging.h [new file with mode: 0644]
gcell/include/gcell/gc_mbox.h [new file with mode: 0644]
gcell/include/gcell/gc_spu_args.h [new file with mode: 0644]
gcell/include/gcell/gc_types.h [new file with mode: 0644]
gcell/include/gcell/gcp_fft_1d_r2.h [new file with mode: 0644]
gcell/include/gcell/memory_barrier.h [new file with mode: 0644]
gcell/include/gcell/spu/Makefile.am [new file with mode: 0644]
gcell/include/gcell/spu/fft_1d.h [new file with mode: 0644]
gcell/include/gcell/spu/fft_1d_r2.h [new file with mode: 0644]
gcell/include/gcell/spu/gc_delay.h [new file with mode: 0644]
gcell/include/gcell/spu/gc_jd_queue.h [new file with mode: 0644]
gcell/include/gcell/spu/gc_random.h [new file with mode: 0644]
gcell/include/gcell/spu/gc_spu_macs.h [new file with mode: 0644]
gcell/include/gcell/spu/libfft.h [new file with mode: 0644]
gcell/lib/Makefile.am [new file with mode: 0644]
gcell/lib/general/Makefile.am [new file with mode: 0644]
gcell/lib/general/spu/fft_1d_r2.c [new file with mode: 0644]
gcell/lib/general/spu/memset.S [new file with mode: 0644]
gcell/lib/general/spu/qa_memset.c [new file with mode: 0644]
gcell/lib/runtime/Makefile.am [new file with mode: 0644]
gcell/lib/runtime/gc_aligned_alloc.cc [new file with mode: 0644]
gcell/lib/runtime/gc_client_thread_info.h [new file with mode: 0644]
gcell/lib/runtime/gc_jd_queue.c [new file with mode: 0644]
gcell/lib/runtime/gc_jd_stack.c [new file with mode: 0644]
gcell/lib/runtime/gc_job_manager.cc [new file with mode: 0644]
gcell/lib/runtime/gc_job_manager_impl.cc [new file with mode: 0644]
gcell/lib/runtime/gc_job_manager_impl.h [new file with mode: 0644]
gcell/lib/runtime/gc_proc_def_utils.cc [new file with mode: 0644]
gcell/lib/runtime/gc_proc_def_utils.h [new file with mode: 0644]
gcell/lib/runtime/gcell-embedspu-libtool [new file with mode: 0755]
gcell/lib/runtime/qa_gcell_runtime.cc [new file with mode: 0644]
gcell/lib/runtime/qa_gcell_runtime.h [new file with mode: 0644]
gcell/lib/runtime/qa_jd_queue.cc [new file with mode: 0644]
gcell/lib/runtime/qa_jd_queue.h [new file with mode: 0644]
gcell/lib/runtime/qa_jd_stack.cc [new file with mode: 0644]
gcell/lib/runtime/qa_jd_stack.h [new file with mode: 0644]
gcell/lib/runtime/qa_job_manager.cc [new file with mode: 0644]
gcell/lib/runtime/qa_job_manager.h [new file with mode: 0644]
gcell/lib/runtime/spu/gc_delay.c [new file with mode: 0644]
gcell/lib/runtime/spu/gc_logging.c [new file with mode: 0644]
gcell/lib/runtime/spu/gc_main.c [new file with mode: 0644]
gcell/lib/runtime/spu/gc_random.c [new file with mode: 0644]
gcell/lib/runtime/spu/gc_spu_config.h [new file with mode: 0644]
gcell/lib/runtime/spu/gc_spu_jd_queue.c [new file with mode: 0644]
gcell/lib/runtime/spu/gcell_runtime_qa.c [new file with mode: 0644]
gcell/lib/runtime/spu/spu_buffers.c [new file with mode: 0644]
gcell/lib/runtime/spu/spu_buffers.h [new file with mode: 0644]
gcell/lib/spu/Makefile.am [new file with mode: 0644]
gcell/lib/wrapper/Makefile.am [new file with mode: 0644]
gcell/lib/wrapper/gcp_fft_1d_r2.cc [new file with mode: 0644]
gcell/lib/wrapper/qa_gcell_general.cc [new file with mode: 0644]
gcell/lib/wrapper/qa_gcell_general.h [new file with mode: 0644]
gcell/lib/wrapper/qa_gcell_wrapper.cc [new file with mode: 0644]
gcell/lib/wrapper/qa_gcell_wrapper.h [new file with mode: 0644]
gcell/lib/wrapper/qa_gcp_fft_1d_r2.cc [new file with mode: 0644]
gcell/lib/wrapper/qa_gcp_fft_1d_r2.h [new file with mode: 0644]
gcell/lib/wrapper/spu/gcs_fft_1d_r2.c [new file with mode: 0644]
gcell/src/Makefile.am [deleted file]
gcell/src/apps/Makefile.am [deleted file]
gcell/src/apps/benchmark_dma.cc [deleted file]
gcell/src/apps/benchmark_nop.cc [deleted file]
gcell/src/apps/gen_script.py [deleted file]
gcell/src/apps/plot_speedup.py [deleted file]
gcell/src/apps/results-071223 [deleted file]
gcell/src/apps/split_and_avg_results.py [deleted file]
gcell/src/apps/spu/Makefile.am [deleted file]
gcell/src/apps/spu/benchmark_procs.c [deleted file]
gcell/src/apps/test_all.cc [deleted file]
gcell/src/ibm/Makefile.am [deleted file]
gcell/src/ibm/README [deleted file]
gcell/src/ibm/sync/ppu_source/atomic.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_add.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_add_return.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_dec.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_dec_and_test.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_dec_if_positive.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_dec_return.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_inc.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_inc_return.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_read.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_set.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_sub.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_sub_and_test.h [deleted file]
gcell/src/ibm/sync/ppu_source/atomic_sub_return.h [deleted file]
gcell/src/ibm/sync/ppu_source/complete.h [deleted file]
gcell/src/ibm/sync/ppu_source/complete_all.h [deleted file]
gcell/src/ibm/sync/ppu_source/completion.h [deleted file]
gcell/src/ibm/sync/ppu_source/cond.h [deleted file]
gcell/src/ibm/sync/ppu_source/cond_broadcast.h [deleted file]
gcell/src/ibm/sync/ppu_source/cond_init.h [deleted file]
gcell/src/ibm/sync/ppu_source/cond_signal.h [deleted file]
gcell/src/ibm/sync/ppu_source/cond_wait.h [deleted file]
gcell/src/ibm/sync/ppu_source/init_completion.h [deleted file]
gcell/src/ibm/sync/ppu_source/libsync.h [deleted file]
gcell/src/ibm/sync/ppu_source/mutex.h [deleted file]
gcell/src/ibm/sync/ppu_source/mutex_init.h [deleted file]
gcell/src/ibm/sync/ppu_source/mutex_lock.h [deleted file]
gcell/src/ibm/sync/ppu_source/mutex_trylock.h [deleted file]
gcell/src/ibm/sync/ppu_source/mutex_unlock.h [deleted file]
gcell/src/ibm/sync/ppu_source/pdt_libsync.xml [deleted file]
gcell/src/ibm/sync/ppu_source/pdt_libsync_config.xml [deleted file]
gcell/src/ibm/sync/ppu_source/sync_utils.h [deleted file]
gcell/src/ibm/sync/ppu_source/trace_libsync.h [deleted file]
gcell/src/ibm/sync/ppu_source/wait_for_completion.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_add.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_add_return.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_dec.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_dec_and_test.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_dec_if_positive.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_dec_return.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_inc.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_inc_return.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_read.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_set.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_sub.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_sub_and_test.h [deleted file]
gcell/src/ibm/sync/spu_source/atomic_sub_return.h [deleted file]
gcell/src/ibm/sync/spu_source/complete.h [deleted file]
gcell/src/ibm/sync/spu_source/complete_all.h [deleted file]
gcell/src/ibm/sync/spu_source/completion.h [deleted file]
gcell/src/ibm/sync/spu_source/cond.h [deleted file]
gcell/src/ibm/sync/spu_source/cond_broadcast.h [deleted file]
gcell/src/ibm/sync/spu_source/cond_init.h [deleted file]
gcell/src/ibm/sync/spu_source/cond_signal.h [deleted file]
gcell/src/ibm/sync/spu_source/cond_wait.h [deleted file]
gcell/src/ibm/sync/spu_source/init_completion.h [deleted file]
gcell/src/ibm/sync/spu_source/libsync.h [deleted file]
gcell/src/ibm/sync/spu_source/mutex.h [deleted file]
gcell/src/ibm/sync/spu_source/mutex_init.h [deleted file]
gcell/src/ibm/sync/spu_source/mutex_lock.h [deleted file]
gcell/src/ibm/sync/spu_source/mutex_trylock.h [deleted file]
gcell/src/ibm/sync/spu_source/mutex_unlock.h [deleted file]
gcell/src/ibm/sync/spu_source/read_lock.h [deleted file]
gcell/src/ibm/sync/spu_source/read_trylock.h [deleted file]
gcell/src/ibm/sync/spu_source/read_unlock.h [deleted file]
gcell/src/ibm/sync/spu_source/rwlock_init.h [deleted file]
gcell/src/ibm/sync/spu_source/sync_irq.h [deleted file]
gcell/src/ibm/sync/spu_source/sync_utils.h [deleted file]
gcell/src/ibm/sync/spu_source/trace_libsync.h [deleted file]
gcell/src/ibm/sync/spu_source/wait_for_completion.h [deleted file]
gcell/src/ibm/sync/spu_source/write_lock.h [deleted file]
gcell/src/ibm/sync/spu_source/write_trylock.h [deleted file]
gcell/src/ibm/sync/spu_source/write_unlock.h [deleted file]
gcell/src/include/Makefile.am [deleted file]
gcell/src/include/compiler.h [deleted file]
gcell/src/include/gc_atomic.h [deleted file]
gcell/src/include/gc_cdefs.h [deleted file]
gcell/src/include/gc_declare_proc.h [deleted file]
gcell/src/include/gc_jd_queue.h [deleted file]
gcell/src/include/gc_jd_queue_data.h [deleted file]
gcell/src/include/gc_jd_stack.h [deleted file]
gcell/src/include/gc_job_desc.h [deleted file]
gcell/src/include/gc_job_desc_private.h [deleted file]
gcell/src/include/gc_logging.h [deleted file]
gcell/src/include/gc_mbox.h [deleted file]
gcell/src/include/gc_spu_args.h [deleted file]
gcell/src/include/gc_types.h [deleted file]
gcell/src/include/memory_barrier.h [deleted file]
gcell/src/include/spu/Makefile.am [deleted file]
gcell/src/include/spu/gc_delay.h [deleted file]
gcell/src/include/spu/gc_jd_queue.h [deleted file]
gcell/src/include/spu/gc_random.h [deleted file]
gcell/src/lib/Makefile.am [deleted file]
gcell/src/lib/general/Makefile.am [deleted file]
gcell/src/lib/general/spu/fft_1d.h [deleted file]
gcell/src/lib/general/spu/fft_1d_r2.c [deleted file]
gcell/src/lib/general/spu/fft_1d_r2.h [deleted file]
gcell/src/lib/general/spu/gc_spu_macs.h [deleted file]
gcell/src/lib/general/spu/libfft.h [deleted file]
gcell/src/lib/general/spu/memset.S [deleted file]
gcell/src/lib/general/spu/qa_memset.c [deleted file]
gcell/src/lib/runtime/Makefile.am [deleted file]
gcell/src/lib/runtime/gc_aligned_alloc.cc [deleted file]
gcell/src/lib/runtime/gc_aligned_alloc.h [deleted file]
gcell/src/lib/runtime/gc_client_thread_info.h [deleted file]
gcell/src/lib/runtime/gc_jd_queue.c [deleted file]
gcell/src/lib/runtime/gc_jd_stack.c [deleted file]
gcell/src/lib/runtime/gc_job_manager.cc [deleted file]
gcell/src/lib/runtime/gc_job_manager.h [deleted file]
gcell/src/lib/runtime/gc_job_manager_impl.cc [deleted file]
gcell/src/lib/runtime/gc_job_manager_impl.h [deleted file]
gcell/src/lib/runtime/gc_proc_def_utils.cc [deleted file]
gcell/src/lib/runtime/gc_proc_def_utils.h [deleted file]
gcell/src/lib/runtime/gcell-embedspu-libtool [deleted file]
gcell/src/lib/runtime/qa_gcell_runtime.cc [deleted file]
gcell/src/lib/runtime/qa_gcell_runtime.h [deleted file]
gcell/src/lib/runtime/qa_jd_queue.cc [deleted file]
gcell/src/lib/runtime/qa_jd_queue.h [deleted file]
gcell/src/lib/runtime/qa_jd_stack.cc [deleted file]
gcell/src/lib/runtime/qa_jd_stack.h [deleted file]
gcell/src/lib/runtime/qa_job_manager.cc [deleted file]
gcell/src/lib/runtime/qa_job_manager.h [deleted file]
gcell/src/lib/runtime/spu/gc_delay.c [deleted file]
gcell/src/lib/runtime/spu/gc_logging.c [deleted file]
gcell/src/lib/runtime/spu/gc_main.c [deleted file]
gcell/src/lib/runtime/spu/gc_random.c [deleted file]
gcell/src/lib/runtime/spu/gc_spu_config.h [deleted file]
gcell/src/lib/runtime/spu/gc_spu_jd_queue.c [deleted file]
gcell/src/lib/runtime/spu/gcell_runtime_qa.c [deleted file]
gcell/src/lib/runtime/spu/spu_buffers.c [deleted file]
gcell/src/lib/runtime/spu/spu_buffers.h [deleted file]
gcell/src/lib/spu/Makefile.am [deleted file]
gcell/src/lib/wrapper/Makefile.am [deleted file]
gcell/src/lib/wrapper/gcp_fft_1d_r2.cc [deleted file]
gcell/src/lib/wrapper/gcp_fft_1d_r2.h [deleted file]
gcell/src/lib/wrapper/qa_gcell_general.cc [deleted file]
gcell/src/lib/wrapper/qa_gcell_general.h [deleted file]
gcell/src/lib/wrapper/qa_gcell_wrapper.cc [deleted file]
gcell/src/lib/wrapper/qa_gcell_wrapper.h [deleted file]
gcell/src/lib/wrapper/qa_gcp_fft_1d_r2.cc [deleted file]
gcell/src/lib/wrapper/qa_gcp_fft_1d_r2.h [deleted file]
gcell/src/lib/wrapper/spu/gcs_fft_1d_r2.c [deleted file]
gr-gcell/src/gcell.i
gr-gcell/src/gcell_fft_vcc.cc
gr-gcell/src/qa_fft.py

index fabe8eb2aa4b151b36d33c75f5378a1496485cc9..f7c88b0d97e42b0ed09996abcf920caa777c13c9 100644 (file)
@@ -101,7 +101,7 @@ GCELL_SPU_INCLUDES = @gcell_spu_INCLUDES@
 GCELL_SPU_LA = @gcell_spu_LA@
 
 # libtool aware wrapper for ppu-embedspu
-GCELL_EMBEDSPU_LIBTOOL = @abs_top_srcdir@/gcell/src/lib/runtime/gcell-embedspu-libtool
+GCELL_EMBEDSPU_LIBTOOL = @abs_top_srcdir@/gcell/lib/runtime/gcell-embedspu-libtool
 
 # This used to be set in configure.ac but is now defined here for all 
 # Makefiles when this fragment is included.
index bdc79a5fac89cc8014b08c6168058492d5e97336..22de44b9f539ead8475f9aef96c94f2c8c943df2 100644 (file)
@@ -79,6 +79,7 @@ m4macros = \
        grc_gr_msdd6000.m4 \
        gr_doxygen.m4 \
        gr_fortran.m4 \
+       gr_gcell.m4 \
        gr_gprof.m4 \
        gr_lib64.m4 \
        gr_libgnuradio_core_extra_ldflags.m4 \
diff --git a/config/gr_gcell.m4 b/config/gr_gcell.m4
new file mode 100644 (file)
index 0000000..0b8b978
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+AC_DEFUN([GR_GCELL],[
+  passed=yes
+  PKG_CHECK_MODULES(GCELL, gcell >= 3.1, [],
+    [passed=no; AC_MSG_RESULT([gcell not found])])
+  PKG_CHECK_MODULES(GCELL_SPU, gcell_spu >= 3.1, [],
+    [passed=no; AC_MSG_RESULT([gcell_spu not found])])
+
+  GCELL_EMBEDSPU_LIBTOOL=
+  if test $passed = yes; then
+    GCELL_EMBEDSPU_LIBTOOL=`$PKG_CONFIG --variable=gcell_embedspu_libtool gcell 2>/dev/null`
+    AC_DEFINE(HAVE_GCELL,[1],[Define if you have gcell installed])
+  fi
+  AC_SUBST([GCELL_EMBEDSPU_LIBTOOL])
+
+  AM_CONDITIONAL([HAVE_GCELL], [test "$passed" = "yes"])
+])
index 0974454204f108dd23764c0fd8562283de11bdee..370f7fb034931241ab0c59517907606599442a91 100644 (file)
@@ -70,6 +70,17 @@ m4_define([GR_STANDALONE],
   GR_NO_UNDEFINED      dnl do we need the -no-undefined linker flag
   GR_SCRIPTING         dnl Locate python, SWIG, etc
 
+  AC_ARG_WITH([python],
+    AC_HELP_STRING([--with-python], [Should we use python? [[default=yes]]]),
+    [case "$with_python" in
+      (no | yes) ;;
+      (*) AC_MSG_ERROR([Invalid argument ($with_python) to --with-python]) ;;
+     esac],
+    [with_python=yes])
+
+  AM_CONDITIONAL([USE_PYTHON], [test "$with_python" = yes])
+
+
   dnl Set the c++ compiler that we use for the build system when cross compiling
   if test "x$CXX_FOR_BUILD" = x
   then
@@ -93,6 +104,13 @@ m4_define([GR_STANDALONE],
   AC_CHECK_PROG([XMLTO],[xmlto],[yes],[])
   AM_CONDITIONAL([HAS_XMLTO], [test x$XMLTO = xyes])
 
+  dnl Define where to look for cppunit includes and libs
+  dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS
+  dnl Try using pkg-config first, then fall back to cppunit-config.
+  PKG_CHECK_EXISTS(cppunit,
+    [PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.9.14)],
+    [AM_PATH_CPPUNIT([1.9.14],[],
+                    [AC_MSG_ERROR([GNU Radio requires cppunit.  Stop])])])
+
   PKG_CHECK_MODULES(GNURADIO_CORE, gnuradio-core >= 3)
-  LIBS="$LIBS $GNURADIO_CORE_LIBS"
 ])
index 38854b95b497f9ec4039feba33451dbd713ba7d2..ff289d1aeccfc14b400cd2527824053e58846ae5 100644 (file)
@@ -50,40 +50,30 @@ AC_DEFUN([GRC_GCELL],[
 
     if test $passed != with; then
        dnl how and where to find INCLUDES and LA
-       gcell_INCLUDES="-I\${abs_top_srcdir}/gcell/src/include \
-                -I\${abs_top_srcdir}/gcell/src/lib/runtime \
-                -I\${abs_top_srcdir}/gcell/src/lib/general \
-                -I\${abs_top_srcdir}/gcell/src/lib/wrapper"
-        gcell_LA="\${abs_top_builddir}/gcell/src/lib/libgcell.la"
-       gcell_spu_INCLUDES="-I\${abs_top_srcdir}/gcell/src/include/spu \
-                -I\${abs_top_srcdir}/gcell/src/include \
-                -I\${abs_top_srcdir}/gcell/src/lib/runtime/spu \
-                -I\${abs_top_srcdir}/gcell/src/lib/general/spu \
-                -I\${abs_top_srcdir}/gcell/src/lib/wrapper/spu"
-       gcell_spu_LA="\${abs_top_builddir}/gcell/src/lib/spu/libgcell_spu.a"
+       gcell_INCLUDES="-I\${abs_top_srcdir}/gcell/include"
+        gcell_LA="\${abs_top_builddir}/gcell/lib/libgcell.la"
+       gcell_spu_INCLUDES="-I\${abs_top_srcdir}/gcell/include"
+       gcell_spu_LA="\${abs_top_builddir}/gcell/lib/spu/libgcell_spu.a"
        AC_SUBST(gcell_spu_INCLUDES)
        AC_SUBST(gcell_spu_LA)
 
-        dnl kludge up initial swig dependency files
-        AC_CONFIG_COMMANDS([swig_gcell_deps], [
-            touch gr-gcell/src/gcell.d
-        ])
     fi
 
     AC_CONFIG_FILES([ \
         gcell/Makefile \
         gcell/gcell.pc \
-        gcell/src/Makefile \
-        gcell/src/include/Makefile \
-        gcell/src/include/spu/Makefile \
-        gcell/src/lib/Makefile \
-        gcell/src/lib/spu/Makefile \
-        gcell/src/lib/general/Makefile \
-        gcell/src/lib/wrapper/Makefile \
-        gcell/src/lib/runtime/Makefile \
-        gcell/src/apps/Makefile \
-       gcell/src/apps/spu/Makefile \
-       gcell/src/ibm/Makefile \
+        gcell/gcell_spu.pc \
+       gcell/include/Makefile \
+        gcell/include/gcell/Makefile \
+        gcell/include/gcell/spu/Makefile \
+        gcell/lib/Makefile \
+        gcell/lib/spu/Makefile \
+        gcell/lib/general/Makefile \
+        gcell/lib/wrapper/Makefile \
+        gcell/lib/runtime/Makefile \
+        gcell/apps/Makefile \
+       gcell/apps/spu/Makefile \
+       gcell/ibm/Makefile \
     ])
 
     GRC_BUILD_CONDITIONAL(gcell)
index d425337efe8f971abda88e3d41a9a0f750ed1f2b..191afdc087e00bee9fb078c0e937644f11bc0868 100644 (file)
@@ -31,6 +31,12 @@ AC_DEFUN([GRC_GR_GCELL],[
         gr-gcell/src/run_tests \
     ])
 
+    dnl kludge up initial swig dependency files
+    AC_CONFIG_COMMANDS([swig_gcell_deps], [
+        touch gr-gcell/src/gcell.d
+    ])
+
+
     GRC_BUILD_CONDITIONAL(gr-gcell,[
        dnl run_tests is created from run_tests.in.  Make it executable.
        AC_CONFIG_COMMANDS([run_tests_gcell], [chmod +x gr-gcell/src/run_tests])
index e18288013e0373c7ca8089de072cdde1d27f7d71..7bb8b60fc2ef03b29ff09a940c68afbda5927026 100644 (file)
@@ -115,7 +115,7 @@ AC_DEFUN([LF_SET_WARNINGS],[
      
   dnl Warnings for the two main compilers
   dnl add -Wextra when you're got time to fix a bunch of them ;-)
-  cc_warning_flags="-Wall $lf_warnings_as_errors"
+  cc_warning_flags="-Wall -Werror-implicit-function-declaration $lf_warnings_as_errors"
   cxx_warning_flags="-Wall -Woverloaded-virtual $lf_warnings_as_errors"
   if test -n "${CC}"
   then
index 80bdfed4c998db7309cd90ea5bb4a3e028a924a4..2d4d96109d5bd4068183a1a6d1c681cd7a4bd7cb 100644 (file)
@@ -111,8 +111,11 @@ fi[]dnl
 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
 #
 # --------------------------------------------------------------
-AC_DEFUN([PKG_CHECK_MODULES],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_DEFUN([PKG_CHECK_MODULES],[
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+
 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
 AC_ARG_VAR([$1][_INCLUDEDIR], [includedir for $1, overriding pkg-config])dnl
@@ -124,7 +127,17 @@ _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
 
 if test x$cross_compiling = xyes
 then
-  _PKG_CONFIG([$1][_LIBS], [libs-only-l --static], [$2])
+  dnl _PKG_CONFIG([$1][_LIBS], [libs-only-l --static], [$2])
+  _PKG_CONFIG([$1][_LIBS], [libs --static], [$2])
+  dnl prune out any -L/lib or -L/usr/lib since they're pointing to the wrong filesystem root
+  _pkg_tmp=
+  for flag in [$]pkg_cv_[$1][_LIBS]; do
+    case $flag in
+    (-L/lib* | -L/usr/lib* )      ;; # ignore
+    (*) _pkg_tmp="$_pkg_tmp $flag" ;;
+    esac
+  done
+  pkg_cv_[$1][_LIBS]="$_pkg_tmp"
 else
   _PKG_CONFIG([$1][_LIBS], [libs --static], [$2])
 fi
index 959d3563d31092c9fe763dfe2eeaf68328f48fa0..fe222e5fb30da5a3d84583c0a19da2c98e4d2aa0 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -20,7 +20,9 @@
 
 include $(top_srcdir)/Makefile.common
 
-SUBDIRS = src
+SUBDIRS = include lib apps ibm
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA =
+pkgconfig_DATA = \
+       gcell.pc \
+       gcell_spu.pc
diff --git a/gcell/apps/Makefile.am b/gcell/apps/Makefile.am
new file mode 100644 (file)
index 0000000..e676852
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# Copyright 2007,2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = spu .
+
+AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) \
+       $(GCELL_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
+
+
+GCELL_QA_LA = $(top_builddir)/gcell/lib/libgcell-qa.la
+
+TESTS = test_all
+
+
+bin_PROGRAMS = \
+       test_all \
+       benchmark_dma \
+       benchmark_nop
+
+
+test_all_SOURCES = test_all.cc
+test_all_LDADD = $(GCELL_QA_LA) $(GCELL_LA)
+
+benchmark_dma_SOURCES = benchmark_dma.cc
+benchmark_dma_LDADD = spu/benchmark_procs $(GCELL_LA)
+
+benchmark_nop_SOURCES = benchmark_nop.cc
+benchmark_nop_LDADD = spu/benchmark_procs $(GCELL_LA)
diff --git a/gcell/apps/benchmark_dma.cc b/gcell/apps/benchmark_dma.cc
new file mode 100644 (file)
index 0000000..bce1953
--- /dev/null
@@ -0,0 +1,273 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+#include <gcell/gc_job_manager.h>
+#include <omni_time.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <boost/scoped_array.hpp>
+#include <assert.h>
+
+// handle to embedded SPU executable that contains benchmark routines
+// (The name of the variable (benchmark_procs) is the name of the spu executable.)
+extern spe_program_handle_t benchmark_procs;
+
+static gc_proc_id_t gcp_benchmark_udelay = GCP_UNKNOWN_PROC;
+
+#define        BENCHMARK_PUT           0x1
+#define        BENCHMARK_GET           0x2
+#define        BENCHMARK_GET_PUT       (BENCHMARK_PUT|BENCHMARK_GET)
+
+
+#if 0
+static bool
+power_of_2_p(unsigned long x)
+{
+  int nbits = sizeof(x) * 8;
+  for (int i = 0; i < nbits; i++)
+    if (x == (1UL << i))
+      return true;
+
+  return false;
+}
+#endif
+
+static void
+init_jd(gc_job_desc *jd, unsigned int usecs,
+       unsigned char *getbuf, unsigned char *putbuf, size_t buflen,
+       int getput_mask)
+{
+  jd->proc_id = gcp_benchmark_udelay;
+  jd->input.nargs = 1;
+  jd->input.arg[0].u32 = usecs;
+  jd->output.nargs = 0;
+
+  switch(getput_mask & BENCHMARK_GET_PUT){
+
+  case BENCHMARK_GET:
+    jd->eaa.nargs = 1;
+    jd->eaa.arg[0].direction = GCJD_DMA_GET;
+    jd->eaa.arg[0].ea_addr = ptr_to_ea(getbuf);
+    jd->eaa.arg[0].get_size = buflen;
+    break;
+
+  case BENCHMARK_PUT:
+    jd->eaa.nargs = 1;
+    jd->eaa.arg[0].direction = GCJD_DMA_PUT;
+    jd->eaa.arg[0].ea_addr = ptr_to_ea(putbuf);
+    jd->eaa.arg[0].put_size = buflen;
+    break;
+    
+  case BENCHMARK_GET_PUT:
+    jd->eaa.nargs = 2;
+    jd->eaa.arg[0].direction = GCJD_DMA_GET;
+    jd->eaa.arg[0].ea_addr = ptr_to_ea(getbuf);
+    jd->eaa.arg[0].get_size = buflen;
+    jd->eaa.arg[1].direction = GCJD_DMA_PUT;
+    jd->eaa.arg[1].ea_addr = ptr_to_ea(putbuf);
+    jd->eaa.arg[1].put_size = buflen;
+    break;
+  }
+}
+
+static void
+run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size, int getput_mask)
+{
+  static const int64_t TOTAL_SIZE_DMA = 5LL << 30;
+  static const int NJDS = 64;
+  unsigned int njobs = (unsigned int)(TOTAL_SIZE_DMA / dma_size);
+  //unsigned int njobs = NJDS * 16;
+  unsigned int nsubmitted = 0;
+  unsigned int ncompleted = 0;
+  gc_job_desc *all_jds[NJDS];
+  gc_job_desc *jds[2][NJDS];
+  unsigned int njds[2];
+  unsigned int ci;             // current index
+  bool done[NJDS];
+  
+  static const unsigned int BUFSIZE = (32 << 10) * NJDS;
+  unsigned char *getbuf = new unsigned char[BUFSIZE];
+  boost::scoped_array<unsigned char> _getbuf(getbuf);
+  unsigned char *putbuf = new unsigned char[BUFSIZE];
+  boost::scoped_array<unsigned char> _putbuf(putbuf);
+  int gbi = 0;
+
+  // touch all pages to force allocation now
+  for (unsigned int i = 0; i < BUFSIZE; i += 4096){
+    getbuf[i] = 0;
+    putbuf[i] = 0;
+  }
+
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&benchmark_procs);
+  opts.nspes = nspes;
+  //opts.enable_logging = true;
+  //opts.log2_nlog_entries = 13;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+  if ((gcp_benchmark_udelay = mgr->lookup_proc("benchmark_udelay")) == GCP_UNKNOWN_PROC){
+    fprintf(stderr, "lookup_proc: failed to find \"benchmark_udelay\"\n");
+    return;
+  }
+
+  // allocate and init all job descriptors
+  for (int i = 0; i < NJDS; i++){
+    if (gbi + dma_size > BUFSIZE)
+      gbi = 0;
+
+    all_jds[i] = mgr->alloc_job_desc();
+    if (all_jds[i] == 0){
+      fprintf(stderr, "alloc_job_desc() returned 0\n");
+      return;
+    }
+    init_jd(all_jds[i], usecs, &getbuf[gbi], &putbuf[gbi], dma_size, getput_mask);
+    gbi += dma_size;
+  }
+
+  for (int iter = 0; iter < 1; iter++){
+
+    omni_time t_start = omni_time::time();
+
+    nsubmitted = 0;
+    ncompleted = 0;
+
+    ci = 0;
+    njds[0] = 0;
+    njds[1] = 0;
+  
+    // submit the first batch
+    for (int i = 0; i < NJDS; i++){
+      if (mgr->submit_job(all_jds[i])){
+       jds[ci][njds[ci]++] = all_jds[i];
+       nsubmitted++;
+      }
+      else {
+       printf("submit_job(jds[%d]) failed, status = %d\n",
+              i, all_jds[i]->status);
+      }
+    }
+  
+    while (ncompleted < njobs){
+      njds[ci^1] = 0;
+      int n = mgr->wait_jobs(njds[ci], jds[ci], done, GC_WAIT_ANY);
+      // printf("%2d\n", n);
+      if (n < 0){
+       fprintf(stderr, "mgr->wait_jobs failed\n");
+       break;
+      }
+      for (unsigned int i = 0; i < njds[ci]; i++){
+       if (!done[i]){  // remember for next iteration
+         jds[ci^1][njds[ci^1]++] = jds[ci][i];
+       }
+       else {
+         ncompleted++;
+         if (jds[ci][i]->status != JS_OK){
+           printf("js_status = %d, job_id = %d, ncompleted = %d\n",
+                  jds[ci][i]->status, jds[ci][i]->sys.job_id, ncompleted);
+         }
+         if (nsubmitted < njobs){                  // submit another one
+           if (mgr->submit_job(jds[ci][i])){
+             jds[ci^1][njds[ci^1]++] = jds[ci][i];  // remember for next iter
+             nsubmitted++;
+           }
+           else {
+             printf("submit_job(jds[%d]) failed, status = %d\n",
+                    i, jds[ci][i]->status);
+           }
+         }
+       }
+      }
+      ci ^= 1; // toggle current
+    }
+
+    // stop timing
+    omni_time t_stop = omni_time::time();
+
+    double delta = (t_stop - t_start).double_time();
+    printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  dma_size: %5d  dma_throughput: %7.3e\n",
+          mgr->nspes(), usecs, delta, dma_size,
+          (double) njobs * dma_size / delta * (getput_mask == BENCHMARK_GET_PUT ? 2.0 : 1.0));
+
+  }
+}
+
+static void
+usage()
+{
+  fprintf(stderr, "usage: benchmark_dma [-p] [-g] [-n <nspes>] [-u <udelay>] [-s <dma_size>]\n");
+  fprintf(stderr, "  you must specify one or both of -p (put) and -g (get)\n");
+}
+
+
+int
+main(int argc, char **argv)
+{
+  unsigned int nspes = 0;
+  unsigned int usecs = 0;
+  unsigned int dma_size = 32 << 10;
+  int getput_mask = 0;
+  int ch;
+
+  while ((ch = getopt(argc, argv, "n:u:s:pg")) != EOF){
+    switch(ch){
+    case 'n':
+      nspes = strtol(optarg, 0, 0);
+      break;
+
+    case 'u':
+      usecs = strtol(optarg, 0, 0);
+      break;
+
+    case 's':
+      dma_size = strtol(optarg, 0, 0);
+      if (dma_size == 0){
+       fprintf(stderr, "-s <dma_size> must be > 0\n");
+       return 1;
+      }
+      break;
+
+    case 'p':
+      getput_mask |= BENCHMARK_PUT;
+      break;
+
+    case 'g':
+      getput_mask |= BENCHMARK_GET;
+      break;
+      
+    case '?':
+    default:
+      usage();
+      return 1;
+    }
+  }
+
+  if (getput_mask == 0){
+    usage();
+    return 1;
+  }
+
+  run_test(nspes, usecs, dma_size, getput_mask);
+  return 0;
+}
diff --git a/gcell/apps/benchmark_nop.cc b/gcell/apps/benchmark_nop.cc
new file mode 100644 (file)
index 0000000..10f9d4c
--- /dev/null
@@ -0,0 +1,163 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+#include <gcell/gc_job_manager.h>
+#include <omni_time.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+// handle to embedded SPU executable that contains benchmark routines
+// (The name of the variable (benchmark_procs) is the name of the spu executable.)
+extern spe_program_handle_t benchmark_procs;
+
+static gc_proc_id_t gcp_benchmark_udelay = GCP_UNKNOWN_PROC;
+
+static void
+init_jd(gc_job_desc *jd, unsigned int usecs)
+{
+  jd->proc_id = gcp_benchmark_udelay;
+  jd->input.nargs = 1;
+  jd->input.arg[0].u32 = usecs;
+  jd->output.nargs = 0;
+  jd->eaa.nargs = 0;
+}
+
+static void
+run_test(unsigned int nspes, unsigned int usecs, int njobs)
+{
+  static const int NJDS = 64;
+  int nsubmitted = 0;
+  int ncompleted = 0;
+  gc_job_desc *all_jds[NJDS];
+  gc_job_desc *jds[2][NJDS];
+  unsigned int njds[2];
+  unsigned int ci;             // current index
+  bool done[NJDS];
+  
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&benchmark_procs);
+  opts.nspes = nspes;
+  opts.gang_schedule = true;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+  if ((gcp_benchmark_udelay = mgr->lookup_proc("benchmark_udelay")) == GCP_UNKNOWN_PROC){
+    fprintf(stderr, "lookup_proc: failed to find \"benchmark_udelay\"\n");
+    return;
+  }
+
+  // allocate and init all job descriptors
+  for (int i = 0; i < NJDS; i++){
+    all_jds[i] = mgr->alloc_job_desc();
+    init_jd(all_jds[i], usecs);
+  }
+
+  omni_time t_start = omni_time::time();
+
+  ci = 0;
+  njds[0] = 0;
+  njds[1] = 0;
+  
+  // submit the first batch
+  for (int i = 0; i < NJDS; i++){
+    if (mgr->submit_job(all_jds[i])){
+      jds[ci][njds[ci]++] = all_jds[i];
+      nsubmitted++;
+    }
+    else {
+      printf("submit_job(jds[%d]) failed, status = %d\n",
+            i, all_jds[i]->status);
+    }
+  }
+  
+  while (ncompleted < njobs){
+    njds[ci^1] = 0;
+    int n = mgr->wait_jobs(njds[ci], jds[ci], done, GC_WAIT_ANY);
+    // printf("%2d\n", n);
+    if (n < 0){
+      fprintf(stderr, "mgr->wait_jobs failed\n");
+      break;
+    }
+    for (unsigned int i = 0; i < njds[ci]; i++){
+      if (!done[i]){   // remember for next iteration
+       jds[ci^1][njds[ci^1]++] = jds[ci][i];
+      }
+      else {
+       ncompleted++;
+       // printf("ncompleted = %7d\n", ncompleted);
+       if (nsubmitted < njobs){                    // submit another one
+         if (mgr->submit_job(jds[ci][i])){
+           jds[ci^1][njds[ci^1]++] = jds[ci][i];  // remember for next iter
+           nsubmitted++;
+         }
+         else {
+           printf("submit_job(jds[%d]) failed, status = %d\n",
+                  i, jds[ci][i]->status);
+         }
+       }
+      }
+    }
+    ci ^= 1;   // toggle current
+  }
+
+  // stop timing
+  omni_time t_stop = omni_time::time();
+  double delta = (t_stop - t_start).double_time();
+  printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  njobs: %g  speedup: %6.3f\n",
+        mgr->nspes(), usecs, delta, (double) njobs,
+        njobs * usecs * 1e-6 / delta);
+}
+
+int
+main(int argc, char **argv)
+{
+  unsigned int nspes = 0;
+  unsigned int usecs = 0;
+  int njobs = 500000;
+  int ch;
+
+  while ((ch = getopt(argc, argv, "n:u:N:")) != EOF){
+    switch(ch){
+    case 'n':
+      nspes = strtol(optarg, 0, 0);
+      break;
+
+    case 'u':
+      usecs = strtol(optarg, 0, 0);
+      break;
+
+    case 'N':
+      njobs = strtol(optarg, 0, 0);
+      break;
+
+    case '?':
+    default:
+      fprintf(stderr, "usage: benchmark_nop [-n <nspes>] [-u <udelay>] [-N <njobs>]\n");
+      return 1;
+    }
+  }
+
+  run_test(nspes, usecs, njobs);
+  return 0;
+}
diff --git a/gcell/apps/gen_script.py b/gcell/apps/gen_script.py
new file mode 100755 (executable)
index 0000000..e4bbc74
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/env python
+
+import sys
+import time
+import os
+
+from optparse import OptionParser
+
+
+def get_svn_rev():
+    try:
+        f = os.popen("svn info", "r")
+        lines = f.readlines()
+        f.close()
+    except:
+        return "unk"
+
+    svn_rev = "unk"
+    for l in lines:
+        if l.startswith('Revision:'):
+            t = l.rstrip()
+            svn_rev = t.split()[-1]
+    return svn_rev
+    
+def is_ps3():
+    try:
+        f = open("/proc/cpuinfo")
+        s = f.read()
+    except:
+        return False
+
+    return s.find('PS3') != -1
+
+
+def main():
+
+    def make_fname(suffix):
+        return basename + '.' + suffix
+
+    max_spes_default = 16
+    if is_ps3():
+        max_spes_default = 6
+        
+    parser = OptionParser()
+    parser.add_option("-m", "--max-spes", type="int", default=max_spes_default,
+                      metavar="NSPES",
+                      help="maximum number of SPEs to use [default=%default]")
+    parser.add_option("", "--min-spes", type="int", default=1,
+                      metavar="NSPES",
+                      help="minimum number of SPEs to use [default=%default]")
+    parser.add_option("-p", "--oprofile", action="store_true", default=False,
+                      help="emit oprofile commands")
+    parser.add_option("-t", "--tag", default=None,
+                      help="additional goodie in generated filenames")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        sys.exit(1)
+
+    svn_rev = get_svn_rev()
+
+    os.environ['TZ'] = 'PST8PDT'        # always pacific
+    time.tzset()
+
+    tag = ''
+    if options.tag:
+        tag = '-' + options.tag
+        
+    basename = 'R-%s%s-%s' % (svn_rev, tag, time.strftime('%Y%m%d-%H%M'))
+
+    base_njobs = int(500e3)
+    njobs = {
+         1 : base_njobs,
+        10 : base_njobs,
+        50 : base_njobs,
+       100 : base_njobs, 
+       200 : int(base_njobs/2),
+       250 : int(base_njobs/2.5),
+       300 : int(base_njobs/3),
+       400 : int(base_njobs/4),
+       500 : int(base_njobs/5)
+        }
+
+    
+    f_results = make_fname('results')
+    f_opreport = make_fname('opreport')
+    f_avg = make_fname('avg')
+    f_png = make_fname('png')
+
+    f = sys.stdout
+    f.write("#!/bin/bash\n")
+
+    if options.oprofile:
+        f.write("opcontrol --stop\n")
+        f.write("opcontrol --reset\n")
+        f.write("opcontrol --start\n")
+
+    f.write("(\n")
+
+    for udelay in (10, 50, 100, 200, 300):
+        for nspes in range(options.min_spes, options.max_spes+1):
+            cmd = "./benchmark_nop -n %d -u %d -N %d\n" % (nspes, udelay, njobs[udelay])
+            f.write(cmd)
+            f.write(cmd)
+
+    f.write(") | tee %s\n" % (f_results,))
+
+    if options.oprofile:
+        f.write("opcontrol --dump\n")
+        f.write("opcontrol --stop\n")
+        f.write("opreport -l | head -100 > %s\n" % (f_opreport,))
+
+    f.write("./split_and_avg_results.py %s > %s\n" % (f_results, f_avg))
+    f.write("./plot_speedup.py %s -o %s\n" % (f_avg, f_png))
+
+
+if __name__ == '__main__':
+    main()
diff --git a/gcell/apps/plot_speedup.py b/gcell/apps/plot_speedup.py
new file mode 100755 (executable)
index 0000000..96277f8
--- /dev/null
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+
+from optparse import OptionParser
+from pylab import *
+from pprint import pprint
+import os.path
+
+
+def add_entry(d, nspes, speedup, work_incr):
+    if d.has_key(work_incr):
+        d[work_incr].append((nspes, speedup))
+    else:
+        d[work_incr] = [(nspes, speedup)]
+    
+def parse_file(f):
+    d = {}
+    for line in f:
+        items = [float(x) for x in line.split()]
+        # print "items =", items
+        nspes = items[0]
+        work_incr = int(1e6 * items[1])
+        speedup = items[4]
+        add_entry(d, nspes, speedup, work_incr)
+    return d
+
+
+class plot_data(object):
+    def __init__(self, filenames, output_filename):
+        self.fig = figure(1, figsize=(8, 6), facecolor='w')
+        self.sp = self.fig.add_subplot(1,1,1)
+        self.sp.set_xlabel("nspes", fontweight="bold")
+        self.sp.set_ylabel("speedup", fontweight="bold")
+        self.sp.grid(True)
+        # print 'rcParams["legend.fontsize"] =', rcParams["legend.fontsize"]
+        rcParams["legend.fontsize"] = 10
+
+
+        self.markers = {
+             10 : 'o',
+             50 : 's',
+            100 : '^',
+            200 : 'D',
+            300 : 'v',
+            400 : '>',
+            500 : 'h'
+            }
+        
+        if len(filenames) == 1:
+            f = filenames[0]
+            d = parse_file(open(f))
+            self.make_single_plot(d, f)
+            
+        else:
+            for f in filenames:
+                d = parse_file(open(f))
+                self.make_plot(d, f, f == filenames[0])
+
+        if output_filename:
+            savefig(output_filename)
+        else:
+            show()
+
+
+    def make_single_plot(self, d, filename):
+        def style(k):
+            return self.markers[k]
+
+        tag, ext = os.path.splitext(os.path.basename(filename))
+        title(tag)
+        keys = d.keys()
+        keys.sort()
+        keys.reverse()
+        for k in keys:
+            vlist = d[k]         # list of 2-tuples
+            xs = [v[0] for v in vlist]
+            ys = [v[1] for v in vlist]
+            plot(xs, ys, style(k), label="%d us" % (k,))
+
+        x = legend(loc=2)
+
+    def make_plot(self, d, filename, first):
+        def style(k):
+            if first:
+                return self.markers[k]
+            else:
+                return 'k' + self.markers[k]
+
+        tag, ext = os.path.splitext(os.path.basename(filename))
+        keys = d.keys()
+        keys.sort()
+        keys.reverse()
+        for k in keys:
+            vlist = d[k]         # list of 2-tuples
+            xs = [v[0] for v in vlist]
+            ys = [v[1] for v in vlist]
+            plot(xs, ys, style(k), label="%s %d us" % (tag, k))
+
+        x = legend(loc=2)
+
+def main():
+    usage="%prog: [options] input_filename..."
+    description = "Plot R*.avg files from benchmark_nop.py"
+    parser = OptionParser(usage=usage, description=description)
+    parser.add_option('-o', '--output', default=None,  metavar="FILE",
+                      help="generate .png file")
+    (options, args) = parser.parse_args()
+    if len(args) < 1:
+        parser.print_help()
+        raise SystemExit, 1
+
+    filenames = args
+    dc = plot_data(filenames, options.output)
+
+
+        
+if __name__ == '__main__':
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+
diff --git a/gcell/apps/results-071223 b/gcell/apps/results-071223
new file mode 100644 (file)
index 0000000..2716171
--- /dev/null
@@ -0,0 +1,126 @@
+nspes:  1  udelay:    1  elapsed_time:  26.117  njobs: 1e+06  us/job:  26.117
+nspes:  1  udelay:    1  elapsed_time:  26.058  njobs: 1e+06  us/job:  26.058
+nspes:  1  udelay:    1  elapsed_time:  26.737  njobs: 1e+06  us/job:  26.737
+nspes:  2  udelay:    1  elapsed_time:  23.585  njobs: 1e+06  us/job:  23.585
+nspes:  2  udelay:    1  elapsed_time:  21.958  njobs: 1e+06  us/job:  21.958
+nspes:  2  udelay:    1  elapsed_time:  21.034  njobs: 1e+06  us/job:  21.034
+nspes:  3  udelay:    1  elapsed_time:  25.819  njobs: 1e+06  us/job:  25.819
+nspes:  3  udelay:    1  elapsed_time:  23.719  njobs: 1e+06  us/job:  23.719
+nspes:  3  udelay:    1  elapsed_time:  21.711  njobs: 1e+06  us/job:  21.711
+nspes:  4  udelay:    1  elapsed_time:  20.210  njobs: 1e+06  us/job:  20.210
+nspes:  4  udelay:    1  elapsed_time:  20.558  njobs: 1e+06  us/job:  20.558
+nspes:  4  udelay:    1  elapsed_time:  20.957  njobs: 1e+06  us/job:  20.957
+nspes:  5  udelay:    1  elapsed_time:  24.571  njobs: 1e+06  us/job:  24.571
+nspes:  5  udelay:    1  elapsed_time:  20.207  njobs: 1e+06  us/job:  20.207
+nspes:  5  udelay:    1  elapsed_time:  21.976  njobs: 1e+06  us/job:  21.976
+nspes:  6  udelay:    1  elapsed_time:  22.601  njobs: 1e+06  us/job:  22.601
+nspes:  6  udelay:    1  elapsed_time:  18.794  njobs: 1e+06  us/job:  18.794
+nspes:  6  udelay:    1  elapsed_time:  19.755  njobs: 1e+06  us/job:  19.755
+nspes:  1  udelay:    5  elapsed_time:  28.047  njobs: 1e+06  us/job:  28.047
+nspes:  1  udelay:    5  elapsed_time:  27.265  njobs: 1e+06  us/job:  27.265
+nspes:  1  udelay:    5  elapsed_time:  27.555  njobs: 1e+06  us/job:  27.555
+nspes:  2  udelay:    5  elapsed_time:  21.130  njobs: 1e+06  us/job:  21.130
+nspes:  2  udelay:    5  elapsed_time:  21.067  njobs: 1e+06  us/job:  21.067
+nspes:  2  udelay:    5  elapsed_time:  21.607  njobs: 1e+06  us/job:  21.607
+nspes:  3  udelay:    5  elapsed_time:  23.712  njobs: 1e+06  us/job:  23.712
+nspes:  3  udelay:    5  elapsed_time:  23.658  njobs: 1e+06  us/job:  23.658
+nspes:  3  udelay:    5  elapsed_time:  25.277  njobs: 1e+06  us/job:  25.277
+nspes:  4  udelay:    5  elapsed_time:  22.264  njobs: 1e+06  us/job:  22.264
+nspes:  4  udelay:    5  elapsed_time:  20.970  njobs: 1e+06  us/job:  20.970
+nspes:  4  udelay:    5  elapsed_time:  21.533  njobs: 1e+06  us/job:  21.533
+nspes:  5  udelay:    5  elapsed_time:  21.504  njobs: 1e+06  us/job:  21.504
+nspes:  5  udelay:    5  elapsed_time:  21.956  njobs: 1e+06  us/job:  21.956
+nspes:  5  udelay:    5  elapsed_time:  21.333  njobs: 1e+06  us/job:  21.333
+nspes:  6  udelay:    5  elapsed_time:  20.639  njobs: 1e+06  us/job:  20.639
+nspes:  6  udelay:    5  elapsed_time:  23.022  njobs: 1e+06  us/job:  23.022
+nspes:  6  udelay:    5  elapsed_time:  22.453  njobs: 1e+06  us/job:  22.453
+nspes:  1  udelay:   10  elapsed_time:  27.780  njobs: 1e+06  us/job:  27.780
+nspes:  1  udelay:   10  elapsed_time:  27.683  njobs: 1e+06  us/job:  27.683
+nspes:  1  udelay:   10  elapsed_time:  26.803  njobs: 1e+06  us/job:  26.803
+nspes:  2  udelay:   10  elapsed_time:  20.878  njobs: 1e+06  us/job:  20.878
+nspes:  2  udelay:   10  elapsed_time:  22.430  njobs: 1e+06  us/job:  22.430
+nspes:  2  udelay:   10  elapsed_time:  20.952  njobs: 1e+06  us/job:  20.952
+nspes:  3  udelay:   10  elapsed_time:  22.752  njobs: 1e+06  us/job:  22.752
+nspes:  3  udelay:   10  elapsed_time:  24.294  njobs: 1e+06  us/job:  24.294
+nspes:  3  udelay:   10  elapsed_time:  23.935  njobs: 1e+06  us/job:  23.935
+nspes:  4  udelay:   10  elapsed_time:  20.437  njobs: 1e+06  us/job:  20.437
+nspes:  4  udelay:   10  elapsed_time:  21.498  njobs: 1e+06  us/job:  21.498
+nspes:  4  udelay:   10  elapsed_time:  20.521  njobs: 1e+06  us/job:  20.521
+nspes:  5  udelay:   10  elapsed_time:  22.704  njobs: 1e+06  us/job:  22.704
+nspes:  5  udelay:   10  elapsed_time:  21.106  njobs: 1e+06  us/job:  21.106
+nspes:  5  udelay:   10  elapsed_time:  22.800  njobs: 1e+06  us/job:  22.800
+nspes:  6  udelay:   10  elapsed_time:  21.098  njobs: 1e+06  us/job:  21.098
+nspes:  6  udelay:   10  elapsed_time:  22.749  njobs: 1e+06  us/job:  22.749
+nspes:  6  udelay:   10  elapsed_time:  19.651  njobs: 1e+06  us/job:  19.651
+nspes:  1  udelay:   50  elapsed_time:  54.621  njobs: 1e+06  us/job:  54.621
+nspes:  1  udelay:   50  elapsed_time:  54.548  njobs: 1e+06  us/job:  54.548
+nspes:  1  udelay:   50  elapsed_time:  54.641  njobs: 1e+06  us/job:  54.641
+nspes:  2  udelay:   50  elapsed_time:  30.837  njobs: 1e+06  us/job:  30.837
+nspes:  2  udelay:   50  elapsed_time:  30.933  njobs: 1e+06  us/job:  30.933
+nspes:  2  udelay:   50  elapsed_time:  30.044  njobs: 1e+06  us/job:  30.044
+nspes:  3  udelay:   50  elapsed_time:  24.170  njobs: 1e+06  us/job:  24.170
+nspes:  3  udelay:   50  elapsed_time:  23.798  njobs: 1e+06  us/job:  23.798
+nspes:  3  udelay:   50  elapsed_time:  23.515  njobs: 1e+06  us/job:  23.515
+nspes:  4  udelay:   50  elapsed_time:  23.011  njobs: 1e+06  us/job:  23.011
+nspes:  4  udelay:   50  elapsed_time:  21.382  njobs: 1e+06  us/job:  21.382
+nspes:  4  udelay:   50  elapsed_time:  20.531  njobs: 1e+06  us/job:  20.531
+nspes:  5  udelay:   50  elapsed_time:  24.157  njobs: 1e+06  us/job:  24.157
+nspes:  5  udelay:   50  elapsed_time:  21.119  njobs: 1e+06  us/job:  21.119
+nspes:  5  udelay:   50  elapsed_time:  22.055  njobs: 1e+06  us/job:  22.055
+nspes:  6  udelay:   50  elapsed_time:  19.136  njobs: 1e+06  us/job:  19.136
+nspes:  6  udelay:   50  elapsed_time:  20.607  njobs: 1e+06  us/job:  20.607
+nspes:  6  udelay:   50  elapsed_time:  20.527  njobs: 1e+06  us/job:  20.527
+nspes:  1  udelay:  100  elapsed_time: 107.531  njobs: 1e+06  us/job: 107.531
+nspes:  1  udelay:  100  elapsed_time: 107.607  njobs: 1e+06  us/job: 107.607
+nspes:  1  udelay:  100  elapsed_time: 107.532  njobs: 1e+06  us/job: 107.532
+nspes:  2  udelay:  100  elapsed_time:  53.950  njobs: 1e+06  us/job:  53.950
+nspes:  2  udelay:  100  elapsed_time:  53.920  njobs: 1e+06  us/job:  53.920
+nspes:  2  udelay:  100  elapsed_time:  54.232  njobs: 1e+06  us/job:  54.232
+nspes:  3  udelay:  100  elapsed_time:  37.987  njobs: 1e+06  us/job:  37.987
+nspes:  3  udelay:  100  elapsed_time:  38.778  njobs: 1e+06  us/job:  38.778
+nspes:  3  udelay:  100  elapsed_time:  39.042  njobs: 1e+06  us/job:  39.042
+nspes:  4  udelay:  100  elapsed_time:  31.192  njobs: 1e+06  us/job:  31.192
+nspes:  4  udelay:  100  elapsed_time:  31.090  njobs: 1e+06  us/job:  31.090
+nspes:  4  udelay:  100  elapsed_time:  31.472  njobs: 1e+06  us/job:  31.472
+nspes:  5  udelay:  100  elapsed_time:  28.490  njobs: 1e+06  us/job:  28.490
+nspes:  5  udelay:  100  elapsed_time:  27.574  njobs: 1e+06  us/job:  27.574
+nspes:  5  udelay:  100  elapsed_time:  27.013  njobs: 1e+06  us/job:  27.013
+nspes:  6  udelay:  100  elapsed_time:  26.635  njobs: 1e+06  us/job:  26.635
+nspes:  6  udelay:  100  elapsed_time:  24.036  njobs: 1e+06  us/job:  24.036
+nspes:  6  udelay:  100  elapsed_time:  26.174  njobs: 1e+06  us/job:  26.174
+nspes:  1  udelay:  300  elapsed_time: 320.618  njobs: 1e+06  us/job: 320.618
+nspes:  1  udelay:  300  elapsed_time: 320.635  njobs: 1e+06  us/job: 320.635
+nspes:  1  udelay:  300  elapsed_time: 320.699  njobs: 1e+06  us/job: 320.699
+nspes:  2  udelay:  300  elapsed_time: 160.314  njobs: 1e+06  us/job: 160.314
+nspes:  2  udelay:  300  elapsed_time: 160.340  njobs: 1e+06  us/job: 160.340
+nspes:  2  udelay:  300  elapsed_time: 160.312  njobs: 1e+06  us/job: 160.312
+nspes:  3  udelay:  300  elapsed_time: 106.878  njobs: 1e+06  us/job: 106.878
+nspes:  3  udelay:  300  elapsed_time: 106.875  njobs: 1e+06  us/job: 106.875
+nspes:  3  udelay:  300  elapsed_time: 106.871  njobs: 1e+06  us/job: 106.871
+nspes:  4  udelay:  300  elapsed_time:  80.158  njobs: 1e+06  us/job:  80.158
+nspes:  4  udelay:  300  elapsed_time:  80.163  njobs: 1e+06  us/job:  80.163
+nspes:  4  udelay:  300  elapsed_time:  80.154  njobs: 1e+06  us/job:  80.154
+nspes:  5  udelay:  300  elapsed_time:  64.156  njobs: 1e+06  us/job:  64.156
+nspes:  5  udelay:  300  elapsed_time:  64.250  njobs: 1e+06  us/job:  64.250
+nspes:  5  udelay:  300  elapsed_time:  64.158  njobs: 1e+06  us/job:  64.158
+nspes:  6  udelay:  300  elapsed_time:  53.633  njobs: 1e+06  us/job:  53.633
+nspes:  6  udelay:  300  elapsed_time:  53.541  njobs: 1e+06  us/job:  53.541
+nspes:  6  udelay:  300  elapsed_time:  53.617  njobs: 1e+06  us/job:  53.617
+nspes:  1  udelay:  500  elapsed_time: 533.638  njobs: 1e+06  us/job: 533.638
+nspes:  1  udelay:  500  elapsed_time: 533.649  njobs: 1e+06  us/job: 533.649
+nspes:  1  udelay:  500  elapsed_time: 533.618  njobs: 1e+06  us/job: 533.618
+nspes:  2  udelay:  500  elapsed_time: 266.810  njobs: 1e+06  us/job: 266.810
+nspes:  2  udelay:  500  elapsed_time: 266.814  njobs: 1e+06  us/job: 266.814
+nspes:  2  udelay:  500  elapsed_time: 266.893  njobs: 1e+06  us/job: 266.893
+nspes:  3  udelay:  500  elapsed_time: 177.875  njobs: 1e+06  us/job: 177.875
+nspes:  3  udelay:  500  elapsed_time: 177.878  njobs: 1e+06  us/job: 177.878
+nspes:  3  udelay:  500  elapsed_time: 177.875  njobs: 1e+06  us/job: 177.875
+nspes:  4  udelay:  500  elapsed_time: 133.417  njobs: 1e+06  us/job: 133.417
+nspes:  4  udelay:  500  elapsed_time: 133.483  njobs: 1e+06  us/job: 133.483
+nspes:  4  udelay:  500  elapsed_time: 133.407  njobs: 1e+06  us/job: 133.407
+nspes:  5  udelay:  500  elapsed_time: 106.723  njobs: 1e+06  us/job: 106.723
+nspes:  5  udelay:  500  elapsed_time: 106.728  njobs: 1e+06  us/job: 106.728
+nspes:  5  udelay:  500  elapsed_time: 106.722  njobs: 1e+06  us/job: 106.722
+nspes:  6  udelay:  500  elapsed_time:  88.943  njobs: 1e+06  us/job:  88.943
+nspes:  6  udelay:  500  elapsed_time:  88.941  njobs: 1e+06  us/job:  88.941
+nspes:  6  udelay:  500  elapsed_time:  88.944  njobs: 1e+06  us/job:  88.944
diff --git a/gcell/apps/split_and_avg_results.py b/gcell/apps/split_and_avg_results.py
new file mode 100755 (executable)
index 0000000..8a750fa
--- /dev/null
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+"""
+input file looks like this:
+
+nspes:  1  udelay:   10  elapsed_time:   6.842  njobs: 500000  speedup:  0.731
+nspes:  2  udelay:   10  elapsed_time:   4.093  njobs: 500000  speedup:  1.221
+"""
+
+import sys
+from optparse import OptionParser
+from pprint import pprint
+
+class data(object):
+    def __init__(self, nspes, work_per_job, elapsed_time, njobs):
+        self.nspes = nspes
+        self.work_per_job = work_per_job  # seconds
+        self.elapsed_time = elapsed_time  # seconds
+        self.njobs = njobs
+        self.speedup = work_per_job * njobs / elapsed_time
+
+    def __repr__(self):
+        return "<data nspes=%d work_per_job=%s elapsed_time=%s njobs=%s speedup=%s>" % (
+            self.nspes, (self.work_per_job),
+            (self.elapsed_time),
+            (self.njobs),
+            (self.speedup))
+
+def cmp_data(x, y):
+    t = x.nspes - y.nspes
+    if t == 0:
+        t = x.work_per_job - y.work_per_job
+        if t < 0:
+            return -1
+        elif t > 0:
+            return +1
+        else:
+            return 0
+    return t
+
+def main():
+    usage = "usage: %prog [options] input_filename"
+    parser = OptionParser(usage=usage)
+    (options, args) = parser.parse_args()
+    if len(args) != 1:
+        parser.print_help()
+        raise SystemExit, 1
+    input_filename = args[0]
+
+    
+    m = {}
+    for line in open(input_filename, "r"):
+        s = line.split()
+        nspes = int(s[1])
+        work_per_job = int(s[3]) * 1e-6
+        elapsed_time = float(s[5])
+        njobs = float(s[7])
+        d = data(nspes, work_per_job, elapsed_time, njobs)
+
+        # collect lists that have the same values for nspes and work_per_job
+        # so we can generate an average elapsed_time from all observations
+        key = (nspes, work_per_job)
+        v = m.get(key, [])
+        v.append(d)
+        m[key] = v
+
+    r = []
+    for k, v in m.iteritems():
+        total_elapsed_time = sum([x.elapsed_time for x in v])
+        r.append(data(v[0].nspes,
+                      v[0].work_per_job,
+                      total_elapsed_time/len(v),
+                      v[0].njobs))
+
+    r.sort(cmp_data)
+
+    #pprint(r)
+    for t in r:
+        print t.nspes, t.work_per_job, t.elapsed_time, t.njobs, t.speedup
+
+if __name__ == '__main__':
+    main()
diff --git a/gcell/apps/spu/Makefile.am b/gcell/apps/spu/Makefile.am
new file mode 100644 (file)
index 0000000..c07a2c3
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+
+include $(top_srcdir)/Makefile.common.spu
+
+AM_CPPFLAGS = $(GCELL_SPU_INCLUDES)
+
+# SPU executables
+
+noinst_PROGRAMS = \
+       benchmark_procs
+
+benchmark_procs_SOURCES = benchmark_procs.c
+benchmark_procs_LDADD = $(GCELL_SPU_LA)
+benchmark_procs_DEPENDENCIES = $(GCELL_SPU_LA)
+
diff --git a/gcell/apps/spu/benchmark_procs.c b/gcell/apps/spu/benchmark_procs.c
new file mode 100644 (file)
index 0000000..fbc7033
--- /dev/null
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_declare_proc.h>
+#include <gcell/spu/gc_delay.h>
+#include <string.h>
+
+static void
+benchmark_udelay(const gc_job_direct_args_t *input,
+                gc_job_direct_args_t *output _UNUSED,
+                const gc_job_ea_args_t *eaa _UNUSED)
+{
+  gc_udelay(input->arg[0].u32);
+}
+
+GC_DECLARE_PROC(benchmark_udelay, "benchmark_udelay");
+
+
+
+static void
+benchmark_put_zeros(const gc_job_direct_args_t *input _UNUSED,
+                   gc_job_direct_args_t *output _UNUSED,
+                   const gc_job_ea_args_t *eaa)
+{
+  for (unsigned int i = 0; i < eaa->nargs; i++){
+    if (eaa->arg[i].direction == GCJD_DMA_PUT)
+      memset(eaa->arg[i].ls_addr, 0, eaa->arg[i].put_size);
+  }
+}
+
+GC_DECLARE_PROC(benchmark_put_zeros, "benchmark_put_zeros");
+
+
+static void
+benchmark_copy(const gc_job_direct_args_t *input _UNUSED,
+              gc_job_direct_args_t *output,
+              const gc_job_ea_args_t *eaa)
+{
+  if (eaa->nargs != 2
+      || eaa->arg[0].direction != GCJD_DMA_PUT
+      || eaa->arg[1].direction != GCJD_DMA_GET){
+    output->arg[0].s32 = -1;
+    return;
+  }
+
+  output->arg[0].s32 = 0;
+  unsigned n = eaa->arg[0].put_size;
+  if (eaa->arg[1].get_size < n)
+    n = eaa->arg[1].get_size;
+  
+  memcpy(eaa->arg[0].ls_addr, eaa->arg[1].ls_addr, n);
+}
+
+GC_DECLARE_PROC(benchmark_copy, "benchmark_copy");
diff --git a/gcell/apps/test_all.cc b/gcell/apps/test_all.cc
new file mode 100644 (file)
index 0000000..9823960
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <cppunit/TextTestRunner.h>
+
+#include "../lib/runtime/qa_gcell_runtime.h"
+#include "../lib/wrapper/qa_gcell_wrapper.h"
+
+int 
+main(int argc, char **argv)
+{
+  
+  CppUnit::TextTestRunner      runner;
+
+  runner.addTest(qa_gcell_runtime::suite());
+  runner.addTest(qa_gcell_wrapper::suite());
+  
+  bool was_successful = runner.run("", false);
+
+  return was_successful ? 0 : 1;
+}
index 2b6101d13e1d1b444c6b7e5b4c50d4221dc4c672..d88d0fb674462155f7623fc599f9c8719d527317 100644 (file)
@@ -2,10 +2,11 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
+gcell_embedspu_libtool=@bindir@/gcell-embedspu-libtool
 
 Name: gcell
 Description: The GNU Radio SPE scheduler and RPC mechanism
-Requires: gnuradio-omnithread mblock
+Requires: gnuradio-omnithread
 Version: @VERSION@
 Libs: -L${libdir} -lgcell
 Cflags: -I${includedir} @DEFINES@
diff --git a/gcell/gcell_spu.pc.in b/gcell/gcell_spu.pc.in
new file mode 100644 (file)
index 0000000..b59043b
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@spu
+includedir=@includedir@
+
+Name: gcell_spu
+Description: The GNU Radio SPE scheduler and RPC mechanism (SPU components)
+Requires: 
+Version: @VERSION@
+Libs: -L${libdir} -lgcell_spu
+Cflags: -I${includedir}
diff --git a/gcell/ibm/Makefile.am b/gcell/ibm/Makefile.am
new file mode 100644 (file)
index 0000000..8013e6a
--- /dev/null
@@ -0,0 +1,98 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+EXTRA_DIST = \
+       ./README \
+       ./sync/ppu_source/atomic_add.h \
+       ./sync/ppu_source/atomic_add_return.h \
+       ./sync/ppu_source/atomic_dec_and_test.h \
+       ./sync/ppu_source/atomic_dec.h \
+       ./sync/ppu_source/atomic_dec_if_positive.h \
+       ./sync/ppu_source/atomic_dec_return.h \
+       ./sync/ppu_source/atomic.h \
+       ./sync/ppu_source/atomic_inc.h \
+       ./sync/ppu_source/atomic_inc_return.h \
+       ./sync/ppu_source/atomic_read.h \
+       ./sync/ppu_source/atomic_set.h \
+       ./sync/ppu_source/atomic_sub_and_test.h \
+       ./sync/ppu_source/atomic_sub.h \
+       ./sync/ppu_source/atomic_sub_return.h \
+       ./sync/ppu_source/complete_all.h \
+       ./sync/ppu_source/complete.h \
+       ./sync/ppu_source/completion.h \
+       ./sync/ppu_source/cond_broadcast.h \
+       ./sync/ppu_source/cond.h \
+       ./sync/ppu_source/cond_init.h \
+       ./sync/ppu_source/cond_signal.h \
+       ./sync/ppu_source/cond_wait.h \
+       ./sync/ppu_source/init_completion.h \
+       ./sync/ppu_source/libsync.h \
+       ./sync/ppu_source/mutex.h \
+       ./sync/ppu_source/mutex_init.h \
+       ./sync/ppu_source/mutex_lock.h \
+       ./sync/ppu_source/mutex_trylock.h \
+       ./sync/ppu_source/mutex_unlock.h \
+       ./sync/ppu_source/pdt_libsync_config.xml \
+       ./sync/ppu_source/pdt_libsync.xml \
+       ./sync/ppu_source/sync_utils.h \
+       ./sync/ppu_source/trace_libsync.h \
+       ./sync/ppu_source/wait_for_completion.h \
+       ./sync/spu_source/atomic_add.h \
+       ./sync/spu_source/atomic_add_return.h \
+       ./sync/spu_source/atomic_dec_and_test.h \
+       ./sync/spu_source/atomic_dec.h \
+       ./sync/spu_source/atomic_dec_if_positive.h \
+       ./sync/spu_source/atomic_dec_return.h \
+       ./sync/spu_source/atomic.h \
+       ./sync/spu_source/atomic_inc.h \
+       ./sync/spu_source/atomic_inc_return.h \
+       ./sync/spu_source/atomic_read.h \
+       ./sync/spu_source/atomic_set.h \
+       ./sync/spu_source/atomic_sub_and_test.h \
+       ./sync/spu_source/atomic_sub.h \
+       ./sync/spu_source/atomic_sub_return.h \
+       ./sync/spu_source/complete_all.h \
+       ./sync/spu_source/complete.h \
+       ./sync/spu_source/completion.h \
+       ./sync/spu_source/cond_broadcast.h \
+       ./sync/spu_source/cond.h \
+       ./sync/spu_source/cond_init.h \
+       ./sync/spu_source/cond_signal.h \
+       ./sync/spu_source/cond_wait.h \
+       ./sync/spu_source/init_completion.h \
+       ./sync/spu_source/libsync.h \
+       ./sync/spu_source/mutex.h \
+       ./sync/spu_source/mutex_init.h \
+       ./sync/spu_source/mutex_lock.h \
+       ./sync/spu_source/mutex_trylock.h \
+       ./sync/spu_source/mutex_unlock.h \
+       ./sync/spu_source/read_lock.h \
+       ./sync/spu_source/read_trylock.h \
+       ./sync/spu_source/read_unlock.h \
+       ./sync/spu_source/rwlock_init.h \
+       ./sync/spu_source/sync_irq.h \
+       ./sync/spu_source/sync_utils.h \
+       ./sync/spu_source/trace_libsync.h \
+       ./sync/spu_source/wait_for_completion.h \
+       ./sync/spu_source/write_lock.h \
+       ./sync/spu_source/write_trylock.h \
+       ./sync/spu_source/write_unlock.h
diff --git a/gcell/ibm/README b/gcell/ibm/README
new file mode 100644 (file)
index 0000000..9420fcc
--- /dev/null
@@ -0,0 +1,10 @@
+This directory and below contains code from IBM licensed under the
+"Modified BSD license."  It was extracted unmodified from the IBM Cell
+SDK 3.0 library source tarball, lib_source.tar, typically found in
+/opt/cell/sdk/src/lib_source.tar.
+
+We've done this because this code doesn't come unpacked in the native
+(cell) installation of the SDK 3.0, and thus we can't just add a
+-I/path/to/this/stuff in our Makefiles.  If this changes, we'll delete
+this code from here, and fix our Makefiles.  In the meanwhile, this
+reduces the probability of build problems.
diff --git a/gcell/ibm/sync/ppu_source/atomic.h b/gcell/ibm/sync/ppu_source/atomic.h
new file mode 100644 (file)
index 0000000..105f7bf
--- /dev/null
@@ -0,0 +1,112 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+/*
+ * atomic.h - PPE atomic SHM counter operations.
+ *
+ * Interfaces patterned after, and hopefully compatible
+ * with PowerPC64-Linux atomic counter operations.  Uses
+ * 32b values for various counters.
+ */
+#ifndef _PPU_ATOMIC_H_
+#define _PPU_ATOMIC_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+
+typedef unsigned int atomic_t __attribute__ ((aligned (128))); 
+
+
+/* atomic_ea_t is a 64bit effective address  that points to 
+ * an atomic_t variable 
+ */
+typedef unsigned long long atomic_ea_t;
+
+/**
+ * ASSUMPTIONS:
+ * On the PPE, the size of a reservation granule is 128 bytes
+ * (a cache-line), so when a programmer puts a reservation on an
+ * address, that whole cacheline is reserved. Therefore both
+ * the PPE and SPE can participate in an atomic operation as long as
+ * lwarx and getllar operate on the same cacheline. 
+ */ 
+
+
+/*
+ * atomically loads and replaces the value v with val. 
+ * Returns the old value at v
+ */ 
+static __inline int _atomic_replace(atomic_ea_t v, int val)
+{
+  int old;
+  void *p;
+
+  SYNC_ULL_TO_PTR(v, p);
+
+  do {
+    old = (int)__lwarx(p);
+  } while (__stwcx(p, (unsigned int)val) == 0);
+
+  return old;
+}
+
+
+/*
+ * atomically loads the value at v, adds val, replaces the
+ * value at v with the sum. Returns the old value at v
+ */ 
+static __inline int _atomic_modify(atomic_ea_t v, int val)
+{
+  int oldval, newval;
+  void *p;
+
+  SYNC_ULL_TO_PTR(v, p);
+
+  do {
+    oldval = (int)__lwarx(p);
+    newval = oldval + val;
+  } while (__stwcx(p, (unsigned int)newval) == 0);
+
+  return oldval;
+}
+
+
+#endif /* _PPU_ATOMIC_H_ */
+
diff --git a/gcell/ibm/sync/ppu_source/atomic_add.h b/gcell/ibm/sync/ppu_source/atomic_add.h
new file mode 100644 (file)
index 0000000..dd7a5b2
--- /dev/null
@@ -0,0 +1,62 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_ADD_H_
+#define _PPU_ATOMIC_ADD_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_add - atomically add to a counter.
+ * @v: handle to effective address of counter.
+ * @a: value to be added.
+ * 
+ * Atomically add a value to a counter in system memory. 
+ * The only restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_add(int a, atomic_ea_t v)
+{
+  _atomic_modify (v, a);
+}
+
+
+
+#endif /* _PPU_ATOMIC_ADD_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_add_return.h b/gcell/ibm/sync/ppu_source/atomic_add_return.h
new file mode 100644 (file)
index 0000000..0fe1275
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_ADD_RETURN_H_
+#define _PPU_ATOMIC_ADD_RETURN_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_add_return - atomically add to a counter and return previous value.
+ * @v: handle to effective address of counter.
+ * @a: value to be added.
+ *
+ * Atomically add a value to a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ *
+ * This routine implements the "fetch and add" primitive
+ * that is described in "Book I PowerPC User Instruction
+ * Set Architecture" 
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_add_return(int a, atomic_ea_t v)
+{
+  return _atomic_modify (v, a);
+}
+
+
+#endif /* _PPU_ATOMIC_ADD_RETURN_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_dec.h b/gcell/ibm/sync/ppu_source/atomic_dec.h
new file mode 100644 (file)
index 0000000..4f82f04
--- /dev/null
@@ -0,0 +1,60 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_DEC_H_
+#define _PPU_ATOMIC_DEC_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_dec - atomically decrement a counter.
+ * @v: handle to effective address of location to be modified.
+ *
+ * Atomically decrement a counter in system memory. The only
+ * restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_dec(atomic_ea_t v)
+{
+  _atomic_modify (v, -1);
+}
+
+
+#endif /* _PPU_ATOMIC_DEC_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_dec_and_test.h b/gcell/ibm/sync/ppu_source/atomic_dec_and_test.h
new file mode 100644 (file)
index 0000000..5093d40
--- /dev/null
@@ -0,0 +1,63 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_DEC_AND_TEST_H_
+#define _PPU_ATOMIC_DEC_AND_TEST_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_dec_and_test - atomically decrement and test if previous==0.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically decrement a counter in system memory and test 
+ * if previous==0.  The only restriction is that @v must be 
+ * word aligned.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_dec_and_test(atomic_ea_t v)
+{
+  return (_atomic_modify(v, -1) == 0) ? 1 : 0;
+}
+
+
+#endif /* _PPU_ATOMIC_DEC_AND_TEST_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_dec_if_positive.h b/gcell/ibm/sync/ppu_source/atomic_dec_if_positive.h
new file mode 100644 (file)
index 0000000..c4d113b
--- /dev/null
@@ -0,0 +1,76 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_DEC_IF_POSITIVE_H_
+#define _PPU_ATOMIC_DEC_IF_POSITIVE_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "atomic.h"
+
+/*
+ * atomic_dec_if_positive - atomically decrement if counter is positive.
+ *
+ *  v: handle to effective address of counter.
+ * 
+ * Atomically decrement a counter if its value is positive.
+ * The only restriction is that v must be word aligned.
+ *
+ *
+ * Returns the old value of the counter, minus 1.
+ */
+static __inline int _atomic_dec_if_positive(atomic_ea_t v)
+{
+  int ret;
+  int tmp;
+  void *p;
+
+  SYNC_ULL_TO_PTR(v, p);
+
+  do {
+    tmp = (int)__lwarx(p);
+    ret = tmp - 1;
+    tmp = (tmp > 0) ? ret : tmp; 
+  } while (__stwcx(p, (unsigned)tmp) == 0);
+
+  return ret;
+}
+
+#endif /* _PPU_ATOMIC_DEC_IF_POSITIVE_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_dec_return.h b/gcell/ibm/sync/ppu_source/atomic_dec_return.h
new file mode 100644 (file)
index 0000000..cd87893
--- /dev/null
@@ -0,0 +1,68 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_DEC_RETURN_H_
+#define _PPU_ATOMIC_DEC_RETURN_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_dec_return - atomically decrement a counter and return previous value.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically decrement a counter in system memory and return its
+ * previous value. The only restriction is that @v must be word 
+ * aligned.
+ *
+ * This routine implements the "fetch and decrement"
+ * primitive that is described in "Book I PowerPC User
+ * Instruction Set Architecture".
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_dec_return(atomic_ea_t v)
+{
+  return _atomic_modify (v, -1);
+}
+
+
+
+#endif /* _PPU_ATOMIC_DEC_RETURN_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_inc.h b/gcell/ibm/sync/ppu_source/atomic_inc.h
new file mode 100644 (file)
index 0000000..714aecb
--- /dev/null
@@ -0,0 +1,59 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_INC_H_
+#define _PPU_ATOMIC_INC_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_inc - atomically increment a counter in system memory.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically increment a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_inc(atomic_ea_t v)
+{
+  _atomic_modify (v, 1); 
+}
+
+#endif /* _PPU_ATOMIC_INC_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_inc_return.h b/gcell/ibm/sync/ppu_source/atomic_inc_return.h
new file mode 100644 (file)
index 0000000..95178f5
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_INC_RETURN_H_
+#define _PPU_ATOMIC_INC_RETURN_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+
+/**
+ * atomic_inc_return - atomically increment a counter and return previous.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically increment a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ *
+ * This routine implements the "fetch and increment"
+ * primitive that is described in "Book I PowerPC User
+ * Instruction Set Architecture" 
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_inc_return(atomic_ea_t v)
+{
+  return _atomic_modify (v, 1);
+}
+
+#endif /* _PPU_ATOMIC_INC_RETURN_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_read.h b/gcell/ibm/sync/ppu_source/atomic_read.h
new file mode 100644 (file)
index 0000000..258fd51
--- /dev/null
@@ -0,0 +1,62 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_READ_H_
+#define _PPU_ATOMIC_READ_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/*
+ * On PowerPC architecture, if v is a word_aligned address, then
+ * a load of that address is guaranteed to be atomic.  An atomic
+ * read operation is simply a load.
+ */ 
+static __inline int _atomic_read(atomic_ea_t v)
+{
+  volatile int *p;
+
+  SYNC_ULL_TO_PTR(v, p);
+
+  return (*p);
+}
+
+
+#endif /* _PPU_ATOMIC_READ_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_set.h b/gcell/ibm/sync/ppu_source/atomic_set.h
new file mode 100644 (file)
index 0000000..e624af4
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_SET_H_
+#define _PPU_ATOMIC_SET_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_set - atomically set a counter in system memory.
+ * @v: this is a 64bit address that points to an atomic_t 
+ * 
+ * Atomically set a counter to a given value. The only 
+ * restriction is that @v must be word aligned.
+ *
+ * This routine implements the "fetch and store" 
+ * primitive that is described in "Book I PowerPC User 
+ * Instruction Set Architecture"
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline void _atomic_set(atomic_ea_t v, int val)
+{
+  _atomic_replace (v, val);
+}
+
+
+#endif /* _PPU_ATOMIC_SET_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_sub.h b/gcell/ibm/sync/ppu_source/atomic_sub.h
new file mode 100644 (file)
index 0000000..b8d3597
--- /dev/null
@@ -0,0 +1,61 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_SUB_H_
+#define _PPU_ATOMIC_SUB_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_sub - atomically subtract from a counter.
+ * @v: handle to effective address of counter.
+ * @a: value to be subtracted.
+ *
+ * Atomically subtract a value from a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_sub(int a, atomic_ea_t v)
+{
+  _atomic_modify (v, -a);
+}
+
+
+#endif /* _PPU_ATOMIC_SUB_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_sub_and_test.h b/gcell/ibm/sync/ppu_source/atomic_sub_and_test.h
new file mode 100644 (file)
index 0000000..37ba588
--- /dev/null
@@ -0,0 +1,63 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_SUB_AND_TEST_H_
+#define _PPU_ATOMIC_SUB_AND_TEST_H_
+
+#include "sync_utils.h"
+#include "atomic.h"
+
+/**
+ * atomic_sub_and_test - atomically subtract and test if previous==0.
+ * @v: handle to effective address of counter.
+ * @a: value to be subtracted.
+ *
+ * Atomically subtract a value from a counter in system memory
+ * and test if previous==0.  The only restriction is that @v 
+ * must be word aligned.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_sub_and_test(int a, atomic_ea_t v)
+{
+  return (_atomic_modify(v, -a) == 0) ? 1 : 0;
+}
+
+#endif /* _PPU_ATOMIC_SUB_AND_TEST_H_ */
diff --git a/gcell/ibm/sync/ppu_source/atomic_sub_return.h b/gcell/ibm/sync/ppu_source/atomic_sub_return.h
new file mode 100644 (file)
index 0000000..084bfa6
--- /dev/null
@@ -0,0 +1,65 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_ATOMIC_SUB_RETURN_H_
+#define _PPU_ATOMIC_SUB_RETURN_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+
+/**
+ * atomic_sub_return - atomically subtract from a counter & return previous.
+ * @v: handle to effective address of counter.
+ * @a: value to be subtracted.
+ *
+ * Atomically subtract a value from a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ *
+ * Returns the previous value from system memory.
+ */
+
+
+static __inline int _atomic_sub_return(int a, atomic_ea_t v)
+{
+  return _atomic_modify (v, -a);
+}
+
+#endif /* _PPU_ATOMIC_SUB_RETURN_H_ */
diff --git a/gcell/ibm/sync/ppu_source/complete.h b/gcell/ibm/sync/ppu_source/complete.h
new file mode 100644 (file)
index 0000000..8633463
--- /dev/null
@@ -0,0 +1,61 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COMPLETE_H_
+#define _PPU_COMPLETE_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "completion.h"
+
+
+static __inline void _complete (completion_ea_t comp)
+{
+  unsigned int old;
+  void *p;
+
+  SYNC_ULL_TO_PTR(comp, p);
+
+  do {
+    old = __lwarx(p);
+  } while (__stwcx(p, (unsigned int)1) == 0);
+}
+
+#endif /* _PPU_COMPLETE_H_ */
diff --git a/gcell/ibm/sync/ppu_source/complete_all.h b/gcell/ibm/sync/ppu_source/complete_all.h
new file mode 100644 (file)
index 0000000..c12eb7f
--- /dev/null
@@ -0,0 +1,70 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COMPLETE_ALL_H_
+#define _PPU_COMPLETE_ALL_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "completion.h"
+
+/**
+ * complete_all - indicate that a completion is true.
+ * @completion: handle to effective address of completion variable.
+ *
+ * Indicate that all are completed is true by storing 
+ * MAX_THREADS_WAITING to the completionition variable.
+ */
+
+static __inline void _complete_all(completion_ea_t comp)
+{
+  unsigned int old;
+  unsigned int val = MAX_THREADS_WAITING;
+
+  void *p;
+
+  SYNC_ULL_TO_PTR(comp, p);
+
+  do {
+    old = __lwarx(p);
+  } while (__stwcx(p, val) == 0);
+}
+
+#endif /* _PPU_COMPLETE_ALL_H_ */
diff --git a/gcell/ibm/sync/ppu_source/completion.h b/gcell/ibm/sync/ppu_source/completion.h
new file mode 100644 (file)
index 0000000..b74bdaa
--- /dev/null
@@ -0,0 +1,50 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+
+#ifndef _PPU_COMPLETION_H_
+#define _PPU_COMPLETION_H_
+
+
+#define MAX_THREADS_WAITING   32000 
+
+typedef unsigned long long completion_ea_t;
+
+#endif /* _PPU_COMPLETION_H_ */
diff --git a/gcell/ibm/sync/ppu_source/cond.h b/gcell/ibm/sync/ppu_source/cond.h
new file mode 100644 (file)
index 0000000..9a38f71
--- /dev/null
@@ -0,0 +1,65 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COND_VAR_H_
+#define _PPU_COND_VAR_H_
+
+#include <mutex.h>
+#include <sync_utils.h>
+
+
+typedef struct
+{
+  short num_threads_signal;       /* the number of threads that are going to be waken up.
+                                 There are 3 values possible for this parameter, 0, 1, 
+                                 or num_threads_waiting*/
+  short num_threads_waiting;      /* the number of threads that are waiting to be awaken */ 
+} condition_variable_t __attribute__ ((aligned (16)));  
+
+typedef unsigned long long cond_ea_t;         /* a system memory 64 bit address that points to
+                                 * a valid condition_variable_t */
+
+typedef union {
+    unsigned long long ull;  
+    unsigned int ui[2];
+} val64;
+
+
+#endif /* _PPU_COND_VAR_H_ */
diff --git a/gcell/ibm/sync/ppu_source/cond_broadcast.h b/gcell/ibm/sync/ppu_source/cond_broadcast.h
new file mode 100644 (file)
index 0000000..b93bf7b
--- /dev/null
@@ -0,0 +1,70 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COND_BROADCAST_H_
+#define _PPU_COND_BROADCAST_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "cond.h"
+
+/**
+ * cond_broadcast - indicate that a condition is true.
+ * @cond: handle to effective address of condition variable.
+ */
+static __inline void _cond_broadcast (cond_ea_t cond)
+{
+  unsigned int val;
+  void *p;
+
+  SYNC_ULL_TO_PTR(cond, p);
+  
+  do {
+    val = __lwarx(p);
+
+    /* Copy the waiting count (low halfword) to
+     * the signaled count (high halfword)
+     */
+    val = (val & 0xFFFF) | ((val+1) << 16);
+    
+  } while (__stwcx(p, val) == 0);
+}
+
+#endif /* _PPU_COND_BROADCAST_H_ */
diff --git a/gcell/ibm/sync/ppu_source/cond_init.h b/gcell/ibm/sync/ppu_source/cond_init.h
new file mode 100644 (file)
index 0000000..0dfbd63
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COND_INIT_H_
+#define _PPU_COND_INIT_H_
+
+#include "sync_utils.h"
+#include "cond.h"
+
+/**
+ * cond_init - initialize condition variable.
+ * @cond: handle to effective address of condition variable.
+ *
+ * Only one thread initializes a condition variable. Usually, the 
+ * PPE thread initializes a condidtion variable 
+ *
+ * Description: Initialize a cond variable to false.
+ */
+static __inline void _cond_init (cond_ea_t  cond)
+{
+  volatile unsigned int *p;
+
+  SYNC_ULL_TO_PTR(cond, p);
+
+  *p = 0;
+}
+
+
+#endif /* _PPU_COND_INIT_H_ */
diff --git a/gcell/ibm/sync/ppu_source/cond_signal.h b/gcell/ibm/sync/ppu_source/cond_signal.h
new file mode 100644 (file)
index 0000000..dd48748
--- /dev/null
@@ -0,0 +1,74 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COND_SIGNAL_H_
+#define _PPU_COND_SIGNAL_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "cond.h"
+
+/*
+ * _cond_signal: signaling any of the waiting threads to wake up.
+ */ 
+static __inline void _cond_signal (cond_ea_t cond)
+{
+  unsigned int val, waiting, signaled;
+  void *p;
+
+  SYNC_ULL_TO_PTR(cond, p);
+  
+  do {
+    val = __lwarx(p);
+
+    waiting = val & 0xFFFF;
+    signaled = val >> 16;
+    
+    /* If no other party is waiting. Don't send a signal.
+     * Otherwise, increment the signaled halfword.
+     */
+    if (waiting == signaled) break;
+    val = ((val+1) << 16) | waiting;
+
+  } while (__stwcx(p, val) == 0);
+}
+
+
+#endif /* _PPU_COND_SIGNAL_H_ */
diff --git a/gcell/ibm/sync/ppu_source/cond_wait.h b/gcell/ibm/sync/ppu_source/cond_wait.h
new file mode 100644 (file)
index 0000000..ed5fbec
--- /dev/null
@@ -0,0 +1,96 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_COND_WAIT_H_
+#define _PPU_COND_WAIT_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "mutex_lock.h"
+#include "mutex_unlock.h"
+#include "cond.h"
+
+static __inline void _cond_wait (cond_ea_t cond, mutex_ea_t  mutex)
+{
+  int delta, cur_delta;
+  unsigned int val, cond_val, signaled_cnt;
+  void *p;
+
+
+  SYNC_ULL_TO_PTR(cond, p);
+
+  /* Atomically signal we have entered the condition wait by incrementing
+   * the waiting count.
+   */
+  do {
+    val = __lwarx(p);
+    val = (val & ~0xFFFF) | ((val+1) & 0xFFFF);
+  } while (__stwcx(p, val) == 0);
+
+
+  /* Release the lock
+   */
+  _mutex_unlock (mutex);
+
+  /* Determine the signal count needed for this 
+   * participant to be signaled.
+   */
+
+  signaled_cnt = val >> 16;
+  delta = (int)(val & 0xFFFF) - (int)signaled_cnt;
+  if (delta < 0) delta = -delta;
+
+  /* Wait until the signaled count reaches the count
+   * previously determined.
+   */
+  do {
+    cond_val = __lwarx(p);
+
+    cur_delta = (int)(cond_val >> 16) - signaled_cnt;
+    if (cur_delta < 0) cur_delta = -cur_delta;
+   
+  } while (cur_delta < delta);
+
+  /* Relock the mutex 
+   */
+  _mutex_lock (mutex);
+}
+
+#endif /* _PPU_COND_WAIT_H_ */
diff --git a/gcell/ibm/sync/ppu_source/init_completion.h b/gcell/ibm/sync/ppu_source/init_completion.h
new file mode 100644 (file)
index 0000000..8e70811
--- /dev/null
@@ -0,0 +1,63 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_INIT_COMPLETION_H_
+#define _PPU_INIT_COMPLETION_H_
+
+#include "sync_utils.h"
+#include "completion.h"
+
+/**
+ * completion_init - initialize completion variable.
+ * @completion: handle to effective address of completion variable.
+ *
+ * Description: Initialize a completion variable to 0.
+ */
+static __inline void _init_completion(completion_ea_t comp)
+{
+  volatile unsigned int *p;
+
+  SYNC_ULL_TO_PTR(comp, p);
+
+  *p = 0;
+}
+
+
+#endif /* _PPU_INIT_COMPLETION_H_ */
diff --git a/gcell/ibm/sync/ppu_source/libsync.h b/gcell/ibm/sync/ppu_source/libsync.h
new file mode 100644 (file)
index 0000000..bd2e043
--- /dev/null
@@ -0,0 +1,114 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_LIBSYNC_H_
+#define _PPU_LIBSYNC_H_
+
+#include "sync_utils.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned long long atomic_ea_t;
+
+extern void atomic_set(atomic_ea_t v, int val);
+extern void atomic_add(int a, atomic_ea_t v);
+extern void atomic_sub(int a, atomic_ea_t v);
+extern void atomic_inc(atomic_ea_t v);
+extern void atomic_dec(atomic_ea_t v);
+
+extern int atomic_read(atomic_ea_t v);
+extern int atomic_add_return(int a, atomic_ea_t v);
+extern int atomic_sub_return(int a, atomic_ea_t v);
+extern int atomic_inc_return(atomic_ea_t v);
+extern int atomic_dec_return(atomic_ea_t v);
+extern int atomic_sub_and_test(int a, atomic_ea_t v);
+extern int atomic_dec_and_test(atomic_ea_t v);
+extern int atomic_dec_if_positive(atomic_ea_t v);
+
+typedef unsigned long long mutex_ea_t;
+void mutex_init(mutex_ea_t lock);
+
+void mutex_lock(mutex_ea_t lock);
+int mutex_trylock(mutex_ea_t ea);
+void mutex_unlock(mutex_ea_t lock);
+
+typedef struct
+{
+  int num_threads_signal;       /* the number of threads that are going to be waken up.
+                                 There are 3 values possible for this parameter, 0, 1, 
+                                 or num_threads_waiting*/
+  int num_threads_waiting;      /* the number of threads that are waiting to be awaken */ 
+} condition_variable_t __attribute__ ((aligned (16)));  
+
+typedef unsigned long long cond_ea_t;         /* a system memory 64 bit address that points to
+                                 * a valid condition_variable_t */
+
+typedef union {
+    unsigned long long ull;  
+    unsigned int ui[2];
+} val64;
+
+
+void cond_init (cond_ea_t  cond);
+void cond_signal (cond_ea_t cond);
+void cond_broadcast (cond_ea_t cond);
+void cond_wait (cond_ea_t cond, mutex_ea_t  mutex);
+
+
+#define MAX_THREADS_WAITING   32000 
+
+typedef unsigned long long completion_ea_t;
+
+extern void init_completion(completion_ea_t comp);
+extern void wait_for_completion(completion_ea_t comp);
+/*
+extern void wait_for_completion_irq(completion_ea_t comp);
+extern void wait_for_completion_irqsave(completion_ea_t comp);
+*/
+extern void complete_all(completion_ea_t comp);
+extern void complete (completion_ea_t comp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PPU_LIBSYNC_H_ */
diff --git a/gcell/ibm/sync/ppu_source/mutex.h b/gcell/ibm/sync/ppu_source/mutex.h
new file mode 100644 (file)
index 0000000..364bb22
--- /dev/null
@@ -0,0 +1,46 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_MUTEX_H_
+#define _PPU_MUTEX_H_           1
+
+typedef unsigned long long mutex_ea_t;
+
+#endif /* _PPU_MUTEX_H_ */
diff --git a/gcell/ibm/sync/ppu_source/mutex_init.h b/gcell/ibm/sync/ppu_source/mutex_init.h
new file mode 100644 (file)
index 0000000..105dc2c
--- /dev/null
@@ -0,0 +1,67 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_MUTEX_INIT_H_
+#define _PPU_MUTEX_INIT_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include "trace_libsync.h"
+
+/***************************************************************************/
+/**
+ * mutex_init - initialize the mutex by setting the value 
+ * to 0.
+ * @lock: handle to effective address of lock variable.
+ *
+ * Description: Initialize a mutex.
+ */
+static __inline void _mutex_init(mutex_ea_t lock)
+{
+  volatile unsigned int *p;
+
+  SYNC_ULL_TO_PTR(lock, p);
+
+  *p = 0;
+
+  TRACE_MUTEX_INIT(lock);
+}
+
+#endif /* _PPU_MUTEX_INIT_H_ */
diff --git a/gcell/ibm/sync/ppu_source/mutex_lock.h b/gcell/ibm/sync/ppu_source/mutex_lock.h
new file mode 100644 (file)
index 0000000..75240a1
--- /dev/null
@@ -0,0 +1,78 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_MUTEX_LOCK_H_
+#define _PPU_MUTEX_LOCK_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "mutex.h"
+#include "trace_libsync.h"
+
+/* function:   _mutex_lock
+ *
+ * Aquire a lock at a location in system memory by waiting for the
+ * value to become zero, then atomically storing 1. 
+ */
+static __inline void _mutex_lock (mutex_ea_t lock)
+{
+  unsigned int done = 0;
+  void *p;
+#ifdef LIBSYNC_TRACE
+  unsigned int miss = 0;
+#endif /* LIBSYNC_TRACE */
+
+  TRACE_MUTEX_LOCK_ENTRY(interval);
+
+  SYNC_ULL_TO_PTR(lock, p);
+
+  do {
+    if (__lwarx(p) == 0) done = __stwcx(p, (unsigned int) 1);
+#ifdef LIBSYNC_TRACE
+    /* if we missed the lock, note it.. */
+    if (done == 0) miss = 1;
+#endif
+  } while (done == 0);
+  __isync();
+
+  TRACE_MUTEX_LOCK_EXIT(interval, lock, miss);
+}
+
+#endif /* _PPU_MUTEX_LOCK_H_ */
diff --git a/gcell/ibm/sync/ppu_source/mutex_trylock.h b/gcell/ibm/sync/ppu_source/mutex_trylock.h
new file mode 100644 (file)
index 0000000..445196c
--- /dev/null
@@ -0,0 +1,81 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_MUTEX_TRYLOCK_H_
+#define _PPU_MUTEX_TRYLOCK_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "mutex.h"
+#include "trace_libsync.h"
+
+/**
+ * mutex_trylock - acquire a lock, or return immediately.
+ * @lock: handle to effective address of lock variable.
+ *
+ * Description: Acquire a lock, or return immediately 
+ * without polling for availability.
+ *
+ * Context: The application should not call this interface 
+ * from a tight loop!!  Use spin_lock() instead.
+ *
+ * Attempt to immediately aquire a lock at a location in system memory,
+ * and return 1 if the lock was aquired or 0 otherwise.
+ */
+static __inline int _mutex_trylock (mutex_ea_t lock)
+{
+  int val;
+  int ret = 0;
+  void *p;
+
+  SYNC_ULL_TO_PTR(lock, p);
+
+  do {
+    val = (int)__lwarx(p);
+    if (val) break;
+  } while ((ret = __stwcx(p, (unsigned int)1)) == 0);
+  __isync();
+
+  TRACE_MUTEX_TRYLOCK(lock,ret);
+
+  return (ret);
+}
+
+#endif /* _PPU_MUTEX_TRYLOCK_H_ */
diff --git a/gcell/ibm/sync/ppu_source/mutex_unlock.h b/gcell/ibm/sync/ppu_source/mutex_unlock.h
new file mode 100644 (file)
index 0000000..e5255be
--- /dev/null
@@ -0,0 +1,64 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_MUTEX_UNLOCK_H_
+#define _PPU_MUTEX_UNLOCK_H_
+
+#include "mutex.h"
+#include "atomic.h"
+#include "trace_libsync.h"
+
+/* function:   _mutex_unlock
+ *
+ * Release a lock held at address 'lock' in system memory.
+ * For the PU, this routine is the same _unlock, and is 
+ * provided here as a simple convenience for programmers 
+ * (to match the interfaces that are supported on the SPU).
+ * All I need to do is a store since store is an atomic operation by itself 
+ */
+static __inline void _mutex_unlock (mutex_ea_t lock)
+{
+  _atomic_replace ((atomic_ea_t)lock, 0);
+
+  TRACE_MUTEX_UNLOCK(lock); 
+}
+
+
+#endif /* _PPU_MUTEX_UNLOCK_H_ */
diff --git a/gcell/ibm/sync/ppu_source/pdt_libsync.xml b/gcell/ibm/sync/ppu_source/pdt_libsync.xml
new file mode 100644 (file)
index 0000000..d9ea2ce
--- /dev/null
@@ -0,0 +1,184 @@
+<pdtGroup name="LIBSYNC" id="0x03" version="3.0">
+       <!-- PPE events -->
+       <subGroup  name="PPE_MUTEX" id="0xFE03">
+               <recordType name="PPE_MUTEX_INIT" description="PPE: mutex lock init" id="0x0003" type="event">
+                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
+                       <physicalField name="lock"  description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>   
+               <recordType name="PPE_MUTEX_LOCK" description="PPE: acquire a mutex lock" id="0x0103"  type="interval">
+                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
+                       <physicalField name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField name="miss"   description="Missed" type="int" toString="0x%x" visible="true"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>
+               <recordType name="PPE_MUTEX_TRYLOCK" description="PPE: try to acquire a lock" id="0x0203"  type="event">
+                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
+                       <physicalField name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField  name="ret" description="Try lock return code" type="int" toString="0x%x" visible="true"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>   
+               <recordType name="PPE_MUTEX_UNLOCK" description="PPE: unlock a mutex lock" id="0x0303"  type="event">
+                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
+                       <physicalField  name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>
+       </subGroup>
+       <!-- SPE events -->
+       <subGroup  name="SPE_MUTEX" id="0xFD03">
+               <recordType name="SPE_MUTEX_INIT" description="SPE: mutex lock init" id="0x0403"  type="event">
+                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
+                       <physicalField  name="lock"  description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>   
+               <recordType name="SPE_MUTEX_LOCK" description="SPE: acquire a mutex lock" id="0x0503"  type="interval">
+                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
+                       <physicalField name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField name="miss"   description="Missed" type="int" toString="0x%x" visible="true"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>
+               <recordType name="SPE_MUTEX_TRYLOCK" description="SPE: try to acquire a mutex lock" id="0x0603"  type="event">
+                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
+                       <physicalField  name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField  name="ret_val" description="Try lock return code" type="int" toString="0x%x" visible="true"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>   
+               <recordType name="SPE_MUTEX_UNLOCK" description="SPE: unlock a mutex lock" id="0x0703"  type="event">
+                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
+                       <physicalField  name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
+                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
+                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
+               </recordType>   
+       </subGroup>
+</pdtGroup>
diff --git a/gcell/ibm/sync/ppu_source/pdt_libsync_config.xml b/gcell/ibm/sync/ppu_source/pdt_libsync_config.xml
new file mode 100644 (file)
index 0000000..a0b848d
--- /dev/null
@@ -0,0 +1,61 @@
+<pdt_configuration application_name="libsync" output_dir="." version="3.0">
+       <groups>
+               <group name="GENERAL" description="General event types" id="0x00">
+                       <view yStart="0.0" yEnd="0.2" color="0x0000FF"/>
+                       <include href="/usr/share/pdt/config/pdt_general.xml"/>
+               </group>
+               <group name="LIBSPE2" description="CBE libspe 2.0 event types" id="0x01">
+                       <view yStart="0.2" yEnd="0.4" color="0x00FFFF"/>
+                       <include href="/usr/share/pdt/config/pdt_libspe2.xml"/>
+               </group>
+               <group name="MFCIO" description="SPE MFCIO event types" id="0x02">
+                       <view yStart="0.4" yEnd="0.6" color="0x00FF80"/>
+                       <include href="/usr/share/pdt/config/pdt_mfcio.xml"/>
+               </group>
+               <group name="LIBSYNC" description="General event types" id="0x03">
+                       <view yStart="0.6" yEnd="0.8" color="0xFFFF00"/>                        
+                       <include href="/usr/share/pdt/config/pdt_libsync.xml"/>
+               </group>
+       </groups>
+<configuration name="CBE">
+<host name="none"/>
+<groupsControl>
+       <group name="GENERAL" active="true">            
+               <profile active="false"/>
+               <!--  The GENERAL group of events are always active-->
+       </group> 
+       <group name="LIBSPE2" active="true">
+       </group>
+       <group name="LIBSYNC" active="true">                    
+               <sub_group name="PPE_MUTEX" active="true">
+                       <event name="PPE_MUTEX_INIT" active="true"/>
+                       <event name="PPE_MUTEX_LOCK" active="true"/>
+                       <event name="PPE_MUTEX_TRYLOCK" active="true"/>
+                       <event name="PPE_MUTEX_UNLOCK" active="true"/>
+               </sub_group>
+       </group>
+</groupsControl>
+</configuration>
+<!-- -->
+<!-- SPEs configuration - this section is read with the CBE configuration -->
+<!-- -->
+<configuration name="SPE">
+<host name="CBE"/>
+<groupsControl>
+       <group name="GENERAL" active="true">                    
+               <profile active="false"/>
+               <!--  The GENERAL group of events are always active-->
+       </group>
+       <group name="MFCIO" active="true">
+       </group>
+       <group name="LIBSYNC" active="true">                    
+               <sub_group name="SPE_MUTEX" active="true">
+                       <event name="SPE_MUTEX_INIT" active="true"/>
+                       <event name="SPE_MUTEX_LOCK" active="true"/>
+                       <event name="SPE_MUTEX_TRYLOCK" active="true"/>
+                       <event name="SPE_MUTEX_UNLOCK" active="true"/>
+               </sub_group>
+       </group>                        
+</groupsControl>
+</configuration>
+</pdt_configuration>
diff --git a/gcell/ibm/sync/ppu_source/sync_utils.h b/gcell/ibm/sync/ppu_source/sync_utils.h
new file mode 100644 (file)
index 0000000..c7120a3
--- /dev/null
@@ -0,0 +1,73 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _PPU_SYNC_UTILS_H_
+#define _PPU_SYNC_UTILS_H_      1
+
+/* SYNC_ULL_TO_PTR - convert a 64-bit unsigned long long to a void 
+ *                   pointer.
+ */
+#ifdef __powerpc64__
+
+#define SYNC_ULL_TO_PTR(_ull, _ptr) {          \
+  union {                                      \
+    void *ptr;                                 \
+    unsigned long long ull;                    \
+  } _x;                                                \
+                                               \
+  _x.ull = _ull;                               \
+  _ptr = _x.ptr;                               \
+}
+
+#else
+
+#define SYNC_ULL_TO_PTR(_ull, _ptr) {          \
+  union {                                      \
+    void *ptr[2];                              \
+    unsigned long long ull;                    \
+  } _x;                                                \
+                                               \
+  _x.ull = _ull;                               \
+  _ptr = _x.ptr[1];                            \
+}
+
+#endif
+
+#endif /* _PPU_SYNC_UTILS_H_ */
diff --git a/gcell/ibm/sync/ppu_source/trace_libsync.h b/gcell/ibm/sync/ppu_source/trace_libsync.h
new file mode 100644 (file)
index 0000000..6d6f036
--- /dev/null
@@ -0,0 +1,117 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2007                                               */
+/* International Business Machines Corporation                     */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef __LIBSYNC_PPU_TRACEHOOKS_H__
+#define __LIBSYNC_PPU_TRACEHOOKS_H__
+
+#ifdef LIBSYNC_TRACE
+
+#include <trace_events.h>
+
+/*
+ *  last parameter in the trace_even and trace_interval_entry call is
+ *   the stack level to report the PC in the trace record. so 0 means
+ *   the PC of the current frame, 1 means the PC of the caller, etc.
+ *   there's a dilemma here - these macros are included in the inline
+ *   _mutex calls which get called from the (created during build)
+ *   mutex functions in the mutex .c files. in that case, the level
+ *   should be 1 - we don't want the PC of where in the mutex function
+ *   the trace call is happening, we want the PC of whomever is calling
+ *   the mutex function.
+ *
+ *   but.. an app can call the inline functions - it can #include the
+ *   appropriate libsync mutex .h files, and call the inlined _mutex
+ *   function in their code. in that case, the appropriate level for the
+ *   trace calls would be 0 - the user would want to know where in their
+ *   code the call to the _mutex function is.
+ *
+ *   so, we'll assume _LEVEL of 0 which is what the inline funtions need.
+ *   when we build the files for libsync, we'll do a -D_LEVEL=1 
+ */
+#ifndef _LEVEL
+#define _LEVEL 0
+#endif
+
+
+#define TRACE_EVENT_MUTEX_INIT 0x0003
+
+#define TRACE_MUTEX_INIT(lock) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(uint64_t)lock; \
+  trace_event(TRACE_EVENT_MUTEX_INIT, 1, &payload, "Event=%d, lock=0x%x",_LEVEL); \
+}
+
+#define TRACE_EVENT_MUTEX_LOCK 0x0103
+
+#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL) \
+trace_interval_p _INTERVAL = trace_interval_entry(TRACE_EVENT_MUTEX_LOCK, _LEVEL)
+
+#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(uint64_t)lock; \
+  payload.word[2]=(uint32_t)miss; \
+  trace_interval_exit(_INTERVAL, 2,  &payload, "Event=%d, lock=0x%x, miss=0x%x"); \
+}
+
+#define TRACE_EVENT_MUTEX_TRYLOCK 0x0203
+
+#define TRACE_MUTEX_TRYLOCK(lock,ret) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(uint64_t)lock; \
+  payload.word[2]=(uint32_t)ret; \
+  trace_event(TRACE_EVENT_MUTEX_TRYLOCK, 2, &payload, "Event=%d, lock=0x%x, ret=0x%x", _LEVEL); \
+}
+
+#define TRACE_EVENT_MUTEX_UNLOCK 0x0303
+
+#define TRACE_MUTEX_UNLOCK(lock) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(uint64_t)lock; \
+  trace_event(TRACE_EVENT_MUTEX_UNLOCK, 1, &payload, "Event=%d, lock=0x%x", _LEVEL); \
+}
+
+#else /* LIBSYNC_TRACE */
+
+#define TRACE_MUTEX_INIT(lock)
+#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL)
+#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss)
+#define TRACE_MUTEX_TRYLOCK(lock,ret_val)
+#define TRACE_MUTEX_UNLOCK(lock)
+
+#endif /* LIBSYNC_TRACE */
+
+#endif  /* __LIBSYNC_PPU_TRACEHOOKS_H__ */
diff --git a/gcell/ibm/sync/ppu_source/wait_for_completion.h b/gcell/ibm/sync/ppu_source/wait_for_completion.h
new file mode 100644 (file)
index 0000000..f2b0427
--- /dev/null
@@ -0,0 +1,75 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+
+#ifndef _PPU_WAIT_FOR_COMPLETION_H_
+#define _PPU_WAIT_FOR_COMPLETION_H_
+
+#include <ppu_intrinsics.h>
+#include "sync_utils.h"
+#include "completion.h"
+
+
+/**
+ * completion_wait - wait until a completion is broadcast.
+ * @comp: handle to effective address of completion variable.
+ *
+ * Description: Wait until another processor or device signals
+ * that a completionition is 'true'.  The only restriction here is 
+ * that @comp must be a word aligned address.
+ *
+ * Beware: This function hot polls waiting for completion.
+ */
+static __inline void _wait_for_completion(completion_ea_t comp)
+{
+  int val;
+  void *p;
+
+  SYNC_ULL_TO_PTR(comp, p);
+
+  do {
+    val = (int)__lwarx(p);
+    if (val != 1) val = (int)__stwcx(p, (unsigned int)0);
+  } while (val == 0);
+  __isync();
+}
+
+
+#endif /* _PPU_WAIT_FOR_COMPLETION_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic.h b/gcell/ibm/sync/spu_source/atomic.h
new file mode 100644 (file)
index 0000000..951c26e
--- /dev/null
@@ -0,0 +1,101 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+/*
+ * atomic.h - SPU atomic SHM counter operations.
+ *
+ * Interfaces patterned after, and hopefully compatible
+ * with PowerPC64-Linux atomic counter operations.  Uses
+ * 32b values for various counters.
+ */
+#ifndef _SPU_ATOMIC_H_
+#define _SPU_ATOMIC_H_
+
+#include <sync_utils.h>
+#include <spu_mfcio.h>
+
+
+/* atomic_eaddr_t is a 64bit effective address 
+ * that points to an atomic_t variable */
+typedef unsigned long long atomic_ea_t;
+
+#define DECL_ATOMIC_VARS()                              \
+    char _tmp[256];                                    \
+    char *tmp = (char *) ALIGN(_tmp, 128);             \
+    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
+    u32 size = 128, tagid = 0;                          \
+    s32 ret_val;                                       \
+    u32 offset;                                         \
+    addr64 ea64
+
+/* __atomic_op                                              
+*    Internal routine to acquire lock line reservation
+*    then conditionally modify the counter variable 
+*    pointed to by 'v'.  The 'replace' flag indicates 
+*    whether or not this is to be an arithmetic R-M-W
+*    or a simple replace operation.
+*/
+#define ATOMIC_OP(__v, __val, __replace, __final_val)           \
+{                                                               \
+    char __tmp[256];                                            \
+    char *_tmp = (char *) ALIGN(__tmp, 128);                   \
+    volatile s32 *_buf = (volatile s32 *) &_tmp[0];             \
+    u32 _size = 128, _tagid = 0;                                \
+    s32 _status, _ret_val;                                      \
+    u32 _offset;                                                \
+    addr64 _ea64;                                               \
+                                                                \
+    _ea64.ull = ALIGN128_EA(__v);                               \
+    _offset = OFFSET128_EA_U32(__v);                            \
+    do {                                                        \
+       MFC_DMA(_buf, _ea64, _size, _tagid, MFC_GETLLAR_CMD);   \
+        spu_readch (MFC_RdAtomicStat);                          \
+                                                                \
+       _ret_val = _buf[_offset];                                \
+       _buf[_offset] = (__replace) ? __val : _ret_val + __val;    \
+       MFC_DMA(_buf, _ea64, _size, _tagid, MFC_PUTLLC_CMD);    \
+       _status = spu_readch(MFC_RdAtomicStat);                  \
+    } while (_status != 0);                                     \
+                                                                \
+    __final_val = _ret_val;                                     \
+}                                                               
+
+#endif /* _SPU_ATOMIC_H_ */
+
diff --git a/gcell/ibm/sync/spu_source/atomic_add.h b/gcell/ibm/sync/spu_source/atomic_add.h
new file mode 100644 (file)
index 0000000..7606ae0
--- /dev/null
@@ -0,0 +1,62 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_ADD_H_
+#define _SPU_ATOMIC_ADD_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_add - atomically add to a counter.
+ * @v: handle to effective address of counter.
+ * @a: value to be added.
+ * 
+ * Atomically add a value to a counter in system memory. 
+ * The only restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_add(int a, atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP (v, a, 0, ret_val);
+}
+
+
+#endif /* _SPU_ATOMIC_ADD_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_add_return.h b/gcell/ibm/sync/spu_source/atomic_add_return.h
new file mode 100644 (file)
index 0000000..35f07ad
--- /dev/null
@@ -0,0 +1,69 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_ADD_RETURN_H_
+#define _SPU_ATOMIC_ADD_RETURN_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+/**
+ * atomic_add_return - atomically add to a counter and return previous value.
+ * @v: handle to effective address of counter.
+ * @a: value to be added.
+ *
+ * Atomically add a value to a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ *
+ * This routine implements the "fetch and add" primitive
+ * that is described in "Book I PowerPC User Instruction
+ * Set Architecture", but uses MFC lock line reservation
+ * operations instead of lwarx/stwcx.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_add_return(int a, atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP(v, a, 0, ret_val);
+    return ret_val;
+}
+
+
+#endif /* _SPU_ATOMIC_ADD_RETURN_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_dec.h b/gcell/ibm/sync/spu_source/atomic_dec.h
new file mode 100644 (file)
index 0000000..30ca7c5
--- /dev/null
@@ -0,0 +1,61 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_DEC_H_
+#define _SPU_ATOMIC_DEC_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_dec - atomically decrement a counter.
+ * @v: handle to effective address of location to be modified.
+ *
+ * Atomically decrement a counter in system memory. The only
+ * restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_dec(atomic_ea_t v)
+{    
+    int ret_val;
+    ATOMIC_OP (v, -1, 0, ret_val);
+}
+
+
+#endif /* _SPU_ATOMIC_DEC_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_dec_and_test.h b/gcell/ibm/sync/spu_source/atomic_dec_and_test.h
new file mode 100644 (file)
index 0000000..b3c8298
--- /dev/null
@@ -0,0 +1,64 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_DEC_AND_TEST_H_
+#define _SPU_ATOMIC_DEC_AND_TEST_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_dec_and_test - atomically decrement and test if previous==0.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically decrement a counter in system memory and test 
+ * if previous==0.  The only restriction is that @v must be 
+ * word aligned.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_dec_and_test(atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP(v, -1, 0, ret_val);
+    return (ret_val == 0) ? 1 : 0;
+}
+
+#endif /* _SPU_ATOMIC_DEC_AND_TEST_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_dec_if_positive.h b/gcell/ibm/sync/spu_source/atomic_dec_if_positive.h
new file mode 100644 (file)
index 0000000..2a01ec3
--- /dev/null
@@ -0,0 +1,86 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_DEC_IF_POSITIVE_H_
+#define _SPU_ATOMIC_DEC_IF_POSITIVE_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_dec_if_positive - atomically decrement if counter is positive.
+ * @v: handle to effective address of counter.
+ * 
+ * Atomically decrement a counter if its value is positive.
+ * The only restriction is that @v must be word aligned.
+ *
+*
+ * Returns the old value of the counter, minus 1.
+ */
+static __inline int _atomic_dec_if_positive(atomic_ea_t v)
+{
+    DECL_ATOMIC_VARS();
+    s32 status;
+
+    ea64.ull = ALIGN128_EA(v);
+    offset = OFFSET128_EA_U32(v);
+    do {
+       MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+       spu_readch(MFC_RdAtomicStat);
+
+       ret_val = buf[offset] - 1;
+       if (likely(ret_val >= 0)) {
+           buf[offset] = ret_val;
+           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
+           status = spu_readch(MFC_RdAtomicStat);
+       } else {
+           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
+           spu_readch(MFC_RdAtomicStat);
+           status = 0;
+           break;
+       }
+    } while (status != 0);
+
+    return ret_val;
+}
+
+
+
+#endif /* _SPU_ATOMIC_DEC_IF_POSITIVE_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_dec_return.h b/gcell/ibm/sync/spu_source/atomic_dec_return.h
new file mode 100644 (file)
index 0000000..45effb6
--- /dev/null
@@ -0,0 +1,70 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_DEC_RETURN_H_
+#define _SPU_ATOMIC_DEC_RETURN_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_dec_return - atomically decrement a counter and return previous value.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically decrement a counter in system memory and return its
+ * previous value. The only restriction is that @v must be word 
+ * aligned.
+ *
+ * This routine implements the "fetch and decrement"
+ * primitive that is described in "Book I PowerPC User
+ * Instruction Set Architecture", but uses MFC lock line
+ * reservation operations instead of lwarx/stwcx.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_dec_return(atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP(v, -1, 0, ret_val);
+    return ret_val;
+}
+
+
+#endif /* _SPU_ATOMIC_DEC_RETURN_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_inc.h b/gcell/ibm/sync/spu_source/atomic_inc.h
new file mode 100644 (file)
index 0000000..6800efe
--- /dev/null
@@ -0,0 +1,61 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_INC_H_
+#define _SPU_ATOMIC_INC_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_inc - atomically increment a counter in system memory.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically increment a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_inc(atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP (v, 1, 0, ret_val);
+}
+
+
+#endif /* _SPU_ATOMIC_INC_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_inc_return.h b/gcell/ibm/sync/spu_source/atomic_inc_return.h
new file mode 100644 (file)
index 0000000..89361a0
--- /dev/null
@@ -0,0 +1,70 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_INC_RETURN_H_
+#define _SPU_ATOMIC_INC_RETURN_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+
+/**
+ * atomic_inc_return - atomically increment a counter and return previous.
+ * @v: handle to effective address of counter.
+ *
+ * Atomically increment a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ *
+ * This routine implements the "fetch and increment"
+ * primitive that is described in "Book I PowerPC User
+ * Instruction Set Architecture", but uses MFC lock line
+ * reservation operations instead of lwarx/stwcx.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_inc_return(atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP(v, 1, 0, ret_val);
+    return ret_val;
+}
+
+
+#endif /* _SPU_ATOMIC_INC_RETURN_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_read.h b/gcell/ibm/sync/spu_source/atomic_read.h
new file mode 100644 (file)
index 0000000..711a0ad
--- /dev/null
@@ -0,0 +1,78 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_READ_H_
+#define _SPU_ATOMIC_READ_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_read - read an atomic counter.
+ * @v: handle to effective address of counter.
+ *
+ * Read the current value of an atomic counter.
+ */
+static __inline int _atomic_read(atomic_ea_t v)
+{
+    DECL_ATOMIC_VARS();
+
+    /* reserve a tag for use */
+    tagid = mfc_tag_reserve();
+
+    u32 oldtmask, tagmask = 1 << (tagid & 31);
+
+    ea64.ull = ALIGN128_EA(v);
+    offset = OFFSET128_EA_U32(v);
+
+    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
+    oldtmask = spu_readch(MFC_RdTagMask);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+    spu_writech(MFC_WrTagMask, oldtmask);
+
+    mfc_tag_release (tagid);
+    ret_val =  buf[offset];
+    return ret_val;
+}
+
+
+#endif /* _SPU_ATOMIC_READ_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_set.h b/gcell/ibm/sync/spu_source/atomic_set.h
new file mode 100644 (file)
index 0000000..261d28a
--- /dev/null
@@ -0,0 +1,68 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_SET_H_
+#define _SPU_ATOMIC_SET_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_set - atomically set a counter in system memory.
+ * @v: handle to effective address of counter.
+ * 
+ * Atomically set a counter to a given value. The only 
+ * restriction is that @v must be word aligned.
+ *
+ * This routine implements the "fetch and store" 
+ * primitive that is described in "Book I PowerPC User 
+ * Instruction Set Architecture", but uses MFC lock line
+ * reservation operations instead of lwarx/stwcx. 
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline void _atomic_set(atomic_ea_t v, int val)
+{
+    int ret_val;
+    ATOMIC_OP(v, val, 1, ret_val);
+}
+
+
+#endif /* _SPU_ATOMIC_SET_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_sub.h b/gcell/ibm/sync/spu_source/atomic_sub.h
new file mode 100644 (file)
index 0000000..f366e1d
--- /dev/null
@@ -0,0 +1,64 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_SUB_H_
+#define _SPU_ATOMIC_SUB_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_sub - atomically subtract from a counter.
+ * @v: handle to effective address of counter.
+ * @a: value to be subtracted.
+ *
+ * Atomically subtract a value from a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ */
+static __inline void _atomic_sub(int a, atomic_ea_t v)
+{
+    int ret_val;
+
+    ATOMIC_OP (v, -a, 0, ret_val);
+}
+
+
+
+#endif /* _SPU_ATOMIC_SUB_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_sub_and_test.h b/gcell/ibm/sync/spu_source/atomic_sub_and_test.h
new file mode 100644 (file)
index 0000000..fe5824a
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_SUB_AND_TEST_H_
+#define _SPU_ATOMIC_SUB_AND_TEST_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+/**
+ * atomic_sub_and_test - atomically subtract and test if previous==0.
+ * @v: handle to effective address of counter.
+ * @a: value to be subtracted.
+ *
+ * Atomically subtract a value from a counter in system memory
+ * and test if previous==0.  The only restriction is that @v 
+ * must be word aligned.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_sub_and_test(int a, atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP(v, -a, 0, ret_val);
+    return (ret_val == 0) ? 1 : 0;
+}
+
+
+#endif /* _SPU_ATOMIC_SUB_AND_TEST_H_ */
diff --git a/gcell/ibm/sync/spu_source/atomic_sub_return.h b/gcell/ibm/sync/spu_source/atomic_sub_return.h
new file mode 100644 (file)
index 0000000..5dbed5b
--- /dev/null
@@ -0,0 +1,69 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_ATOMIC_SUB_RETURN_H_
+#define _SPU_ATOMIC_SUB_RETURN_H_
+
+#include <sync_utils.h>
+#include <atomic.h>
+
+
+/**
+ * atomic_sub_return - atomically subtract from a counter & return previous.
+ * @v: handle to effective address of counter.
+ * @a: value to be subtracted.
+ *
+ * Atomically subtract a value from a counter in system memory.
+ * The only restriction is that @v must be word aligned.
+ *
+ * Returns the previous value from system memory.
+ */
+static __inline int _atomic_sub_return(int a, atomic_ea_t v)
+{
+    int ret_val;
+    ATOMIC_OP(v, -a, 0, ret_val);
+    return ret_val;
+    //return __atomic_op(v, -a, 0);
+}
+
+
+
+
+#endif /* _SPU_ATOMIC_SUB_RETURN_H_ */
diff --git a/gcell/ibm/sync/spu_source/complete.h b/gcell/ibm/sync/spu_source/complete.h
new file mode 100644 (file)
index 0000000..6a78086
--- /dev/null
@@ -0,0 +1,67 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COMPLETE_H_
+#define _SPU_COMPLETE_H_
+
+#include "sync_utils.h"
+#include <spu_mfcio.h>
+#include "completion.h"
+
+static __inline void _complete(completion_ea_t completion)
+{
+    DECL_COMPLETION_VARS();
+
+    ea64.ull = ALIGN128_EA(completion);
+    offset = OFFSET128_EA_U32(completion);
+    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+    spu_readch(MFC_RdAtomicStat);
+
+    /* set the completionition variable to exactly one so
+     * only one thread can be awaken */
+    buf[offset] = 1;
+    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
+    spu_readch(MFC_RdAtomicStat);
+}
+
+
+
+
+#endif /* _SPU_COMPLETE_H_ */
diff --git a/gcell/ibm/sync/spu_source/complete_all.h b/gcell/ibm/sync/spu_source/complete_all.h
new file mode 100644 (file)
index 0000000..5f9c3dc
--- /dev/null
@@ -0,0 +1,74 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COMPLETE_ALL_H_
+#define _SPU_COMPLETE_ALL_H_
+
+#include "sync_utils.h"
+#include <spu_mfcio.h>
+#include "completion.h"
+
+/**
+ * completion_broadcast - indicate that a completion is true.
+ * @completion: handle to effective address of completion variable.
+ *
+ * Indicate that a completionition is true by storing '1' to the
+ * completionition variable.
+ */
+static __inline void _complete_all(completion_ea_t completion)
+{
+    DECL_COMPLETION_VARS();
+
+    ea64.ull = ALIGN128_EA(completion);
+    offset = OFFSET128_EA_U32(completion);
+    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+    spu_readch(MFC_RdAtomicStat);
+
+    /* set the completionition variable to the count. So that
+     * all the threads  */
+    buf[offset] = MAX_THREADS_WAITING;
+    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
+    spu_readch(MFC_RdAtomicStat);
+}
+
+
+
+
+#endif /* _SPU_COMPLETE_ALL_H_ */
diff --git a/gcell/ibm/sync/spu_source/completion.h b/gcell/ibm/sync/spu_source/completion.h
new file mode 100644 (file)
index 0000000..4a302d2
--- /dev/null
@@ -0,0 +1,68 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+/*
+ * cond.h - simple condition wait & broadcast operations.
+ *
+ * Interrupt aware versions of the routines are supported.
+ * Applications should call either '_irq' or '_irqsave'
+ * forms of the functions when interrupts are enabled.
+ */
+
+#ifndef __SPU_COMPLETION_H__
+#define __SPU_COMPLETION_H__
+
+#include "sync_utils.h"
+
+#define MAX_THREADS_WAITING   32000 
+typedef unsigned long long completion_ea_t;
+
+
+#define DECL_COMPLETION_VARS()                                \
+    char _tmp[256];                                     \
+    char *tmp = (char *) ALIGN(_tmp, 128);              \
+    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
+    u32 size = 128, tagid = 0;                          \
+    u32 offset;                                         \
+    addr64 ea64
+
+
+
+#endif /* __SPU_COMPLETION_H__ */
diff --git a/gcell/ibm/sync/spu_source/cond.h b/gcell/ibm/sync/spu_source/cond.h
new file mode 100644 (file)
index 0000000..ceb3285
--- /dev/null
@@ -0,0 +1,69 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COND_VAR_H_
+#define _SPU_COND_VAR_H_
+
+#include "sync_utils.h"
+typedef struct
+{
+  int num_threads_signal;       /* the number of threads that are going to be waken up.
+                                 There are 3 values possible for this parameter, 0, 1, 
+                                 or num_threads_waiting*/
+  int num_threads_waiting;      /* the number of threads that are waiting to be awaken */ 
+} condition_variable_t __attribute__ ((aligned (128)));  
+
+typedef eaddr_t cond_ea_t;         /* a system memory 64 bit address that points to
+                                 * a valid condition_variable_t */
+
+
+
+
+#define DECL_COND_VARS()                                \
+    char _tmp[256];                                     \
+    char *tmp = (char *) ALIGN(_tmp, 128);              \
+    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
+    u32 size = 128, tagid = 0;                          \
+    s32 status, ret_val;                                \
+    u32 offset;                                         \
+    addr64 ea64;                                        \
+    condition_variable_t cond_var
+
+#endif /* _SPU_COND_VAR_H_ */
diff --git a/gcell/ibm/sync/spu_source/cond_broadcast.h b/gcell/ibm/sync/spu_source/cond_broadcast.h
new file mode 100644 (file)
index 0000000..15a1da3
--- /dev/null
@@ -0,0 +1,73 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COND_BROADCAST_H_
+#define _SPU_COND_BROADCAST_H_
+
+#include "sync_utils.h"
+#include "cond.h"
+#include <spu_mfcio.h>
+
+/**
+ * cond_broadcast - indicate that a condition is true.
+ * @cond: handle to effective address of condition variable.
+ */
+static __inline void _cond_broadcast(cond_ea_t cond)
+{
+    char _tmp[256];                                     
+    char *tmp = (char *) ALIGN(_tmp, 128);              
+    volatile unsigned short *buf = (volatile unsigned short *) &tmp[0];       
+    unsigned int size = 128, tagid = 0;                          
+    u32 offset;                                         
+    addr64 ea64;          
+
+    ea64.ull = ALIGN128_EA(cond);
+    offset = OFFSET128_EA_U16(cond);
+    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+    spu_readch(MFC_RdAtomicStat);
+
+    /* set the condition variable to the count. So that
+     * all the threads  */
+    buf[offset] = buf[offset + 1];
+    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
+    spu_readch(MFC_RdAtomicStat);
+}
+
+#endif /* _SPU_COND_BROADCAST_H_ */
diff --git a/gcell/ibm/sync/spu_source/cond_init.h b/gcell/ibm/sync/spu_source/cond_init.h
new file mode 100644 (file)
index 0000000..7202e53
--- /dev/null
@@ -0,0 +1,127 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COND_INIT_H_
+#define _SPU_COND_INIT_H_
+
+#include "sync_utils.h"
+#include "cond.h"
+#include <spu_mfcio.h>
+
+
+/**
+ * cond_init - initialize condition variable.
+ * @cond: handle to effective address of condition variable.
+ *
+ *
+ * Conditional Variable - is a synchronization device that allows 
+ * SPE and PPE threads to suspend execution and relinquish the 
+ * processors until some predicate on shared data is satisfied. 
+ * The basic operations on conditions are: signal the condition
+ * (when the predicate becomes true), and wait for the condition,
+ * suspending the thread execution until anoter thread signals the
+ * condition
+ *
+ * A condition variable must always be associated with a mutex, to
+ * avoid the race condition where a thread prepares to wait on a 
+ * condition variable and another thread signals the condition just
+ * before the first thread actually waits on it.
+ *
+ * cond_init initializes the condition variable cond. 
+ *
+ * cond_signal restarts one of the threads that are waiting on the
+ * condition variable cond. If no threads are waiting on cond, nothing
+ * happens. If several threads are waiting on cond, exactly one
+ * is restarted, but it is not specified which
+ *
+ * cond_broadcast restarts all the threads that are waiting on the 
+ * condition variable cond. Nothing happens if no threads are waiting
+ * on cond
+ *
+ * cond_wait atomically unlocks the mutex and waits for the condition
+ * variable cond to be signaled. The mutex must be lock locked by 
+ * the calling thread on the entrance to cond_wait. Before returning
+ * to the calling thread, cond_wait re-acquires mutex. 
+ *
+ * Only one thread initializes a condition variable. Usually, the 
+ * PPE thread initializes a condidtion variable, however, a cond_init
+ * function is provided here for completeness
+ *
+ * Description: Initialize a cond variable to false.
+ */
+static __inline void _cond_init(cond_ea_t cond )
+{
+    char _tmp[256];                                     
+    char *tmp = (char *) ALIGN(_tmp, 128);              
+    volatile unsigned short *buf = (volatile unsigned short *) &tmp[0];       
+    unsigned int size = 128, tagid;                          
+    unsigned int offset;           
+    addr64 ea64;
+    unsigned int oldtmask;
+    unsigned int tagmask;    
+
+    tagid = mfc_tag_reserve(); 
+
+    tagmask = 1 << (tagid & 31);
+
+    ea64.ull = ALIGN128_EA(cond);
+    offset = OFFSET128_EA_U16(cond);
+
+    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
+    oldtmask = spu_readch(MFC_RdTagMask);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+
+    /* this is still just one word. since buf is of type
+     * short, we fit both counts into one word. */
+    buf[offset] = 0;
+    buf[offset+1] = 0;
+    MFC_DMA(buf, ea64, size, (tagid & 31), MFC_PUT_CMD);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+    spu_writech(MFC_WrTagMask, oldtmask);
+    mfc_tag_release (tagid);
+}
+
+
+
+#endif /* _SPU_COND_INIT_H_ */
diff --git a/gcell/ibm/sync/spu_source/cond_signal.h b/gcell/ibm/sync/spu_source/cond_signal.h
new file mode 100644 (file)
index 0000000..a035d28
--- /dev/null
@@ -0,0 +1,88 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COND_SIGNAL_H_
+#define _SPU_COND_SIGNAL_H_
+#include <stdio.h>
+#include "sync_utils.h"
+#include "cond.h"
+#include "atomic.h"
+#include <spu_mfcio.h>
+
+/*
+ * _cond_signal: signalling any of the waiting threads to wake up.
+ */ 
+static __inline void _cond_signal(cond_ea_t cond)
+{
+    char _tmp[256];                                     
+    char *tmp = (char *) ALIGN(_tmp, 128);              
+    volatile unsigned short *buf = (volatile unsigned short *) &tmp[0];       
+    unsigned int size = 128, tagid = 0;                          
+    u32 offset;                                         
+    addr64 ea64;                                      
+    int status;
+
+    ea64.ull = ALIGN128_EA(cond);
+    offset = OFFSET128_EA_U16(cond);
+
+    do {
+      MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+      (void)spu_readch(MFC_RdAtomicStat);
+
+      /* Check for waiting threads.
+       */
+      if (buf[offset] != buf[offset+1]) {
+       /* Increment the signaled count to release the next waiting
+        * thread.
+        */
+       buf[offset]++;
+
+       MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
+       status = spu_readch(MFC_RdAtomicStat);
+      } else {
+       /* Nobody is waiting, do nothing.
+        */
+       status = 0;
+      }
+    } while (status);
+}
+
+
+#endif /* _SPU_COND_SIGNAL_H_ */
diff --git a/gcell/ibm/sync/spu_source/cond_wait.h b/gcell/ibm/sync/spu_source/cond_wait.h
new file mode 100644 (file)
index 0000000..cf4b880
--- /dev/null
@@ -0,0 +1,103 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_COND_WAIT_H_
+#define _SPU_COND_WAIT_H_
+#include <stdio.h>
+#include "sync_irq.h"
+#include "sync_utils.h"
+#include "mutex_lock.h"
+#include "mutex_unlock.h"
+#include "cond.h"
+#include <spu_mfcio.h>
+
+static __inline void _cond_wait (cond_ea_t cond, mutex_ea_t  mutex)
+{
+    char _tmp[256];                                     
+    char *tmp = (char *) ALIGN(_tmp, 128);              
+    volatile signed short *buf = (volatile signed short *) &tmp[0];       
+    unsigned int size = 128, tagid = 0;                          
+    int status;                                
+    unsigned int offset;                                         
+    addr64 ea64;  
+    signed short delta, cur_delta, signaled_cnt;
+
+    ea64.ull = ALIGN128_EA(cond);
+    offset = OFFSET128_EA_U16(cond);
+
+    /* increment the waiting halfword of the condition variable.
+     */
+    do {
+      MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+      (void)spu_readch(MFC_RdAtomicStat);
+
+      buf[offset+1]++;
+      
+      MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
+      status = spu_readch(MFC_RdAtomicStat); 
+    } while (status);
+
+    _mutex_unlock(mutex);
+
+    /* keep track of the change in count needed to be signaled. This 
+     * is delta.
+     */
+    signaled_cnt = buf[offset];
+    delta = buf[offset+1] - signaled_cnt;
+    if (delta < 0) delta = -delta;
+
+    while (1) {
+      MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+      (void)spu_readch(MFC_RdAtomicStat);
+
+      cur_delta = buf[offset] - signaled_cnt;
+      if (cur_delta < 0) cur_delta = -cur_delta;
+
+
+      if (cur_delta >= delta) {
+       /* the counts indicate that this thread has been signaled.
+        */
+       break;
+      } 
+    } 
+    _mutex_lock (mutex);
+}
+
+#endif /* _SPU_COND_WAIT_H_ */
diff --git a/gcell/ibm/sync/spu_source/init_completion.h b/gcell/ibm/sync/spu_source/init_completion.h
new file mode 100644 (file)
index 0000000..bf93e72
--- /dev/null
@@ -0,0 +1,82 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_INIT_COMPLETION_H_
+#define _SPU_INIT_COMPLETION_H_
+
+#include "sync_utils.h"
+#include <spu_mfcio.h>
+#include "completion.h"
+
+/**
+ * completion_init - initialize completion variable.
+ * @completion: handle to effective address of completion variable.
+ *
+ * Description: Initialize a completion variable to false.
+ */
+static __inline void _init_completion(completion_ea_t completion)
+{
+    DECL_COMPLETION_VARS();
+    u32 oldtmask, tagmask;
+   
+    tagid = mfc_tag_reserve();
+    tagmask = 1 << (tagid & 31);
+
+    ea64.ull = ALIGN128_EA(completion);
+    offset = OFFSET128_EA_U32(completion);
+
+    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
+    oldtmask = spu_readch(MFC_RdTagMask);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+
+    buf[offset] = 0;
+    MFC_DMA(buf, ea64, size, tagid & 31, MFC_PUT_CMD);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+    spu_writech(MFC_WrTagMask, oldtmask);
+    mfc_tag_release(tagid);
+}
+
+
+
+#endif /* _SPU_INIT_COMPLETION_H_ */
diff --git a/gcell/ibm/sync/spu_source/libsync.h b/gcell/ibm/sync/spu_source/libsync.h
new file mode 100644 (file)
index 0000000..48cc722
--- /dev/null
@@ -0,0 +1,116 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_LIB_SYNC_H_
+#define _SPU_LIB_SYNC_H_
+#include "sync_utils.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned long long atomic_ea_t;
+
+extern void atomic_set(atomic_ea_t v, int val);
+extern void atomic_add(int a, atomic_ea_t v);
+extern void atomic_sub(int a, atomic_ea_t v);
+extern void atomic_inc(atomic_ea_t v);
+extern void atomic_dec(atomic_ea_t v);
+
+extern int atomic_read(atomic_ea_t v);
+extern int atomic_add_return(int a, atomic_ea_t v);
+extern int atomic_sub_return(int a, atomic_ea_t v);
+extern int atomic_inc_return(atomic_ea_t v);
+extern int atomic_dec_return(atomic_ea_t v);
+extern int atomic_sub_and_test(int a, atomic_ea_t v);
+extern int atomic_dec_and_test(atomic_ea_t v);
+extern int atomic_dec_if_positive(atomic_ea_t v);
+
+typedef unsigned long long mutex_ea_t;
+
+extern void mutex_init(mutex_ea_t lock);
+extern void mutex_lock(mutex_ea_t lock);
+extern int mutex_trylock(mutex_ea_t ea);
+extern void mutex_unlock(mutex_ea_t lock);
+
+
+typedef struct
+{
+  int num_threads_signal;       /* the number of threads that are going to be waken up.
+                                * There are 3 values possible for this parameter, 0, 1, 
+                                 * or num_threads_waiting
+                                */
+  int num_threads_waiting;      /* the number of threads that are waiting to be awaken 
+                                */ 
+} condition_variable_t __attribute__ ((aligned (128)));  
+
+typedef eaddr_t cond_ea_t;     /* a system memory 64 bit address that points to
+                                * a valid condition_variable_t 
+                                */
+
+
+extern void cond_init (cond_ea_t  cond);
+extern void cond_signal (cond_ea_t cond);
+extern void cond_broadcast (cond_ea_t cond);
+extern void cond_wait (cond_ea_t cond, mutex_ea_t  mutex);
+
+typedef unsigned long long completion_ea_t;
+
+extern void init_completion(completion_ea_t completion);
+extern void wait_for_completion(completion_ea_t completion);
+extern void complete(completion_ea_t completion);
+extern void complete_all(completion_ea_t completion);
+
+#ifdef __SPU__
+  /* Function only implemented for the SPU
+   */
+  extern void read_lock(eaddr_t ea);
+  extern void read_unlock(eaddr_t ea);
+  extern int  read_trylock(eaddr_t ea);
+  extern void write_lock(eaddr_t ea);
+  extern void write_unlock(eaddr_t ea);
+  extern int  write_trylock(eaddr_t ea);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SPU_LIB_SYNC_H_ */
diff --git a/gcell/ibm/sync/spu_source/mutex.h b/gcell/ibm/sync/spu_source/mutex.h
new file mode 100644 (file)
index 0000000..37f2b4d
--- /dev/null
@@ -0,0 +1,178 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_MUTEX_H_
+#define _SPU_MUTEX_H_           1
+
+#include "sync_utils.h"
+#include "sync_irq.h"
+#include <spu_mfcio.h>
+
+typedef eaddr_t mutex_ea_t;
+
+#define DECL_MUTEX_VARS()                               \
+    char _tmp[256];                                     \
+    char *tmp = (char *) ALIGN(_tmp, 128);              \
+    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
+    u32 size = 128, tagid = 0;                          \
+    u32 offset;                                         \
+    addr64 ea64
+
+/* RAW_TEST_AND_SET
+ *    Macro implementing the test and set primitive.
+ *
+ *    RAW_TEST_AND_SET(==, 1)  used by spin_try_lock()
+ *    RAW_TEST_AND_SET(>=, 1)  used by read_try_lock()
+ *    RAW_TEST_AND_SET(==, -1) used by write_try_lock()
+ */
+#define RAW_TEST_AND_SET(_RELOP_, _val)                                \
+    ea64.ull = ALIGN128_EA(ea);                                        \
+    offset = OFFSET128_EA_U32(ea);                             \
+    do {                                                       \
+        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);      \
+        spu_readch(MFC_RdAtomicStat);                          \
+        SET_HIT;                                               \
+        if (likely(buf[offset] _RELOP_ 0)) {                   \
+            buf[offset] += _val;                               \
+           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);    \
+            status = spu_readch(MFC_RdAtomicStat);             \
+            ret_val = 1;                                       \
+        } else {                                               \
+           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);    \
+            spu_readch(MFC_RdAtomicStat);                      \
+            status = ret_val = 0;                              \
+            break;                                             \
+        }                                                      \
+    } while (status != 0)
+
+/* RAW_SPINLOCK
+ *    Macro implementing the spinlock primitive.
+ *
+ *    RAW_SPINLOCK(==, 1)      used by spin_lock()
+ *    RAW_SPINLOCK(>=, 1)      used by read_lock()
+ *    RAW_SPINLOCK(==, -1)     used by write_lock()
+ */
+
+
+#define RAW_SPINLOCK(_RELOP_, _val)                            \
+    ea64.ull = ALIGN128_EA(ea);                                        \
+    offset = OFFSET128_EA_U32(ea);                             \
+    do {                                                       \
+        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);      \
+        spu_readch(MFC_RdAtomicStat);                          \
+        SET_HIT;                                               \
+        status = 1;                                            \
+        if (likely(buf[offset] _RELOP_ 0)) {                   \
+            buf[offset] += _val;                               \
+           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);    \
+            status = spu_readch(MFC_RdAtomicStat);             \
+        }                                                      \
+    } while (status != 0);
+
+
+static inline void _lock_init(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    u32 oldtmask, tagmask;
+  
+    tagid = mfc_tag_reserve(); 
+   
+    tagmask = 1 << (tagid & 31);
+
+    /* __lock_init
+     *    Internal routine to initialize a spinlock or
+     *    reader/writer lock.
+     */
+    ea64.ull = ALIGN128_EA(ea);
+    offset = OFFSET128_EA_U32(ea);
+    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
+    oldtmask = spu_readch(MFC_RdTagMask);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+
+    buf[offset] = 0;
+    MFC_DMA(buf, ea64, size, tagid & 31, MFC_PUT_CMD);
+    spu_writech(MFC_WrTagMask, tagmask);
+    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
+    spu_readch(MFC_RdTagStat);
+    spu_writech(MFC_WrTagMask, oldtmask);
+    mfc_tag_release(tagid);
+}
+
+static inline void _spin_lock(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status;
+
+    /* _spin_lock
+     *    Internal routine to acquire spinlock.
+     */
+/* non trace - no hit/miss indicator */
+#define SET_HIT
+    RAW_SPINLOCK(==, 1);
+}
+
+#ifdef LIBSYNC_TRACE
+static inline s32 _spin_lock_trace(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status = 0;
+/* trace - need hit/miss indicator */
+#undef SET_HIT
+#define SET_HIT        if (status == 0) hit = buf[offset]
+    s32 hit;
+
+    hit = 0;
+    /* _spin_lock_trace for trace
+     *    Internal routine to acquire spinlock.
+     */
+    RAW_SPINLOCK(==, 1);
+
+    return hit;
+
+#undef SET_HIT
+#define SET_HIT
+}
+
+#endif /* LIBSYNC_TRACE */
+
+
+#endif /* SPU_MUTEX_H */
diff --git a/gcell/ibm/sync/spu_source/mutex_init.h b/gcell/ibm/sync/spu_source/mutex_init.h
new file mode 100644 (file)
index 0000000..9bddb14
--- /dev/null
@@ -0,0 +1,64 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_MUTEX_INIT_H_
+#define _SPU_MUTEX_INIT_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include "trace_libsync.h"
+
+/***************************************************************************/
+/**
+ * mutex_init - initialize the mutex by setting the value 
+ * to 0.
+ * @lock: handle to effective address of lock variable.
+ *
+ * Description: Initialize a mutex.
+ */
+static __inline void _mutex_init(mutex_ea_t lock)
+{
+   _lock_init(lock);
+
+   TRACE_MUTEX_INIT(lock);
+}
+
+
+#endif /* _SPU_MUTEX_INIT_H_ */
diff --git a/gcell/ibm/sync/spu_source/mutex_lock.h b/gcell/ibm/sync/spu_source/mutex_lock.h
new file mode 100644 (file)
index 0000000..63bdbc3
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_MUTEX_LOCK_H_
+#define _SPU_MUTEX_LOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include "trace_libsync.h"
+
+static __inline void _mutex_lock(mutex_ea_t ea)
+{
+
+#ifdef LIBSYNC_TRACE
+   s32 miss = 0;
+
+   TRACE_MUTEX_LOCK_ENTRY(interval);
+   miss = _spin_lock_trace(ea);
+   TRACE_MUTEX_LOCK_EXIT(interval, ea, miss);
+
+#else /* LIBSYNC_TRACE */
+
+   _spin_lock(ea);
+
+#endif /* LIBSYNC_TRACE */
+
+}
+
+#endif /* _SPU_MUTEX_LOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/mutex_trylock.h b/gcell/ibm/sync/spu_source/mutex_trylock.h
new file mode 100644 (file)
index 0000000..3c8df46
--- /dev/null
@@ -0,0 +1,70 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_MUTEX_TRYLOCK_H_
+#define _SPU_MUTEX_TRYLOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include "trace_libsync.h"
+
+/**
+ * mutex_trylock - acquire a lock, or return immediately.
+ * @ea: handle to effective address of lock variable.
+ *
+ * Description: Acquire a lock, or return immediately 
+ * without polling for availability.
+ *
+ * Context: The application should not call this interface 
+ * from a tight loop!!  Use spin_lock() instead.
+ */
+static __inline int _mutex_trylock(mutex_ea_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status, ret_val;
+
+    RAW_TEST_AND_SET(==, 1);
+
+    TRACE_MUTEX_TRYLOCK(ea, ret_val);
+
+    return ret_val;
+}
+
+#endif /* _SPU_MUTEX_TRYLOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/mutex_unlock.h b/gcell/ibm/sync/spu_source/mutex_unlock.h
new file mode 100644 (file)
index 0000000..87d6bba
--- /dev/null
@@ -0,0 +1,59 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_MUTEX_UNLOCK_H_
+#define _SPU_MUTEX_UNLOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include "atomic.h"
+#include "trace_libsync.h"
+
+static __inline void _mutex_unlock(mutex_ea_t ea)
+{
+    int ret_val;
+
+    ATOMIC_OP((atomic_ea_t)ea, 0, 1, ret_val);
+
+    TRACE_MUTEX_UNLOCK(ea);
+}
+
+
+#endif /* _SPU_MUTEX_UNLOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/read_lock.h b/gcell/ibm/sync/spu_source/read_lock.h
new file mode 100644 (file)
index 0000000..0e1d971
--- /dev/null
@@ -0,0 +1,66 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_READ_LOCK_H_
+#define _SPU_READ_LOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+
+/**
+ * read_lock - acquire reader lock, or spin until available.
+ * @ea: handle to effective address of lock variable.
+ *
+ * Description: Acquire a non-exclusive reader lock, or spin 
+ * until available.  The only restriction here is that @ea
+ * must be word aligned.
+ *
+ * Context: This routine should not be called if SPU 
+ * asynchronous interrupts are enabled.
+ */
+static __inline void _read_lock(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status;
+
+    RAW_SPINLOCK(>=, 1);
+}
+
+#endif /* _SPU_READ_LOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/read_trylock.h b/gcell/ibm/sync/spu_source/read_trylock.h
new file mode 100644 (file)
index 0000000..d032783
--- /dev/null
@@ -0,0 +1,71 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_READ_TRYLOCK_H_
+#define _SPU_READ_TRYLOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+
+/**
+ * read_trylock - acquire a reader lock, or return immediately.
+ * @ea: handle to effective address of lock variable.
+ *
+ * Acquire a non-exclusive reader lock, or return
+ * immediately.  The only restriction here is that
+ * @ea must be word aligned.
+ *
+ * Returns 1 on success, or 0 on failure.
+ *
+ * Context: The application should not call this interface 
+ * from a tight loop!!  Use read_lock() instead.
+ */
+static __inline int _read_trylock(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status, ret_val;
+
+    RAW_TEST_AND_SET(>=, 1);
+
+    return ret_val;
+}
+
+
+#endif /* _SPU_READ_TRYLOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/read_unlock.h b/gcell/ibm/sync/spu_source/read_unlock.h
new file mode 100644 (file)
index 0000000..f011550
--- /dev/null
@@ -0,0 +1,88 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_READ_UNLOCK_H_
+#define _SPU_READ_UNLOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include <spu_mfcio.h>
+
+
+/**
+ * read_unlock - release reader lock.
+ * @ea: handle to effective address of lock variable.
+ * 
+ * Description: Release a reader lock.  The only restriction 
+ * here is that @ea must be word aligned.
+ *
+ * Context: This routine should be used when interrupts
+ * do not need to be re-enabled --either because interrupts
+ * are not being used, or because the application will take
+ * steps to re-enable them later.
+ */
+static __inline void _read_unlock(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status;
+
+    /* _read_unlock
+     *
+     *    Reader locks must use PUTLLC when releasing, instead of
+     *    the more traditional PUTLLUC because of the non-exclusive
+     *    nature of the lock.  The reason for this is that other
+     *    readers may have incremented the counter, and we don't
+     *    want to corrupt it by blindly issuing PUTLLUC!!
+     */
+    ea64.ull = ALIGN128_EA(ea);
+    offset = OFFSET128_EA_U32(ea);
+    do {
+        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+        spu_readch(MFC_RdAtomicStat);
+
+        buf[offset] -= 1;
+        MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
+        status = spu_readch(MFC_RdAtomicStat);
+    } while (status != 0);
+
+}
+
+
+#endif /* _SPU_READ_UNLOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/rwlock_init.h b/gcell/ibm/sync/spu_source/rwlock_init.h
new file mode 100644 (file)
index 0000000..6b05533
--- /dev/null
@@ -0,0 +1,60 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_RWLOCK_INIT_H_
+#define _SPU_RWLOCK_INIT_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+
+/**
+ * rwlock_init - initialize a reader/writer lock.
+ * @ea: handle to effective address of lock variable.
+ *
+ * Description: Initialize a reader/writer lock.
+ */
+static __inline void _rwlock_init(eaddr_t rwlock)
+{
+    _lock_init(rwlock);
+}
+
+
+
+#endif /* _SPU_RWLOCK_INIT_H_ */
diff --git a/gcell/ibm/sync/spu_source/sync_irq.h b/gcell/ibm/sync/spu_source/sync_irq.h
new file mode 100644 (file)
index 0000000..feae65e
--- /dev/null
@@ -0,0 +1,76 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+/*
+ * irq.h - SPU interrupt management facilities.
+ * 
+ * These utilities help an "interrupt aware" library to manage
+ * state of SPU interrupts.  
+ */
+
+#ifndef __SPU_IRQ_H__
+#define __SPU_IRQ_H__
+
+#include <spu_intrinsics.h>
+#include "sync_utils.h"
+
+static inline u32 irq_mask(u32 newmask)
+{
+    u32 old, tmp = 0;
+
+    /* irq_mask
+     *    Set the interrupt mask to the newmask value,
+     *    and return its previous setting.  Will
+     *    detect and discard potential phantom
+     *    events.
+     */
+
+    old = spu_readch(SPU_RdEventMask);
+    spu_writech(SPU_WrEventMask, tmp);
+    if (spu_readchcnt(SPU_RdEventStat)) {
+        tmp = spu_readch(SPU_RdEventStat);
+        spu_writech(SPU_WrEventAck, tmp);
+    }
+    spu_writech(SPU_WrEventMask, newmask);
+
+    return old;
+}
+
+#endif /* __SPU_IRQ_H__ */
diff --git a/gcell/ibm/sync/spu_source/sync_utils.h b/gcell/ibm/sync/spu_source/sync_utils.h
new file mode 100644 (file)
index 0000000..516b41f
--- /dev/null
@@ -0,0 +1,103 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+/*
+ * sync_utils.h - SPU sync-library internal utilities.
+ *
+ * These utilities are used internally by the SPU sync library.
+ */
+#ifndef __SPU_SYNC_UTILS_H__
+#define __SPU_SYNC_UTILS_H__
+
+#include <spu_intrinsics.h>
+
+typedef unsigned int u32;
+typedef signed int s32;
+typedef unsigned long long u64;
+typedef unsigned long long eaddr_t;
+
+
+typedef union {
+    u64 ull;  
+    u32 ui[2];
+} addr64;
+
+#ifndef likely
+#define likely(_c)     \
+    __builtin_expect((_c), 1)
+#define unlikely(_c)    \
+    __builtin_expect((_c), 0)
+#endif
+
+#define ALLOCA(_nbytes, _size)    \
+    alloca((_nbytes) + (_size)-1)
+
+#define ALIGN(_ptr, _size)       \
+    ((((u32) _ptr) + (_size)-1) & ~((_size)-1))
+
+#define ALIGN128_EA(_ull)      \
+    ((_ull) & ~(127ULL))
+/*
+#define OFFSET128_EA(_ull, _type) \
+    (((_ull) & 127ULL) / sizeof(_type))
+    */
+
+#define OFFSET128_EA_U32(_ull) \
+    (((_ull) & 127ULL) >> 2)
+
+#define OFFSET128_EA_U16(_ull) \
+    (((_ull) & 127ULL) >> 1)
+
+#define MFC_DMA(_ls, _ea, _sz, _tg, _cmd) \
+    spu_mfcdma64(_ls, _ea.ui[0], _ea.ui[1], _sz, _tg, _cmd)
+
+#define MFC_SYNC() {                           \
+    u32 _tagid = 0;                            \
+    spu_writech(mfc_tag_id, _tagid);           \
+    spu_writech(mfc_cmd_queue, MFC_SYNC_CMD);  \
+}
+
+#define MFC_EIEIO() {                          \
+    u32 _tagid = 0;                            \
+    spu_writech(mfc_tag_id, _tagid);           \
+    spu_writech(mfc_cmd_queue, MFC_EIEIO_CMD); \
+}
+
+#endif /* __SPU_SYNC_UTILS_H__ */
diff --git a/gcell/ibm/sync/spu_source/trace_libsync.h b/gcell/ibm/sync/spu_source/trace_libsync.h
new file mode 100644 (file)
index 0000000..47887c9
--- /dev/null
@@ -0,0 +1,117 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2007                                               */
+/* International Business Machines Corporation                     */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef __LIBSYNC_SPU_TRACEHOOKS_H__
+#define __LIBSYNC_SPU_TRACEHOOKS_H__
+
+#ifdef LIBSYNC_TRACE
+
+#include <trace_events.h>
+
+/*
+ *  last parameter in the trace_even and trace_interval_entry call is
+ *   the stack level to report the PC in the trace record. so 0 means
+ *   the PC of the current frame, 1 means the PC of the caller, etc.
+ *   there's a dilemma here - these macros are included in the inline
+ *   _mutex calls which get called from the (created during build)
+ *   mutex functions in the mutex .c files. in that case, the level
+ *   should be 1 - we don't want the PC of where in the mutex function
+ *   the trace call is happening, we want the PC of whomever is calling
+ *   the mutex function.
+ *
+ *   but.. an app can call the inline functions - it can #include the
+ *   appropriate libsync mutex .h files, and call the inlined _mutex
+ *   function in their code. in that case, the appropriate level for the
+ *   trace calls would be 0 - the user would want to know where in their
+ *   code the call to the _mutex function is.
+ *
+ *   so, we'll assume _LEVEL of 0 which is what the inline funtions need.
+ *   when we build the files for libsync, we'll do a -D_LEVEL=1 
+ */
+#ifndef _LEVEL
+#define _LEVEL 0
+#endif
+
+
+#define TRACE_EVENT_MUTEX_INIT 0x0403
+
+#define TRACE_MUTEX_INIT(lock) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(unsigned long)lock; \
+  trace_event(TRACE_EVENT_MUTEX_INIT, 1, &payload, "Event=%d, lock=0x%x", _LEVEL); \
+}
+
+#define TRACE_EVENT_MUTEX_LOCK 0x0503
+
+#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL) \
+trace_interval_p _INTERVAL = trace_interval_entry(TRACE_EVENT_MUTEX_LOCK, _LEVEL)
+
+#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(unsigned long)lock; \
+  payload.word[2]=(unsigned int)miss; \
+  trace_interval_exit(_INTERVAL, 2,  &payload, "Event=%d, lock=0x%x, miss=0x%x"); \
+}
+
+#define TRACE_EVENT_MUTEX_TRYLOCK 0x0603
+
+#define TRACE_MUTEX_TRYLOCK(lock,ret_val) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(unsigned long)lock; \
+  payload.word[2]=(unsigned int)ret_val; \
+  trace_event(TRACE_EVENT_MUTEX_TRYLOCK, 2, &payload, "Event=%d, lock=0x%x, ret_val=0x%x", _LEVEL); \
+}
+
+#define TRACE_EVENT_MUTEX_UNLOCK 0x0703
+
+#define TRACE_MUTEX_UNLOCK(lock) { \
+  trace_payload_t payload; \
+  payload.dword[0]=(unsigned long)lock; \
+  trace_event(TRACE_EVENT_MUTEX_UNLOCK, 1, &payload, "Event=%d, lock=0x%x", _LEVEL); \
+}
+
+#else /* LIBSYNC_TRACE */
+
+#define TRACE_MUTEX_INIT(lock) 
+#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL) 
+#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss)
+#define TRACE_MUTEX_TRYLOCK(lock,ret_val)
+#define TRACE_MUTEX_UNLOCK(lock) 
+
+#endif /* LIBSYNC_TRACE */
+
+#endif  /* __LIBSYNC_SPU_TRACEHOOKS_H__ */
diff --git a/gcell/ibm/sync/spu_source/wait_for_completion.h b/gcell/ibm/sync/spu_source/wait_for_completion.h
new file mode 100644 (file)
index 0000000..ea7bdbe
--- /dev/null
@@ -0,0 +1,82 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_WAIT_FOR_COMPLETION_H_
+#define _SPU_WAIT_FOR_COMPLETION_H_
+
+#include "sync_utils.h"
+#include <spu_mfcio.h>
+#include "sync_irq.h"
+#include "completion.h"
+
+/* _wait_for_completion 
+ *    Internal routine to wait for completion to
+ *    become true (!0).  When completion is false,
+ *    uses lock line reservation lost event to 
+ *    sleep until the variable has been changed.
+ */
+static __inline void _wait_for_completion(completion_ea_t completion)
+{
+    DECL_COMPLETION_VARS();
+    s32 status;
+
+    status = 1;
+
+    ea64.ull = ALIGN128_EA(completion);
+    offset = OFFSET128_EA_U32(completion);
+    do {
+        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+        spu_readch(MFC_RdAtomicStat);
+        /* if the completion variable has been set elsewhere
+         * (a signal or broadcast function has been called 
+         * then we get out of the loop, and reset the variable */
+        if (likely(buf[offset] != 0)) {
+            /* decrement the variable */
+            buf[offset]--;
+            MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
+            spu_readch(MFC_RdAtomicStat);
+            status = 0;
+        }
+    } while (status != 0);
+}
+
+
+
+#endif /* _SPU_WAIT_FOR_COMPLETION_H_ */
diff --git a/gcell/ibm/sync/spu_source/write_lock.h b/gcell/ibm/sync/spu_source/write_lock.h
new file mode 100644 (file)
index 0000000..7af5175
--- /dev/null
@@ -0,0 +1,67 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_WRITE_LOCK_H_
+#define _SPU_WRITE_LOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+
+/**
+ * write_lock - acquire writer lock, or spin until available.
+ * @ea: handle to effective address of lock variable.
+ *
+ * Description: Acquire an exclusive writer lock, 
+ * or spin until available.  The only restriction 
+ * here is that @ea must be word aligned.
+ *
+ * Context: This routine should not be called if SPU 
+ * asynchronous interrupts are enabled.
+ */
+static __inline void _write_lock(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status;
+
+    RAW_SPINLOCK(==, -1);
+}
+
+
+#endif /* _SPU_WRITE_LOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/write_trylock.h b/gcell/ibm/sync/spu_source/write_trylock.h
new file mode 100644 (file)
index 0000000..b3799b3
--- /dev/null
@@ -0,0 +1,72 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_WRITE_TRYLOCK_H_
+#define _SPU_WRITE_TRYLOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+
+/**
+ * write_trylock - acquire a writer lock, or return immediately.
+ * @ea: handle to effective address of lock variable.
+ *
+ * Try to acquire an exclusive writer lock, or return
+ * immediately.  The only restriction here is that @ea
+ * must be word aligned.
+ *
+ * Returns 1 on success, or 0 on failure.
+ *
+ * Caution:
+ * The application should not call this interface from a tight
+ * loop!!  Use write_lock() instead.
+ */
+static __inline int _write_trylock(eaddr_t ea)
+{
+    DECL_MUTEX_VARS();
+    s32 status, ret_val;
+
+    RAW_TEST_AND_SET(==, -1);
+
+    return ret_val;
+}
+
+
+#endif /* _SPU_WRITE_TRYLOCK_H_ */
diff --git a/gcell/ibm/sync/spu_source/write_unlock.h b/gcell/ibm/sync/spu_source/write_unlock.h
new file mode 100644 (file)
index 0000000..25b24e1
--- /dev/null
@@ -0,0 +1,69 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _SPU_WRITE_UNLOCK_H_
+#define _SPU_WRITE_UNLOCK_H_
+
+#include "sync_utils.h"
+#include "mutex.h"
+#include <spu_mfcio.h>
+
+/**
+ * write_unlock - release writer lock.
+ * @rwlock: handle to effective address of lock variable.
+ *
+ * Release a single writer lock.
+ */
+static __inline void _write_unlock(eaddr_t rwlock)
+{
+    DECL_MUTEX_VARS();
+
+    ea64.ull = ALIGN128_EA(rwlock);
+    offset = OFFSET128_EA_U32(rwlock);
+    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
+    spu_readch(MFC_RdAtomicStat);
+
+    buf[offset] = 0;
+    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
+    spu_readch(MFC_RdAtomicStat);
+}
+
+
+#endif /* _SPU_WRITE_UNLOCK_H_ */
diff --git a/gcell/include/Makefile.am b/gcell/include/Makefile.am
new file mode 100644 (file)
index 0000000..c96c6f0
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = gcell
+
diff --git a/gcell/include/gcell/Makefile.am b/gcell/include/gcell/Makefile.am
new file mode 100644 (file)
index 0000000..03255e5
--- /dev/null
@@ -0,0 +1,42 @@
+#
+# Copyright 2007,2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = spu
+
+gcellinclude_HEADERS = \
+       compiler.h \
+       gc_aligned_alloc.h \
+       gc_atomic.h \
+       gc_cdefs.h \
+       gc_declare_proc.h \
+       gc_job_manager.h \
+       gc_jd_queue_data.h \
+       gc_jd_queue.h \
+       gc_jd_stack.h \
+       gc_job_desc.h \
+       gc_job_desc_private.h \
+       gc_logging.h \
+       gc_mbox.h \
+       gc_spu_args.h \
+       gc_types.h \
+       gcp_fft_1d_r2.h \
+       memory_barrier.h
diff --git a/gcell/include/gcell/compiler.h b/gcell/include/gcell/compiler.h
new file mode 100644 (file)
index 0000000..d1adcd1
--- /dev/null
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_COMPILER_H
+#define INCLUDED_GCELL_COMPILER_H
+
+/*!
+ * \brief Compiler specific hackery.  These are for GCC.
+ */
+
+#define _AL8   __attribute__((aligned (8)))
+#define _AL16  __attribute__((aligned (16)))
+#define _AL128 __attribute__((aligned (128)))
+
+#define _UNUSED __attribute__((unused))
+
+#ifndef likely
+#define likely(x)       __builtin_expect(!!(x), 1)
+#define unlikely(x)     __builtin_expect(!!(x), 0)
+#endif
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
+#endif
+
+
+#endif /* INCLUDED_GCELL_COMPILER_H */
diff --git a/gcell/include/gcell/gc_aligned_alloc.h b/gcell/include/gcell/gc_aligned_alloc.h
new file mode 100644 (file)
index 0000000..bdc21c2
--- /dev/null
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GC_ALIGNED_ALLOC_H
+#define INCLUDED_GC_ALIGNED_ALLOC_H
+
+#include <boost/shared_ptr.hpp>
+
+/*!
+ * \brief Return pointer to chunk of storage of size size bytes.
+ * The allocation will be aligned to an \p alignment boundary.
+ *
+ * \param size is the number of bytes to allocate
+ * \param alignment is the minimum storage alignment in bytes; must be a power of 2.
+ *
+ * Throws if can't allocate memory.  The storage should be freed
+ * with "free" when done.  The memory is initialized to zero.
+ */
+void *
+gc_aligned_alloc(size_t size, size_t alignment = 128);
+
+/*!
+ * \brief Return boost::shared_ptr to chunk of storage of size size bytes.
+ * The allocation will be aligned to an \p alignment boundary.
+ *
+ * \param size is the number of bytes to allocate
+ * \param alignment is the minimum storage alignment in bytes; must be a power of 2.
+ *
+ * Throws if can't allocate memory.  The storage should be freed
+ * with "free" when done.  The memory is initialized to zero.
+ */
+boost::shared_ptr<void>
+gc_aligned_alloc_sptr(size_t size, size_t alignment = 128);
+
+#endif /* INCLUDED_GC_ALIGNED_ALLOC_H */
diff --git a/gcell/include/gcell/gc_atomic.h b/gcell/include/gcell/gc_atomic.h
new file mode 100644 (file)
index 0000000..51d38af
--- /dev/null
@@ -0,0 +1,29 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_GC_ATOMIC_H
+#define INCLUDED_GCELL_GC_ATOMIC_H
+
+#include <stdint.h>
+
+typedef uint32_t       gc_atomic_t;
+
+
+#endif /* INCLUDED_GCELL_GC_ATOMIC_H */
diff --git a/gcell/include/gcell/gc_cdefs.h b/gcell/include/gcell/gc_cdefs.h
new file mode 100644 (file)
index 0000000..0c5fc4a
--- /dev/null
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_CDEFS_H
+#define INCLUDED_GCELL_GC_CDEFS_H
+
+/* C++ needs to know that types and declarations are C, not C++.  */
+#ifdef __cplusplus
+# define __GC_BEGIN_DECLS      extern "C" {
+# define __GC_END_DECLS        }
+#else
+# define __GC_BEGIN_DECLS
+# define __GC_END_DECLS
+#endif
+
+#endif /* INCLUDED_GCELL_GC_CDEFS_H */
diff --git a/gcell/include/gcell/gc_declare_proc.h b/gcell/include/gcell/gc_declare_proc.h
new file mode 100644 (file)
index 0000000..ba77e0f
--- /dev/null
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_GC_DECLARE_PROC_H
+#define INCLUDED_GCELL_GC_DECLARE_PROC_H
+
+#include <stdint.h>
+#include <gcell/gc_job_desc.h>
+
+/*
+ * This is C, not C++ code...
+ *
+ * ...and is used by both PPE and SPE code
+ */
+__GC_BEGIN_DECLS
+
+#define GC_PROC_DEF_SECTION ".gcell.proc_def"
+
+typedef struct gc_proc_def {
+#if defined(__SPU__)
+  gc_spu_proc_t        proc;
+#else
+  uint32_t     proc;
+#endif
+  char         name[28];
+} _AL16 gc_proc_def_t;
+
+
+#if defined(__SPU__)
+/*!
+ * \brief Tell gcell about a SPU procedure
+ *
+ * \param _proc_   pointer to function (gc_spu_proc_t)
+ * \param _name_   the name of the procedure ("quoted string")
+ *
+ * This macro registers the given procedure with the gcell runtime.
+ * From the PPE, use gc_job_manager::lookup_proc to map \p _name_ to a gc_proc_id_t
+ */
+#define GC_DECLARE_PROC(_proc_, _name_) \
+static struct gc_proc_def \
+  _GCPD_ ## _proc_ __attribute__((section(GC_PROC_DEF_SECTION), used)) = \
+  { _proc_, _name_ }
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GCELL_GC_DECLARE_PROC_H */
diff --git a/gcell/include/gcell/gc_jd_queue.h b/gcell/include/gcell/gc_jd_queue.h
new file mode 100644 (file)
index 0000000..50777a3
--- /dev/null
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_JD_QUEUE_H
+#define INCLUDED_GCELL_GC_JD_QUEUE_H
+
+#include <gcell/gc_jd_queue_data.h>
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Initialize the queue to empty.
+ */
+void 
+gc_jd_queue_init(gc_jd_queue_t *q);
+  
+
+/*!
+ * \brief Add \p item to the tail of \p q.
+ */
+void 
+gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item);
+
+
+/*!
+ * \brief Remove and return item at head of queue, or 0 if queue is empty
+ */
+gc_job_desc_t *
+gc_jd_queue_dequeue(gc_jd_queue_t *q);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GCELL_GC_JD_QUEUE_H */
diff --git a/gcell/include/gcell/gc_jd_queue_data.h b/gcell/include/gcell/gc_jd_queue_data.h
new file mode 100644 (file)
index 0000000..819b371
--- /dev/null
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_JD_QUEUE_DATA_H
+#define INCLUDED_GCELL_GC_JD_QUEUE_DATA_H
+
+#include <gcell/gc_types.h>
+#include <gcell/gc_job_desc.h>
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief (Lock free someday...) queue for job descriptors
+ *
+ * This is the main data structure shared between PPEs and SPEs.
+ * It is used to enqueue work for SPEs.  SPEs or PPEs may enqueue
+ * work.  SPE's dequeue from here.
+ *
+ * FIXME make it lock free ;)  For now, use a spin lock.
+ *
+ * (Fills a single cache line)
+ */
+typedef struct gc_jd_queue
+{
+  gc_eaddr_t   head  _AL16;
+  gc_eaddr_t   tail  _AL16;
+  uint32_t     mutex _AL16;            // libsync mutex (spin lock)
+} _AL128 gc_jd_queue_t;
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GCELL_GC_JD_QUEUE_DATA_H */
+
+
diff --git a/gcell/include/gcell/gc_jd_stack.h b/gcell/include/gcell/gc_jd_stack.h
new file mode 100644 (file)
index 0000000..9eab4e4
--- /dev/null
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_JD_STACK_H
+#define INCLUDED_GCELL_GC_JD_STACK_H
+
+#include <gcell/gc_types.h>
+#include <gcell/gc_job_desc.h>
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Lock free stack for job descriptors (used for free list)
+ *
+ * This is aligned to a cache line, and fills the cache line,
+ * to avoid inadvertently losing reservations created with
+ * the load-and-reserve instructions.
+ */
+
+typedef struct gc_jd_stack
+{
+  gc_eaddr_t   top;
+
+  // pad out to a full cache line
+  uint8_t      _pad[128 - sizeof(gc_eaddr_t)];
+} _AL128 gc_jd_stack_t;
+
+
+/*!
+ * \brief Initialize the stack to empty.
+ */
+void 
+gc_jd_stack_init(gc_jd_stack_t *stack);
+  
+
+/*!
+ * \brief Add \p item to the top of \p stack.
+ */
+void 
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item);
+
+
+/*!
+ * \brief pop and return top item on stack, or 0 if stack is empty
+ */
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GCELL_GC_JD_STACK_H */
diff --git a/gcell/include/gcell/gc_job_desc.h b/gcell/include/gcell/gc_job_desc.h
new file mode 100644 (file)
index 0000000..5ff99e2
--- /dev/null
@@ -0,0 +1,213 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_JOB_DESC_H
+#define INCLUDED_GCELL_GC_JOB_DESC_H
+
+/*!
+ * This file contains the structures that are used to describe how to
+ * call "jobs" that execute on the SPEs.  A "job" is a task, or piece of
+ * work that you want to run on an SPE.
+ *
+ * There is code running in the SPE that knows how to interpret
+ * these job descriptions. Thus, in most cases, the overhead
+ * of invoking these is very low.
+ *
+ * The whole "job idea" is SPE centric.  At first pass,
+ * the PPE will be constructing jobs and enqueing them.
+ * However, there is nothing in the implementation that
+ * prohibits SPEs from creating their own jobs in the
+ * future.  Also, there is nothing prohibiting SPE-to-SPE
+ * DMA's.
+ *
+ * SPE's dequeue and "pull" jobs to themselves, do the work, then
+ * notify the entity that submitted the job.
+ */
+
+#include <gcell/gc_types.h>
+#include <gcell/gc_job_desc_private.h>
+
+/*
+ * This is C, not C++ code...
+ *
+ * ...and is used by both PPE and SPE code
+ */
+__GC_BEGIN_DECLS
+
+
+//! opaque ID that specifies which code to invoke on the SPE
+typedef uint32_t gc_proc_id_t;
+#define GCP_UNKNOWN_PROC ((gc_proc_id_t) -1)
+
+
+//! final job status
+typedef enum {
+  JS_OK,
+  JS_SHUTTING_DOWN,        // job mananger is shutting down
+  JS_TOO_MANY_CLIENTS,     // too many client threads
+  JS_UNKNOWN_PROC,         // didn't recognize the procedure ID
+  JS_BAD_DIRECTION,        // EA arg has invalid direction
+  JS_BAD_EAH,              // not all EA args have the same high 32 address bits
+  JS_BAD_N_DIRECT,         // too many direct args
+  JS_BAD_N_EA,             // too many EA args
+  JS_ARGS_TOO_LONG,        // total length of EA args exceeds limit
+  JS_BAD_JUJU,             // misc problem: you're having a bad day
+  JS_BAD_JOB_DESC,         // gc_job_desc was not allocated using mgr->alloc_job_desc()
+
+} gc_job_status_t;
+
+#define MAX_ARGS_DIRECT  8  // maximum number of args passed using "direct" method
+#define MAX_ARGS_EA     8  // maximum number of args passed via EA memory (dma)
+
+/*
+ * We support two classes of arguments,
+ *   "direct", which are contained in the gc_job_desc_args and
+ *   "EA", which are copied in/out according to info in gc_job_desc_args
+ */
+
+/*!
+ * \brief Tag type of "direct" argument
+ */
+typedef enum {
+  GCT_S32,
+  GCT_U32,
+  GCT_S64,
+  GCT_U64,
+  GCT_FLOAT,
+  GCT_DOUBLE,
+  GCT_FLT_CMPLX,
+  GCT_DBL_CMPLX,
+  GCT_EADDR,
+
+} gc_tag_t;
+
+
+/*!
+ * \brief union for passing "direct" argument
+ */
+typedef union gc_arg_union
+{
+  int32_t       s32;
+  uint32_t      u32;
+  int64_t       s64;
+  uint64_t      u64;
+  float                 f;
+  double        d;
+  //float complex  cf; //  64-bits (C99)
+  //double complex cd;  // 128-bits (C99)
+  gc_eaddr_t    ea;    //  64-bits
+} _AL8 gc_arg_union_t;
+
+
+/*!
+ * \brief "direct" input or output arguments
+ */
+typedef struct gc_job_direct_args
+{
+  uint32_t       nargs;                        // # of "direct" args
+  gc_tag_t       tag[MAX_ARGS_DIRECT] _AL16;   // type of direct arg[i]
+  gc_arg_union_t  arg[MAX_ARGS_DIRECT] _AL16;   // direct argument values
+
+} _AL16 gc_job_direct_args_t;
+
+
+// specifies direction for args passed in EA memory
+
+#define GCJD_DMA_GET           0x01            // in to SPE
+#define        GCJD_DMA_PUT            0x02            // out from SPE
+
+/*!
+ * \brief Description of args passed in EA memory.
+ * These are DMA'd between EA and LS as specified.
+ */
+typedef struct gc_job_ea_arg {
+  //! EA address of buffer
+  gc_eaddr_t     ea_addr;      
+
+  //! GC_JD_DMA_* get arg or put arg
+  uint32_t      direction;
+
+  //! number of bytes to get
+  uint32_t      get_size;         
+
+  //! number of bytes to put
+  uint32_t      put_size;
+
+#if defined(__SPU__)
+  //! local store address (filled in by SPU runtime)
+  void         *ls_addr;
+  uint32_t      _pad[2];
+#else
+  uint32_t       _pad[3];
+#endif
+
+} _AL16 gc_job_ea_arg_t;
+
+
+typedef struct gc_job_ea_args {
+  uint32_t             nargs;
+  gc_job_ea_arg_t      arg[MAX_ARGS_EA];
+
+} _AL16 gc_job_ea_args_t;
+
+
+/*!
+ * \brief "job description" that is DMA'd to/from the SPE.
+ */
+typedef struct gc_job_desc
+{
+  gc_job_desc_private_t sys;     // internals
+  gc_job_status_t      status;   // what happened (output)
+  gc_proc_id_t          proc_id;  // specifies which procedure to run
+  gc_job_direct_args_t input;    // direct args to SPE
+  gc_job_direct_args_t output;   // direct args from SPE
+  gc_job_ea_args_t     eaa;      // args passed via EA memory
+
+} _AL128 gc_job_desc_t;
+
+
+/*!
+ * type of procedure invoked on spu
+ */
+typedef void (*gc_spu_proc_t)(const gc_job_direct_args_t *input,
+                             gc_job_direct_args_t *output,
+                             const gc_job_ea_args_t *eaa);
+
+#if !defined(__SPU__)
+
+static inline gc_job_desc_t *
+ea_to_jdp(gc_eaddr_t ea)
+{
+  return (gc_job_desc_t *) ea_to_ptr(ea);
+}
+
+static inline gc_eaddr_t
+jdp_to_ea(gc_job_desc_t *item)
+{
+  return ptr_to_ea(item);
+}
+
+#endif
+
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GCELL_GC_JOB_DESC_H */
diff --git a/gcell/include/gcell/gc_job_desc_private.h b/gcell/include/gcell/gc_job_desc_private.h
new file mode 100644 (file)
index 0000000..fa831a8
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_JOB_DESC_PRIVATE_H
+#define INCLUDED_GCELL_GC_JOB_DESC_PRIVATE_H
+
+// #include <libsync.h>
+
+/*!
+ * \brief Implementation details we'd like to hide from the user.
+ */
+typedef struct gc_job_desc_private
+{
+  gc_eaddr_t   next;               // used to implement job queue and free list
+  uint16_t     job_id;
+  uint16_t     client_id;
+  uint32_t     direction_union;    // union of all gc_job_ea_arg.direction fields
+} gc_job_desc_private_t;
+
+#endif /* INCLUDED_GCELL_GC_JOB_PRIVATE_H */
+
diff --git a/gcell/include/gcell/gc_job_manager.h b/gcell/include/gcell/gc_job_manager.h
new file mode 100644 (file)
index 0000000..67abce7
--- /dev/null
@@ -0,0 +1,286 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GC_JOB_MANAGER_H
+#define INCLUDED_GC_JOB_MANAGER_H
+
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+#include <string>
+#include <stdexcept>
+#include <libspe2.h>
+#include "gc_job_desc.h"
+
+class gc_job_manager;
+typedef boost::shared_ptr<gc_job_manager> gc_job_manager_sptr;
+typedef boost::shared_ptr<spe_program_handle_t> spe_program_handle_sptr;
+typedef boost::shared_ptr<gc_job_desc> gc_job_desc_sptr;
+
+/*!
+ * \brief Return a boost::shared_ptr to an spe_program_handle_t
+ *
+ * \param filename is the name of the SPE ELF executable to open.
+ *
+ * Calls spe_image_open to open the file.  If successful returns a
+ * boost::shared_ptr that will call spe_image_close when it's time to
+ * free the object.
+ *
+ * Returns the equivalent of the NULL pointer if the file cannot be
+ * opened, or if it's not an SPE ELF object file.
+ *
+ * \sa gc_program_handle_from_address
+ */
+spe_program_handle_sptr 
+gc_program_handle_from_filename(const std::string &filename);
+
+/*!
+ * \brief Return a boost::shared_ptr to an spe_program_handle_t
+ *
+ * \param handle is a non-zero pointer to an embedded SPE image.
+ *
+ * If successful returns a boost::shared_ptr that does nothing when
+ * it's time to free the object.
+ *
+ * \sa gc_program_handle_from_filename
+ */
+spe_program_handle_sptr 
+gc_program_handle_from_address(spe_program_handle_t *handle);
+
+/*!
+ * \brief map gc_job_status_t into a string
+ */
+const std::string
+gc_job_status_string(gc_job_status_t status);
+
+/*
+ * \brief Options that configure the job_manager.
+ * The default values are reasonable.
+ */
+struct gc_jm_options {
+  unsigned int max_jobs;           // max # of job descriptors in system
+  unsigned int max_client_threads;  // max # of client threads of job manager
+  unsigned int nspes;              // how many SPEs shall we use? 0 -> all of them
+  bool gang_schedule;              // shall we gang schedule?
+  bool use_affinity;               // shall we try for affinity (FIXME not implmented)
+  bool enable_logging;             // shall we log SPE events?
+  uint32_t log2_nlog_entries;             // log2 of number of log entries (default is 12 == 4k)
+  spe_program_handle_sptr program_handle;  // program to load into SPEs
+
+  gc_jm_options() :
+    max_jobs(0), max_client_threads(0), nspes(0),
+    gang_schedule(false), use_affinity(false),
+    enable_logging(false), log2_nlog_entries(12)
+  {
+  }
+
+  gc_jm_options(spe_program_handle_sptr program_handle_,
+               unsigned int nspes_ = 0) :
+    max_jobs(0), max_client_threads(0), nspes(nspes_),
+    gang_schedule(false), use_affinity(false),
+    enable_logging(false), log2_nlog_entries(12),
+    program_handle(program_handle_)
+  {
+  }
+};
+
+enum gc_wait_mode {
+  GC_WAIT_ANY,
+  GC_WAIT_ALL,
+};
+
+/*
+ * exception classes
+ */
+class gc_exception : public std::runtime_error
+{
+public:
+  gc_exception(const std::string &msg);
+};
+
+class gc_unknown_proc : public gc_exception
+{
+public:
+  gc_unknown_proc(const std::string &msg);
+};
+
+class gc_bad_alloc : public gc_exception
+{
+public:
+  gc_bad_alloc(const std::string &msg);
+};
+
+class gc_bad_align : public gc_exception
+{
+public:
+  gc_bad_align(const std::string &msg);
+};
+
+class gc_bad_submit : public gc_exception
+{
+public:
+  gc_bad_submit(const std::string &name, gc_job_status_t status);
+};
+
+/*
+ * \brief Create an instance of the job manager
+ */
+gc_job_manager_sptr
+gc_make_job_manager(const gc_jm_options *options = 0);
+
+
+/*!
+ * \brief Abstract class that manages SPE jobs.
+ *
+ * There is typically a single instance derived from this class.
+ * It is safe to call its methods from any thread.
+ */
+class gc_job_manager : boost::noncopyable
+{
+public:
+  gc_job_manager(const gc_jm_options *options = 0); 
+
+  virtual ~gc_job_manager();
+
+  /*!
+   * Stop accepting new jobs.  Wait for existing jobs to complete.
+   * Return all managed SPE's to the system.
+   */
+  virtual bool shutdown() = 0;
+
+  /*!
+   * \brief Return number of SPE's currently allocated to job manager.
+   */
+  virtual int nspes() const = 0;
+
+  /*!
+   * \brief Return a pointer to a properly aligned job descriptor,
+   * or throws gc_bad_alloc if there are none available.
+   */
+  virtual gc_job_desc *alloc_job_desc() = 0;
+
+  /*
+   *! Free a job descriptor previously allocated with alloc_job_desc()
+   *
+   * \param[in] jd pointer to job descriptor to free.
+   */
+  virtual void free_job_desc(gc_job_desc *jd) = 0;
+
+  /*!
+   * \brief Submit a job for asynchronous processing on an SPE.
+   *
+   * \param[in] jd pointer to job description
+   *
+   * The caller must not read or write the job description
+   * or any of the memory associated with any indirect arguments
+   * until after calling wait_job.
+   *
+   * \returns true iff the job was successfully enqueued.
+   * If submit_job returns false, check jd->status for additional info.
+   */
+  virtual bool submit_job(gc_job_desc *jd) = 0;
+
+  /*!
+   * \brief Wait for job to complete.
+   *
+   * A thread may only wait for jobs which it submitted.
+   *
+   * \returns true if sucessful, else false.
+   */
+  virtual bool 
+  wait_job(gc_job_desc *jd) = 0;
+
+  /*!
+   * \brief wait for 1 or more jobs to complete.
+   *
+   * \param[input] njobs is the length of arrays \p jd and \p done.
+   * \param[input] jd are the jobs that are to be waited for.
+   * \param[output] done indicates whether the corresponding job is complete.
+   * \param[input] mode indicates whether to wait for ALL or ANY of the jobs
+   *   in \p jd to complete.
+   *
+   * A thread may only wait for jobs which it submitted.
+   *
+   * \returns number of jobs completed, or -1 if error.
+   * The caller must examine the status field of each job to confirm
+   * successful completion of the job.
+   */
+  virtual int
+  wait_jobs(unsigned int njobs,
+           gc_job_desc *jd[], bool done[], gc_wait_mode mode) = 0;
+
+  /*!
+   * Return the maximum number of bytes of EA arguments that may be
+   * copied to or from the SPE in a single job.  The limit applies
+   * independently to the "get" and "put" args.  
+   * \sa gc_job_desc_t, gc_job_ea_args_t
+   */
+  virtual int ea_args_maxsize() = 0;
+
+  /*!
+   * Return gc_proc_id_t associated with spu procedure \p proc_name if one
+   * exists, otherwise throws gc_unknown_proc.
+   */
+  virtual gc_proc_id_t lookup_proc(const std::string &proc_name) = 0;
+  
+  /*!
+   * Return a vector of all known spu procedure names.
+   */
+  virtual std::vector<std::string> proc_names() = 0;
+
+  virtual void set_debug(int debug);
+  virtual int debug();
+
+  /* ----- static methods ----- */
+
+  /*!
+   * \brief Set the singleton gc_job_manager instance.
+   * \param mgr is the job manager instance.
+   *
+   * The singleton is weakly held, thus the caller must maintain
+   * a reference to the mgr for the duration.  (If we held the
+   * manager strongly, the destructor would never be called, and the
+   * resources (SPEs) would not be returned.)  Bottom line: the
+   * caller is responsible for life-time management.
+   */
+  static void set_singleton(gc_job_manager_sptr mgr);
+
+  /*!
+   * \brief Retrieve the singleton gc_job_manager instance.
+   *
+   * Returns the singleton gc_job_manager instance or raises
+   * boost::bad_weak_ptr if the singleton is empty.
+   */
+  static gc_job_manager_sptr singleton();
+
+  /*!
+   * \brief return a boost::shared_ptr to a job descriptor.
+   */
+  static gc_job_desc_sptr make_jd_sptr(gc_job_manager_sptr mgr, gc_job_desc *jd);
+
+  /*!
+   * \brief allocate a job descriptor and return a boost::shared_ptr to it.
+   */
+  static gc_job_desc_sptr alloc_job_desc(gc_job_manager_sptr mgr);
+};
+
+
+#endif /* INCLUDED_GC_JOB_MANAGER_H */
diff --git a/gcell/include/gcell/gc_logging.h b/gcell/include/gcell/gc_logging.h
new file mode 100644 (file)
index 0000000..9cc6fa7
--- /dev/null
@@ -0,0 +1,166 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_GC_LOGGING_H
+#define INCLUDED_GCELL_GC_LOGGING_H
+
+#include <gcell/gc_types.h>
+#include <string.h>
+
+__GC_BEGIN_DECLS
+
+typedef struct gc_log {
+  gc_eaddr_t           base;           // gc_log_entry_t * (16 byte aligned)
+  uint32_t     nentries;       // number of entries (power-of-2)
+} gc_log_t;
+
+typedef struct gc_log_entry {
+  uint32_t     seqno;          // monotonic sequence number
+  uint32_t     timestamp;      // decrementer value (wraps every 53s on PS3)
+  uint16_t     subsystem;      // 0 to 255 reserved for system, user gets 256 and up
+  uint16_t     event;
+  uint32_t     info[5];
+} _AL16 gc_log_entry_t;
+
+#define        GCL_SS_SYS      0       // lowest system reserved subsystem
+#define        GCL_SS_USER   256       // lowest user reserved subsystem
+
+
+/*
+ * The resulting log files can be displayed using using:
+ *
+ *  $ od -t x4 -w32 spu_log.00 | less
+ */
+
+
+#if defined(__SPU__)
+
+/*!
+ * System fills in seqno and timestamp.  User is responsible for the rest.
+ */
+
+void _gc_log_write(gc_log_entry_t entry);
+
+#ifdef ENABLE_GC_LOGGING
+#define gc_log_write(entry) _gc_log_write(entry)
+#else
+#define gc_log_write(entry) do { } while (0)
+#endif
+
+inline static void
+gc_log_write0(int subsystem, int event)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = 0;
+  e.info[1] = 0;
+  e.info[2] = 0;
+  e.info[3] = 0;
+  e.info[4] = 0;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write1(int subsystem, int event,
+             uint32_t info0)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = 0;
+  e.info[2] = 0;
+  e.info[3] = 0;
+  e.info[4] = 0;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write2(int subsystem, int event,
+             uint32_t info0, uint32_t info1)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = 0;
+  e.info[3] = 0;
+  e.info[4] = 0;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write3(int subsystem, int event,
+             uint32_t info0, uint32_t info1, uint32_t info2)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = info2;
+  e.info[3] = 0;
+  e.info[4] = 0;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write4(int subsystem, int event,
+             uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = info2;
+  e.info[3] = info3;
+  e.info[4] = 0;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write5(int subsystem, int event,
+             uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3, uint32_t info4)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = info2;
+  e.info[3] = info3;
+  e.info[4] = info4;
+  gc_log_write(e);
+}
+
+/*!
+ * One time initialization called by system runtime
+ */
+void
+_gc_log_init(gc_log_t log_info);
+
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GCELL_GC_LOGGING_H */
diff --git a/gcell/include/gcell/gc_mbox.h b/gcell/include/gcell/gc_mbox.h
new file mode 100644 (file)
index 0000000..1d577ff
--- /dev/null
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_GC_MBOX_H
+#define INCLUDED_GCELL_GC_MBOX_H
+
+/*
+ * The PPE and SPE exchange a few 32-bit messages via mailboxes.
+ * All have a 4 bit opcode in the high bits.
+ *
+ *      3                   2                   1
+ *    1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |  op   |                        arg                            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+
+#define MK_MBOX_MSG(cmd, args) ((((cmd) & 0xf) << 28) | ((args) & 0x0fffffff))
+#define MBOX_MSG_OP(msg)  (((msg) >> 28) & 0xf)
+#define        MBOX_MSG_ARG(msg) ((msg) & 0x0fffffff)
+
+// PPE to SPE (sent via SPE Read Inbound Mailbox)
+
+#define OP_EXIT                        0x0     // exit now
+#define        OP_GET_SPU_BUFSIZE      0x1 
+
+// SPE to PPE (sent via SPE Write Outbound Interrupt Mailbox)
+
+#define OP_JOBS_DONE           0x2     // arg is 0 or 1, indicating which
+                                       //   gc_completion_info_t contains the info
+#define        OP_SPU_BUFSIZE          0x3     // arg is max number of bytes
+
+
+#endif /* INCLUDED_GCELL_GC_MBOX_H */
diff --git a/gcell/include/gcell/gc_spu_args.h b/gcell/include/gcell/gc_spu_args.h
new file mode 100644 (file)
index 0000000..3719bac
--- /dev/null
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_GC_SPU_ARGS_H
+#define INCLUDED_GCELL_GC_SPU_ARGS_H
+
+#include <gcell/gc_types.h>
+#include <gcell/gc_logging.h>
+
+// args passed to SPE at initialization time
+
+typedef struct gc_spu_args {
+  gc_eaddr_t   queue;          // address of job queue (gc_jd_queue_t *)
+  gc_eaddr_t   comp_info[2];   // completion info (gc_comp_info_t *)
+  uint32_t     spu_idx;        // which spu we are: [0,nspus-1]
+  uint32_t     nspus;          // number of spus we're using
+  uint32_t     proc_def_ls_addr;  // LS addr of proc_def table
+  uint32_t     nproc_defs;        // number of proc_defs in table
+  gc_log_t     log;               // logging info
+} _AL16 gc_spu_args_t;
+
+
+#define        GC_CI_NJOBS     62      // makes gc_comp_info 1 cache line long
+
+/*!
+ * \brief Used to return info to PPE on which jobs are completed.
+ *
+ * When each SPE is initalized, it is passed EA pointers to two of
+ * these structures.  The SPE uses these to communicate which jobs
+ * that it has worked on are complete.  The SPE notifies the PPE by
+ * sending an OP_JOBS_DONE message (see gc_mbox.h) with an argument of
+ * 0 or 1, indicating which of the two comp_info's to examine.  The
+ * SPE sets the in_use flag to 1 before DMA'ing to the PPE.  When the
+ * PPE is done with the structure, it must clear the in_use field to
+ * let the SPE know it can begin using it again.
+ */
+typedef struct gc_comp_info {
+  uint16_t     in_use;         // set by SPE, cleared by PPE when it's finished
+  uint16_t     ncomplete;      // number of valid job_id's
+  uint16_t     job_id[GC_CI_NJOBS];    // job_id's of completed jobs
+} _AL128 gc_comp_info_t;
+
+#endif /* INCLUDED_GCELL_GC_SPU_ARGS_H */
diff --git a/gcell/include/gcell/gc_types.h b/gcell/include/gcell/gc_types.h
new file mode 100644 (file)
index 0000000..b75bcd8
--- /dev/null
@@ -0,0 +1,63 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_GC_TYPES_H
+#define INCLUDED_GCELL_GC_TYPES_H
+
+#include <stdint.h>
+#include <gcell/gc_cdefs.h>
+#include <gcell/compiler.h>
+
+__GC_BEGIN_DECLS
+
+#ifndef __cplusplus
+typedef int bool;
+#define true  1
+#define false 0
+#endif
+
+/*!
+ * \brief 64-bit integer type representing an effective address (EA)
+ *
+ * This type is always 64-bits, regardless of whether we're
+ * running in 32 or 64-bit mode.
+ */
+typedef uint64_t       gc_eaddr_t;
+
+#if !defined(__SPU__)
+static inline void *
+ea_to_ptr(gc_eaddr_t ea)
+{
+  // in 32-bit mode we're tossing the top 32-bits.
+  return (void *) (uintptr_t) ea;
+}
+
+static inline gc_eaddr_t
+ptr_to_ea(void *p)
+{
+  // two steps to avoid compiler warning in 32-bit mode.
+  return (gc_eaddr_t) (uintptr_t) p;
+}
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GCELL_GC_TYPES_H */
diff --git a/gcell/include/gcell/gcp_fft_1d_r2.h b/gcell/include/gcell/gcp_fft_1d_r2.h
new file mode 100644 (file)
index 0000000..c1d3318
--- /dev/null
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCP_FFT_1D_R2_H
+#define INCLUDED_GCP_FFT_1D_R2_H
+
+#include <gcell/gc_job_manager.h>
+#include <complex>
+
+/*!
+ * \brief Submit a job that computes the forward or inverse FFT.
+ *
+ * \param mgr is the job manager instance
+ * \param log2_fft_length is the log2 of the fft_length (4 <= x <= 12).
+ * \param forward is true to compute the forward transform, else the inverse.
+ * \param shift indicates if an "fftshift" should be applied to the output data
+ * \param out is the fft_length output from FFT (must be 16-byte aligned).
+ * \param in is the fft_length input to FFT (must be 16-byte aligned).
+ * \param twiddle is fft_length/4 twiddle factor input to FFT (must be 16-byte aligned).
+ * \param window is the window to be applied to the input data.
+ *    The window length must be either 0 or fft_length (must be 16-byte aligned).
+ *
+ * Returns a shared_ptr to a job descriptor which should be passed to wait_job*.
+ * Throws an exception in the event of a problem.
+ * This uses the FFTW conventions for scaling.  That is, neither the forward nor inverse
+ * are scaled by 1/fft_length.
+ */
+gc_job_desc_sptr
+gcp_fft_1d_r2_submit(gc_job_manager_sptr mgr,
+                    unsigned int log2_fft_length,
+                    bool forward,
+                    bool shift,
+                    std::complex<float> *out,
+                    const std::complex<float> *in,
+                    const std::complex<float> *twiddle,
+                    const float *window);
+
+/*!
+ * \brief Compute twiddle factors 
+ *
+ * \param log2_fft_length is the log2 of the fft_length.
+ * \param W is fft_length/4 twiddle factor output (must be 16-byte aligned).
+ */
+void
+gcp_fft_1d_r2_twiddle(unsigned int log2_fft_length, std::complex<float> *W);
+
+#endif /* INCLUDED_GCP_FFT_1D_R2_H */
diff --git a/gcell/include/gcell/memory_barrier.h b/gcell/include/gcell/memory_barrier.h
new file mode 100644 (file)
index 0000000..4a1f870
--- /dev/null
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_MEMORY_BARRIER_H
+#define INCLUDED_GCELL_MEMORY_BARRIER_H
+
+/*
+ * powerpc memory barriers
+ *
+ * The sync instruction guarantees that all memory accesses initiated
+ * by this processor have been performed (with respect to all other
+ * mechanisms that access memory).  The eieio instruction is a barrier
+ * providing an ordering (separately) for (a) cacheable stores and (b)
+ * loads and stores to non-cacheable memory (e.g. I/O devices).
+ *
+ * smp_mb() prevents loads and stores being reordered across this point.
+ * smp_rmb() prevents loads being reordered across this point.
+ * smp_wmb() prevents stores being reordered across this point.
+ *
+ * We have to use the sync instructions for smp_mb(), since lwsync
+ * doesn't order loads with respect to previous stores.  Lwsync is
+ * fine for smp_rmb(), though.  For smp_wmb(), we use eieio since it
+ * is only used to order updates to system memory.
+ *
+ * For details, see "PowerPC Virtual Environment Architecture, Book
+ * II".  Especially Chapter 1, "Storage Model" and Chapter 3, "Storage
+ * Control Instructions." (site:ibm.com)
+ */
+
+static inline void smp_mb(void)
+{
+  __asm__ volatile ("sync" : : : "memory");
+}
+
+static inline void smp_rmb(void)
+{
+  __asm__ volatile ("lwsync" : : : "memory");
+}
+
+static inline void smp_wmb(void)
+{
+  __asm__ volatile ("eieio" : : : "memory");
+}
+
+
+#endif /* INCLUDED_GCELL_MEMORY_BARRIER_H */
diff --git a/gcell/include/gcell/spu/Makefile.am b/gcell/include/gcell/spu/Makefile.am
new file mode 100644 (file)
index 0000000..5881681
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# Copyright 2007,2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+gcellspuinclude_HEADERS = \
+       fft_1d.h \
+       fft_1d_r2.h \
+       gc_delay.h \
+       gc_jd_queue.h \
+       gc_random.h \
+       gc_spu_macs.h \
+       libfft.h
diff --git a/gcell/include/gcell/spu/fft_1d.h b/gcell/include/gcell/spu/fft_1d.h
new file mode 100644 (file)
index 0000000..355b84b
--- /dev/null
@@ -0,0 +1,103 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _FFT_1D_H_
+#define _FFT_1D_H_     1
+
+#include <spu_intrinsics.h>
+
+/* BIT_SWAP - swaps up to 16 bits of the integer _i according to the 
+ *            pattern specified by _pat.
+ */
+#define BIT_SWAP(_i, _pat)       spu_extract(spu_gather(spu_shuffle(spu_maskb(_i), _pat, _pat)), 0)
+
+
+#ifndef MAX_FFT_1D_SIZE
+#define MAX_FFT_1D_SIZE        8192
+#endif
+
+#ifndef INV_SQRT_2
+#define INV_SQRT_2     0.7071067811865
+#endif
+
+
+/* The following macro, FFT_1D_BUTTERFLY, performs a 4 way SIMD basic butterfly 
+ * operation. The inputs are in parallel arrays (seperate real and imaginary
+ * vectors). 
+ * 
+ *          p --------------------------> P = p + q*Wi
+ *                        \      /
+ *                         \    /
+ *                          \  /
+ *                           \/
+ *                           /\
+ *                          /  \
+ *                         /    \
+ *               ____     /      \
+ *          q --| Wi |-----------------> Q = p - q*Wi
+ *               ----
+ */
+
+#define FFT_1D_BUTTERFLY(_P_re, _P_im, _Q_re, _Q_im, _p_re, _p_im, _q_re, _q_im, _W_re, _W_im) {       \
+  vector float _qw_re, _qw_im;                                                                         \
+                                                                                                       \
+  _qw_re = spu_msub(_q_re, _W_re, spu_mul(_q_im, _W_im));                                              \
+  _qw_im = spu_madd(_q_re, _W_im, spu_mul(_q_im, _W_re));                                              \
+  _P_re  = spu_add(_p_re, _qw_re);                                                                     \
+  _P_im  = spu_add(_p_im, _qw_im);                                                                     \
+  _Q_re  = spu_sub(_p_re, _qw_re);                                                                     \
+  _Q_im  = spu_sub(_p_im, _qw_im);                                                                     \
+}
+
+
+/* FFT_1D_BUTTERFLY_HI is equivalent to FFT_1D_BUTTERFLY with twiddle factors (W_im, -W_re)
+ */
+#define FFT_1D_BUTTERFLY_HI(_P_re, _P_im, _Q_re, _Q_im, _p_re, _p_im, _q_re, _q_im, _W_re, _W_im) {    \
+  vector float _qw_re, _qw_im;                                                                         \
+                                                                                                       \
+  _qw_re = spu_madd(_q_re, _W_im, spu_mul(_q_im, _W_re));                                              \
+  _qw_im = spu_msub(_q_im, _W_im, spu_mul(_q_re, _W_re));                                              \
+  _P_re  = spu_add(_p_re, _qw_re);                                                                     \
+  _P_im  = spu_add(_p_im, _qw_im);                                                                     \
+  _Q_re  = spu_sub(_p_re, _qw_re);                                                                     \
+  _Q_im  = spu_sub(_p_im, _qw_im);                                                                     \
+}
+
+#endif /* _FFT_1D_H_ */
diff --git a/gcell/include/gcell/spu/fft_1d_r2.h b/gcell/include/gcell/spu/fft_1d_r2.h
new file mode 100644 (file)
index 0000000..a51cbc3
--- /dev/null
@@ -0,0 +1,529 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+#ifndef _FFT_1D_R2_H_
+#define _FFT_1D_R2_H_  1
+
+#include "fft_1d.h"
+
+/* fft_1d_r2
+ * ---------
+ * Performs a single precision, complex Fast Fourier Transform using 
+ * the DFT (Discrete Fourier Transform) with radix-2 decimation in time. 
+ * The input <in> is an array of complex numbers of length (1<<log2_size)
+ * entries. The result is returned in the array of complex numbers specified
+ * by <out>. Note: This routine can support an in-place transformation
+ * by specifying <in> and <out> to be the same array.
+ *
+ * This implementation utilizes the Cooley-Tukey algorithm consisting 
+ * of <log2_size> stages. The basic operation is the butterfly.
+ *
+ *          p --------------------------> P = p + q*Wi
+ *                        \      /
+ *                         \    /
+ *                          \  /
+ *                           \/
+ *                           /\
+ *                          /  \
+ *                         /    \
+ *               ____     /      \
+ *          q --| Wi |-----------------> Q = p - q*Wi
+ *               ----
+ *
+ * This routine also requires pre-computed twiddle values, W. W is an
+ * array of single precision complex numbers of length 1<<(log2_size-2) 
+ * and is computed as follows:
+ *
+ *     for (i=0; i<n/4; i++)
+ *         W[i].real =  cos(i * 2*PI/n);
+ *         W[i].imag = -sin(i * 2*PI/n);
+ *      }
+ *
+ * This array actually only contains the first half of the twiddle
+ * factors. Due for symmetry, the second half of the twiddle factors
+ * are implied and equal:
+ *
+ *     for (i=0; i<n/4; i++)
+ *         W[i+n/4].real =  W[i].imag =  sin(i * 2*PI/n);
+ *         W[i+n/4].imag = -W[i].real = -cos(i * 2*PI/n);
+ *      }
+ *
+ * Further symmetry allows one to generate the twiddle factor table 
+ * using half the number of trig computations as follows:
+ *
+ *      W[0].real = 1.0;
+ *      W[0].imag = 0.0;
+ *     for (i=1; i<n/4; i++)
+ *         W[i].real =  cos(i * 2*PI/n);
+ *         W[n/4 - i].imag = -W[i].real;
+ *      }
+ *
+ * The complex numbers are packed into quadwords as follows:
+ *
+ *    quadword                       complex
+ *  array element                   array elements
+ *             -----------------------------------------------------
+ *       i    |  real 2*i   |  imag 2*i  | real 2*i+1  | imag 2*i+1 | 
+ *             -----------------------------------------------------
+ *
+ */
+
+
+static __inline void _fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size)
+{
+  int i, j, k;
+  int stage, offset;
+  int i_rev;
+  int n, n_2, n_4, n_8, n_16, n_3_16;
+  int w_stride, w_2stride, w_3stride, w_4stride;
+  int stride, stride_2, stride_4, stride_3_4;
+  vector float *W0, *W1, *W2, *W3;
+  vector float *re0, *re1, *re2, *re3;
+  vector float *im0, *im1, *im2, *im3;
+  vector float *in0, *in1, *in2, *in3, *in4, *in5, *in6, *in7;
+  vector float *out0, *out1, *out2, *out3;
+  vector float tmp0, tmp1;
+  vector float w0_re, w0_im, w1_re, w1_im;
+  vector float w0, w1, w2, w3;
+  vector float src_lo0, src_lo1, src_lo2, src_lo3;
+  vector float src_hi0, src_hi1, src_hi2, src_hi3;
+  vector float dst_lo0, dst_lo1, dst_lo2, dst_lo3;
+  vector float dst_hi0, dst_hi1, dst_hi2, dst_hi3;
+  vector float out_re_lo0, out_re_lo1, out_re_lo2, out_re_lo3;
+  vector float out_im_lo0, out_im_lo1, out_im_lo2, out_im_lo3;
+  vector float out_re_hi0, out_re_hi1, out_re_hi2, out_re_hi3;
+  vector float out_im_hi0, out_im_hi1, out_im_hi2, out_im_hi3;
+  vector float re_lo0,  re_lo1,  re_lo2,  re_lo3;
+  vector float im_lo0,  im_lo1,  im_lo2,  im_lo3;
+  vector float re_hi0,  re_hi1,  re_hi2,  re_hi3;
+  vector float im_hi0,  im_hi1,  im_hi2,  im_hi3;
+  vector float pq_lo0,  pq_lo1,  pq_lo2,  pq_lo3;
+  vector float pq_hi0,  pq_hi1,  pq_hi2,  pq_hi3;
+  vector float re[MAX_FFT_1D_SIZE/4], im[MAX_FFT_1D_SIZE/4];   /* real & imaginary working arrays */
+  vector float ppmm = (vector float) { 1.0f,  1.0f, -1.0f, -1.0f};
+  vector float pmmp = (vector float) { 1.0f, -1.0f, -1.0f,  1.0f};
+  vector unsigned char reverse;
+  vector unsigned char shuf_lo = (vector unsigned char) {
+                                            0,  1, 2, 3,  4, 5, 6, 7,
+                                            16,17,18,19, 20,21,22,23};
+  vector unsigned char shuf_hi = (vector unsigned char) {
+                                            8,  9,10,11, 12,13,14,15,
+                                            24,25,26,27, 28,29,30,31};
+  vector unsigned char shuf_0202 = (vector unsigned char) {
+                                              0, 1, 2, 3,  8, 9,10,11,
+                                              0, 1, 2, 3,  8, 9,10,11};
+  vector unsigned char shuf_1313 = (vector unsigned char) {
+                                              4, 5, 6, 7, 12,13,14,15,
+                                              4, 5, 6, 7, 12,13,14,15};
+  vector unsigned char shuf_0303 = (vector unsigned char) { 
+                                              0, 1, 2, 3, 12,13,14,15,
+                                              0, 1, 2, 3, 12,13,14,15};
+  vector unsigned char shuf_1212 = (vector unsigned char) {
+                                              4, 5, 6, 7,  8, 9,10,11,
+                                              4, 5, 6, 7,  8, 9,10,11};
+  vector unsigned char shuf_0415 = (vector unsigned char) {
+                                              0, 1, 2, 3, 16,17,18,19,
+                                              4, 5, 6, 7, 20,21,22,23};
+  vector unsigned char shuf_2637 = (vector unsigned char) {
+                                              8, 9,10,11, 24,25,26,27,
+                                              12,13,14,15,28,29,30,31};
+  vector unsigned char shuf_0246 = (vector unsigned char) {
+                                              0, 1, 2, 3,  8, 9,10,11,
+                                              16,17,18,19,24,25,26,27};
+  vector unsigned char shuf_1357 = (vector unsigned char) {
+                                              4, 5, 6, 7, 12,13,14,15,
+                                              20,21,22,23,28,29,30,31};
+  
+  n = 1 << log2_size;
+  n_2  = n >> 1;
+  n_4  = n >> 2;
+  n_8  = n >> 3;
+  n_16 = n >> 4;
+
+  n_3_16 = n_8 + n_16;
+
+  /* Compute a byte reverse shuffle pattern to be used to produce
+   * an address bit swap.
+   */
+  reverse = spu_or(spu_slqwbyte(spu_splats((unsigned char)0x80), log2_size),
+                  spu_rlmaskqwbyte(((vec_uchar16){15,14,13,12, 11,10,9,8, 
+                                                   7, 6, 5, 4,  3, 2,1,0}),
+                                   log2_size-16));
+
+  /* Perform the first 3 stages of the FFT. These stages differs from 
+   * other stages in that the inputs are unscrambled and the data is 
+   * reformated into parallel arrays (ie, seperate real and imaginary
+   * arrays). The term "unscramble" means the bit address reverse the 
+   * data array. In addition, the first three stages have simple twiddle
+   * weighting factors.
+   *           stage 1: (1, 0)
+   *            stage 2: (1, 0) and (0, -1)
+   *           stage 3: (1, 0), (0.707, -0.707), (0, -1), (-0.707, -0.707)
+   *
+   * The arrays are processed as two halves, simultaneously. The lo (first 
+   * half) and hi (second half). This is done because the scramble 
+   * shares source value between each half of the output arrays.
+   */
+  i = 0;
+  i_rev = 0;
+
+  in0 = in;
+  in1 = in + n_8;
+  in2 = in + n_16;
+  in3 = in + n_3_16;  
+
+  in4 = in  + n_4;
+  in5 = in1 + n_4;
+  in6 = in2 + n_4;
+  in7 = in3 + n_4;
+
+  re0 = re;
+  re1 = re + n_8;
+  im0 = im;
+  im1 = im + n_8;
+
+  w0_re = (vector float) { 1.0f,  INV_SQRT_2,  0.0f, -INV_SQRT_2};
+  w0_im = (vector float) { 0.0f, -INV_SQRT_2, -1.0f, -INV_SQRT_2};
+      
+  do {
+    src_lo0 = in0[i_rev];
+    src_lo1 = in1[i_rev];
+    src_lo2 = in2[i_rev];
+    src_lo3 = in3[i_rev];
+
+    src_hi0 = in4[i_rev];
+    src_hi1 = in5[i_rev];
+    src_hi2 = in6[i_rev];
+    src_hi3 = in7[i_rev];
+
+    /* Perform scramble.
+     */
+    dst_lo0 = spu_shuffle(src_lo0, src_hi0, shuf_lo);
+    dst_hi0 = spu_shuffle(src_lo0, src_hi0, shuf_hi);
+    dst_lo1 = spu_shuffle(src_lo1, src_hi1, shuf_lo);
+    dst_hi1 = spu_shuffle(src_lo1, src_hi1, shuf_hi);
+    dst_lo2 = spu_shuffle(src_lo2, src_hi2, shuf_lo);
+    dst_hi2 = spu_shuffle(src_lo2, src_hi2, shuf_hi);
+    dst_lo3 = spu_shuffle(src_lo3, src_hi3, shuf_lo);
+    dst_hi3 = spu_shuffle(src_lo3, src_hi3, shuf_hi);
+
+    /* Perform the stage 1 butterfly. The multiplier constant, ppmm,
+     * is used to control the sign of the operands since a single
+     * quadword contains both of P and Q valule of the butterfly.
+     */
+    pq_lo0 = spu_madd(ppmm, dst_lo0, spu_rlqwbyte(dst_lo0, 8));
+    pq_hi0 = spu_madd(ppmm, dst_hi0, spu_rlqwbyte(dst_hi0, 8));
+    pq_lo1 = spu_madd(ppmm, dst_lo1, spu_rlqwbyte(dst_lo1, 8));
+    pq_hi1 = spu_madd(ppmm, dst_hi1, spu_rlqwbyte(dst_hi1, 8));
+    pq_lo2 = spu_madd(ppmm, dst_lo2, spu_rlqwbyte(dst_lo2, 8));
+    pq_hi2 = spu_madd(ppmm, dst_hi2, spu_rlqwbyte(dst_hi2, 8));
+    pq_lo3 = spu_madd(ppmm, dst_lo3, spu_rlqwbyte(dst_lo3, 8));
+    pq_hi3 = spu_madd(ppmm, dst_hi3, spu_rlqwbyte(dst_hi3, 8));
+
+    /* Perfrom the stage 2 butterfly. For this stage, the 
+     * inputs pq are still interleaved (p.real, p.imag, q.real, 
+     * q.imag), so we must first re-order the data into 
+     * parallel arrays as well as perform the reorder 
+     * associated with the twiddle W[n/4], which equals
+     * (0, -1). 
+     *
+     * ie. (A, B) * (0, -1) => (B, -A)
+     */
+    re_lo0 = spu_madd(ppmm, 
+                     spu_shuffle(pq_lo1, pq_lo1, shuf_0303),
+                     spu_shuffle(pq_lo0, pq_lo0, shuf_0202));
+    im_lo0 = spu_madd(pmmp, 
+                     spu_shuffle(pq_lo1, pq_lo1, shuf_1212),
+                     spu_shuffle(pq_lo0, pq_lo0, shuf_1313));
+
+    re_lo1 = spu_madd(ppmm, 
+                     spu_shuffle(pq_lo3, pq_lo3, shuf_0303),
+                     spu_shuffle(pq_lo2, pq_lo2, shuf_0202));
+    im_lo1 = spu_madd(pmmp, 
+                     spu_shuffle(pq_lo3, pq_lo3, shuf_1212),
+                     spu_shuffle(pq_lo2, pq_lo2, shuf_1313));
+
+
+    re_hi0 = spu_madd(ppmm, 
+                     spu_shuffle(pq_hi1, pq_hi1, shuf_0303),
+                     spu_shuffle(pq_hi0, pq_hi0, shuf_0202));
+    im_hi0 = spu_madd(pmmp, 
+                      spu_shuffle(pq_hi1, pq_hi1, shuf_1212),
+                      spu_shuffle(pq_hi0, pq_hi0, shuf_1313));
+
+    re_hi1 = spu_madd(ppmm, 
+                     spu_shuffle(pq_hi3, pq_hi3, shuf_0303),
+                     spu_shuffle(pq_hi2, pq_hi2, shuf_0202));
+    im_hi1 = spu_madd(pmmp, 
+                     spu_shuffle(pq_hi3, pq_hi3, shuf_1212),
+                     spu_shuffle(pq_hi2, pq_hi2, shuf_1313));
+
+
+    /* Perform stage 3 butterfly.
+     */
+    FFT_1D_BUTTERFLY(re0[0], im0[0], re0[1], im0[1], re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
+    FFT_1D_BUTTERFLY(re1[0], im1[0], re1[1], im1[1], re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
+
+    re0 += 2;
+    re1 += 2;
+    im0 += 2; 
+    im1 += 2;
+    
+    i += 8;
+    i_rev = BIT_SWAP(i, reverse) / 2;
+  } while (i < n_2);
+
+  /* Process stages 4 to log2_size-2
+   */
+  for (stage=4, stride=4; stage<log2_size-1; stage++, stride += stride) {
+    w_stride  = n_2 >> stage;
+    w_2stride = n   >> stage;
+    w_3stride = w_stride +  w_2stride;
+    w_4stride = w_2stride + w_2stride;
+
+    W0 = W;
+    W1 = W + w_stride;
+    W2 = W + w_2stride;
+    W3 = W + w_3stride;
+
+    stride_2 = stride >> 1;
+    stride_4 = stride >> 2;
+    stride_3_4 = stride_2 + stride_4;
+
+    re0 = re;              im0 = im;
+    re1 = re + stride_2;   im1 = im + stride_2;   
+    re2 = re + stride_4;   im2 = im + stride_4;   
+    re3 = re + stride_3_4; im3 = im + stride_3_4;   
+
+    for (i=0, offset=0; i<stride_4; i++, offset += w_4stride) {
+      /* Compute the twiddle factors
+       */
+      w0 = W0[offset];
+      w1 = W1[offset];
+      w2 = W2[offset];
+      w3 = W3[offset];
+
+      tmp0 = spu_shuffle(w0, w2, shuf_0415);
+      tmp1 = spu_shuffle(w1, w3, shuf_0415);
+
+      w0_re = spu_shuffle(tmp0, tmp1, shuf_0415);
+      w0_im = spu_shuffle(tmp0, tmp1, shuf_2637);
+
+      j = i;
+      k = i + stride;
+      do {
+       re_lo0 = re0[j]; im_lo0 = im0[j];
+       re_lo1 = re1[j]; im_lo1 = im1[j];
+
+       re_hi0 = re2[j]; im_hi0 = im2[j];
+       re_hi1 = re3[j]; im_hi1 = im3[j];
+
+       re_lo2 = re0[k]; im_lo2 = im0[k];
+       re_lo3 = re1[k]; im_lo3 = im1[k];
+
+       re_hi2 = re2[k]; im_hi2 = im2[k];
+       re_hi3 = re3[k]; im_hi3 = im3[k];
+
+       FFT_1D_BUTTERFLY   (re0[j], im0[j], re1[j], im1[j], re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
+       FFT_1D_BUTTERFLY_HI(re2[j], im2[j], re3[j], im3[j], re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
+
+       FFT_1D_BUTTERFLY   (re0[k], im0[k], re1[k], im1[k], re_lo2, im_lo2, re_lo3, im_lo3, w0_re, w0_im);
+       FFT_1D_BUTTERFLY_HI(re2[k], im2[k], re3[k], im3[k], re_hi2, im_hi2, re_hi3, im_hi3, w0_re, w0_im);
+
+       j += 2 * stride;
+       k += 2 * stride;
+      } while (j < n_4);
+    }
+  }
+
+  /* Process stage log2_size-1. This is identical to the stage processing above
+   * except for this stage the inner loop is only executed once so it is removed
+   * entirely.
+   */
+  w_stride  = n_2 >> stage;
+  w_2stride = n   >> stage;
+  w_3stride = w_stride +  w_2stride;
+  w_4stride = w_2stride + w_2stride;
+
+  stride_2 = stride >> 1;
+  stride_4 = stride >> 2;
+
+  stride_3_4 = stride_2 + stride_4;
+
+  re0 = re;              im0 = im;
+  re1 = re + stride_2;   im1 = im + stride_2;   
+  re2 = re + stride_4;   im2 = im + stride_4;   
+  re3 = re + stride_3_4; im3 = im + stride_3_4;   
+
+  for (i=0, offset=0; i<stride_4; i++, offset += w_4stride) {
+    /* Compute the twiddle factors
+     */
+    w0 = W[offset];
+    w1 = W[offset + w_stride];
+    w2 = W[offset + w_2stride];
+    w3 = W[offset + w_3stride];
+
+    tmp0 = spu_shuffle(w0, w2, shuf_0415);
+    tmp1 = spu_shuffle(w1, w3, shuf_0415);
+
+    w0_re = spu_shuffle(tmp0, tmp1, shuf_0415);
+    w0_im = spu_shuffle(tmp0, tmp1, shuf_2637);
+
+    j = i;
+    k = i + stride;
+
+    re_lo0 = re0[j]; im_lo0 = im0[j];
+    re_lo1 = re1[j]; im_lo1 = im1[j];
+
+    re_hi0 = re2[j]; im_hi0 = im2[j];
+    re_hi1 = re3[j]; im_hi1 = im3[j];
+
+    re_lo2 = re0[k]; im_lo2 = im0[k];
+    re_lo3 = re1[k]; im_lo3 = im1[k];
+
+    re_hi2 = re2[k]; im_hi2 = im2[k];
+    re_hi3 = re3[k]; im_hi3 = im3[k];
+      
+    FFT_1D_BUTTERFLY   (re0[j], im0[j], re1[j], im1[j], re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
+    FFT_1D_BUTTERFLY_HI(re2[j], im2[j], re3[j], im3[j], re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
+
+    FFT_1D_BUTTERFLY   (re0[k], im0[k], re1[k], im1[k], re_lo2, im_lo2, re_lo3, im_lo3, w0_re, w0_im);
+    FFT_1D_BUTTERFLY_HI(re2[k], im2[k], re3[k], im3[k], re_hi2, im_hi2, re_hi3, im_hi3, w0_re, w0_im);
+  }
+
+
+  /* Process the final stage (stage log2_size). For this stage, 
+   * reformat the data from parallel arrays back into 
+   * interleaved arrays,storing the result into <in>.
+   *
+   * This loop has been manually unrolled by 2 to improve 
+   * dual issue rates and reduce stalls. This unrolling
+   * forces a minimum FFT size of 32.
+   */
+  re0 = re;
+  re1 = re + n_8;
+  re2 = re + n_16;
+  re3 = re + n_3_16;
+
+  im0 = im;
+  im1 = im + n_8;
+  im2 = im + n_16;
+  im3 = im + n_3_16;
+
+  out0 = out;
+  out1 = out + n_4;
+  out2 = out + n_8;
+  out3 = out1 + n_8;
+
+  i = n_16;
+
+  do {
+    /* Fetch the twiddle factors
+     */
+    w0 = W[0];
+    w1 = W[1];
+    w2 = W[2];
+    w3 = W[3];
+
+    W += 4;
+
+    w0_re = spu_shuffle(w0, w1, shuf_0246);
+    w0_im = spu_shuffle(w0, w1, shuf_1357);
+    w1_re = spu_shuffle(w2, w3, shuf_0246);
+    w1_im = spu_shuffle(w2, w3, shuf_1357);
+
+    /* Fetch the butterfly inputs, reals and imaginaries
+     */
+    re_lo0 = re0[0]; im_lo0 = im0[0];
+    re_lo1 = re1[0]; im_lo1 = im1[0];
+    re_lo2 = re0[1]; im_lo2 = im0[1];
+    re_lo3 = re1[1]; im_lo3 = im1[1];
+
+    re_hi0 = re2[0]; im_hi0 = im2[0];
+    re_hi1 = re3[0]; im_hi1 = im3[0];
+    re_hi2 = re2[1]; im_hi2 = im2[1];
+    re_hi3 = re3[1]; im_hi3 = im3[1];
+
+    re0 += 2; im0 += 2;
+    re1 += 2; im1 += 2;
+    re2 += 2; im2 += 2;
+    re3 += 2; im3 += 2;
+
+    /* Perform the butterflys
+     */
+    FFT_1D_BUTTERFLY   (out_re_lo0, out_im_lo0, out_re_lo1, out_im_lo1, re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
+    FFT_1D_BUTTERFLY   (out_re_lo2, out_im_lo2, out_re_lo3, out_im_lo3, re_lo2, im_lo2, re_lo3, im_lo3, w1_re, w1_im);
+
+    FFT_1D_BUTTERFLY_HI(out_re_hi0, out_im_hi0, out_re_hi1, out_im_hi1, re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
+    FFT_1D_BUTTERFLY_HI(out_re_hi2, out_im_hi2, out_re_hi3, out_im_hi3, re_hi2, im_hi2, re_hi3, im_hi3, w1_re, w1_im);
+
+    /* Interleave the results and store them into the output buffers (ie,
+     * the original input buffers.
+     */
+    out0[0] = spu_shuffle(out_re_lo0, out_im_lo0, shuf_0415);
+    out0[1] = spu_shuffle(out_re_lo0, out_im_lo0, shuf_2637);
+    out0[2] = spu_shuffle(out_re_lo2, out_im_lo2, shuf_0415);
+    out0[3] = spu_shuffle(out_re_lo2, out_im_lo2, shuf_2637);
+
+    out1[0] = spu_shuffle(out_re_lo1, out_im_lo1, shuf_0415);
+    out1[1] = spu_shuffle(out_re_lo1, out_im_lo1, shuf_2637);
+    out1[2] = spu_shuffle(out_re_lo3, out_im_lo3, shuf_0415);
+    out1[3] = spu_shuffle(out_re_lo3, out_im_lo3, shuf_2637);
+
+    out2[0] = spu_shuffle(out_re_hi0, out_im_hi0, shuf_0415);
+    out2[1] = spu_shuffle(out_re_hi0, out_im_hi0, shuf_2637);
+    out2[2] = spu_shuffle(out_re_hi2, out_im_hi2, shuf_0415);
+    out2[3] = spu_shuffle(out_re_hi2, out_im_hi2, shuf_2637);
+
+    out3[0] = spu_shuffle(out_re_hi1, out_im_hi1, shuf_0415);
+    out3[1] = spu_shuffle(out_re_hi1, out_im_hi1, shuf_2637);
+    out3[2] = spu_shuffle(out_re_hi3, out_im_hi3, shuf_0415);
+    out3[3] = spu_shuffle(out_re_hi3, out_im_hi3, shuf_2637);
+
+    out0 += 4;
+    out1 += 4;
+    out2 += 4;
+    out3 += 4;
+
+    i -= 2;
+  } while (i);
+}
+
+#endif /* _FFT_1D_R2_H_ */
diff --git a/gcell/include/gcell/spu/gc_delay.h b/gcell/include/gcell/spu/gc_delay.h
new file mode 100644 (file)
index 0000000..e995b3a
--- /dev/null
@@ -0,0 +1,27 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_SPU_GC_DELAY_H
+#define INCLUDED_GCELL_SPU_GC_DELAY_H
+
+void gc_udelay(unsigned int usecs);
+void gc_cdelay(unsigned int cpu_cycles);
+
+#endif /* INCLUDED_GCELL_SPU_GC_DELAY_H */
diff --git a/gcell/include/gcell/spu/gc_jd_queue.h b/gcell/include/gcell/spu/gc_jd_queue.h
new file mode 100644 (file)
index 0000000..ce1977c
--- /dev/null
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GCELL_SPU_GC_JD_QUEUE_H
+#define INCLUDED_GCELL_SPU_GC_JD_QUEUE_H
+
+#include <gcell/gc_jd_queue_data.h>
+
+/*
+ * Declarations for SPU side of job queue interface
+ */
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Remove and return item at head of queue.
+ *
+ * \param[in]  q is EA address of queue structure.
+ * \param[out] item_ea is EA address of item at head of queue.
+ * \param[in]  jd_tag is the tag to use to get the LS copy of the item.
+ * \param[out] item is local store copy of item at head of queue.
+ * \returns false if the queue is empty, otherwise returns true
+ *   and sets \p item_ea and DMA's job descriptor into \p item
+ *
+ * If return is false, we're holding a lock-line reservation that
+ * covers the queue.
+ */
+bool
+gc_jd_queue_dequeue(gc_eaddr_t q, gc_eaddr_t *item_ea,
+                   int jd_tag, gc_job_desc_t *item);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GCELL_SPU_GC_JD_QUEUE_H */
diff --git a/gcell/include/gcell/spu/gc_random.h b/gcell/include/gcell/spu/gc_random.h
new file mode 100644 (file)
index 0000000..f51b187
--- /dev/null
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_SPU_GC_RANDOM_H
+#define INCLUDED_GCELL_SPU_GC_RANDOM_H
+
+/*!
+ * \brief Return a uniformly distributed value in the range [0, 1.0)
+ * (Linear congruential generator. YMMV. Caveat emptor.)
+ */
+
+float gc_uniform_deviate(void);
+void gc_set_seed(int seed);
+
+#endif /* INCLUDED_GCELL_SPU_GC_RANDOM_H */
diff --git a/gcell/include/gcell/spu/gc_spu_macs.h b/gcell/include/gcell/spu/gc_spu_macs.h
new file mode 100644 (file)
index 0000000..0d7dc99
--- /dev/null
@@ -0,0 +1,380 @@
+/* -*- asm -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GC_SPU_MACS_H
+#define INCLUDED_GC_SPU_MACS_H
+
+/*
+ * This file contains a set of macros that are generally useful when
+ * coding in SPU assembler
+ *
+ * Note that the multi-instruction macros in here may overwrite
+ * registers 77, 78, and 79 without warning.
+ */
+
+/*
+ * defines for all registers
+ */
+#define r0     $0
+#define r1     $1
+#define r2     $2
+#define r3     $3
+#define r4     $4
+#define r5     $5
+#define r6     $6
+#define r7     $7
+#define r8     $8
+#define r9     $9
+#define r10    $10
+#define r11    $11
+#define r12    $12
+#define r13    $13
+#define r14    $14
+#define r15    $15
+#define r16    $16
+#define r17    $17
+#define r18    $18
+#define r19    $19
+#define r20    $20
+#define r21    $21
+#define r22    $22
+#define r23    $23
+#define r24    $24
+#define r25    $25
+#define r26    $26
+#define r27    $27
+#define r28    $28
+#define r29    $29
+#define r30    $30
+#define r31    $31
+#define r32    $32
+#define r33    $33
+#define r34    $34
+#define r35    $35
+#define r36    $36
+#define r37    $37
+#define r38    $38
+#define r39    $39
+#define r40    $40
+#define r41    $41
+#define r42    $42
+#define r43    $43
+#define r44    $44
+#define r45    $45
+#define r46    $46
+#define r47    $47
+#define r48    $48
+#define r49    $49
+#define r50    $50
+#define r51    $51
+#define r52    $52
+#define r53    $53
+#define r54    $54
+#define r55    $55
+#define r56    $56
+#define r57    $57
+#define r58    $58
+#define r59    $59
+#define r60    $60
+#define r61    $61
+#define r62    $62
+#define r63    $63
+#define r64    $64
+#define r65    $65
+#define r66    $66
+#define r67    $67
+#define r68    $68
+#define r69    $69
+#define r70    $70
+#define r71    $71
+#define r72    $72
+#define r73    $73
+#define r74    $74
+#define r75    $75
+#define r76    $76
+#define r77    $77
+#define r78    $78
+#define r79    $79
+#define r80    $80
+#define r81    $81
+#define r82    $82
+#define r83    $83
+#define r84    $84
+#define r85    $85
+#define r86    $86
+#define r87    $87
+#define r88    $88
+#define r89    $89
+#define r90    $90
+#define r91    $91
+#define r92    $92
+#define r93    $93
+#define r94    $94
+#define r95    $95
+#define r96    $96
+#define r97    $97
+#define r98    $98
+#define r99    $99
+#define r100   $100
+#define r101   $101
+#define r102   $102
+#define r103   $103
+#define r104   $104
+#define r105   $105
+#define r106   $106
+#define r107   $107
+#define r108   $108
+#define r109   $109
+#define r110   $110
+#define r111   $111
+#define r112   $112
+#define r113   $113
+#define r114   $114
+#define r115   $115
+#define r116   $116
+#define r117   $117
+#define r118   $118
+#define r119   $119
+#define r120   $120
+#define r121   $121
+#define r122   $122
+#define r123   $123
+#define r124   $124
+#define r125   $125
+#define r126   $126
+#define r127   $127
+
+
+#define        lr      r0      // link register
+#define        sp      r1      // stack pointer
+                        // r2 is environment pointer for langs that need it (ALGOL)
+
+#define        retval  r3      // return values are passed in regs starting at r3
+
+#define        arg1    r3      // args are passed in regs starting at r3
+#define        arg2    r4
+#define        arg3    r5
+#define        arg4    r6
+#define        arg5    r7
+#define        arg6    r8
+#define        arg7    r9
+#define        arg8    r10
+#define        arg9    r11
+#define        arg10   r12
+
+//  r3 -  r74 are volatile (caller saves)
+// r74 -  r79 are volatile (scratch regs possibly destroyed by fct prolog/epilog)
+// r80 - r127 are non-volatile (callee-saves)
+
+// scratch registers reserved for use by the macros in this file.
+
+#define _gc_t0 r79
+#define        _gc_t1  r78
+#define        _gc_t2  r77
+
+/*
+ * ----------------------------------------------------------------
+ *                         pseudo ops
+ * ----------------------------------------------------------------
+ */
+#define PROC_ENTRY(name)               \
+        .text;                         \
+       .p2align 4;                     \
+       .global name;                   \
+       .type   name, @function;        \
+name:
+
+/*
+ * ----------------------------------------------------------------
+ *                 aliases for common operations
+ * ----------------------------------------------------------------
+ */
+
+// Move register (even pipe, 2 cycles)
+#define MR(rt, ra)                     or      rt, ra, ra;
+
+// Move register (odd pipe, 4 cycles)
+#define        LMR(rt, ra)                     rotqbyi rt, ra, 0;
+
+// return
+#define        RETURN()                        bi      lr;
+
+// hint for a return
+#define        HINT_RETURN(ret_label)          hbr     ret_label, lr;
+
+// return if zero
+#define BRZ_RETURN(rt)                 biz     rt, lr;
+
+// return if not zero
+#define BRNZ_RETURN(rt)                        binz    rt, lr;
+
+// return if halfword zero
+#define        BRHZ_RETURN(rt)                 bihz    rt, lr;
+
+// return if halfword not zero
+#define BRHNZ_RETURN(rt)               bihnz   rt, lr;
+
+
+/*
+ * ----------------------------------------------------------------
+ * modulo like things for constant moduli that are powers of 2
+ * ----------------------------------------------------------------
+ */
+
+// rt = ra & (pow2 - 1)
+#define MODULO(rt, ra, pow2) \
+       andi    rt, ra, (pow2)-1;
+
+// rt = pow2 - (ra & (pow2 - 1))
+#define MODULO_NEG(rt, ra, pow2) \
+       andi    rt, ra, (pow2)-1;               \
+       sfi     rt, rt, (pow2);
+
+// rt = ra & -(pow2)
+#define        ROUND_DOWN(rt, ra, pow2) \
+       andi    rt, ra, -(pow2);
+
+// rt = (ra + (pow2 - 1)) & -(pow2)
+#define ROUND_UP(rt, ra, pow2) \
+       ai      rt, ra, (pow2)-1;               \
+       andi    rt, rt, -(pow2);
+
+/*
+ * ----------------------------------------------------------------
+ * Splat - replicate a particular slot into all slots
+ * Altivec analogs...
+ * ----------------------------------------------------------------
+ */
+
+// replicate byte from slot s [0,15]
+#define VSPLTB(rt, ra, s) \
+       ilh     _gc_t0, (s)*0x0101;             \
+       shufb   rt, ra, ra, _gc_t0;
+
+// replicate halfword from slot s [0,7]
+#define        VSPLTH(rt, ra, s) \
+       ilh     _gc_t0, 2*(s)*0x0101 + 0x0001;  \
+       shufb   rt, ra, ra, _gc_t0;
+
+// replicate word from slot s [0,3]
+#define VSPLTW(rt, ra, s) \
+       iluh    _gc_t0, 4*(s)*0x0101 + 0x0001;  \
+       iohl    _gc_t0, 4*(s)*0x0101 + 0x0203;  \
+       shufb   rt, ra, ra, _gc_t0;
+       
+// replicate double from slot s [0,1]
+#define        VSPLTD(rt, ra, s) \
+       /* sp is always 16-byte aligned */ \
+       cdd     _gc_t0, 8(sp);          /* 0x10111213 14151617 00010203 04050607 */ \
+       rotqbyi rt, ra, ra, (s) << 3;   /* rotate double into preferred slot     */ \
+       shufb   rt, rt, rt, _gc_t0;
+
+/*
+ * ----------------------------------------------------------------
+ * lots of min/max variations...
+ *
+ * On a slot by slot basis, compute the min or max
+ *
+ * U - unsigned, else signed
+ * B,H,{} - byte, halfword, word
+ * F float
+ * ----------------------------------------------------------------
+ */
+
+#define MIN_SELB(rt, ra, rb, rc)       selb    rt, ra, rb, rc;
+#define MAX_SELB(rt, ra, rb, rc)       selb    rt, rb, ra, rc;
+       
+       // words
+
+#define MIN(rt, ra, rb) \
+       cgt     _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        MAX(rt, ra, rb) \
+       cgt     _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+#define UMIN(rt, ra, rb) \
+       clgt    _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        UMAX(rt, ra, rb) \
+       clgt    _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+       // bytes
+       
+#define MINB(rt, ra, rb) \
+       cgtb    _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        MAXB(rt, ra, rb) \
+       cgtb    _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+#define UMINB(rt, ra, rb) \
+       clgtb   _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        UMAXB(rt, ra, rb) \
+       clgtb   _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+       // halfwords
+       
+#define MINH(rt, ra, rb) \
+       cgth    _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        MAXH(rt, ra, rb) \
+       cgth    _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+#define UMINH(rt, ra, rb) \
+       clgth   _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        UMAXH(rt, ra, rb) \
+       clgth   _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+       // floats
+       
+#define FMIN(rt, ra, rb) \
+       fcgt    _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+#define        FMAX(rt, ra, rb) \
+       fcgt    _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+// Ignoring the sign, select the values with the minimum magnitude
+#define FMINMAG(rt, ra, rb) \
+       fcmgt   _gc_t0, ra, rb; \
+       MIN_SELB(rt, ra, rb, _gc_t0)
+       
+// Ignoring the sign, select the values with the maximum magnitude
+#define        FMAXMAG(rt, ra, rb) \
+       fcmgt   _gc_t0, ra, rb; \
+       MAX_SELB(rt, ra, rb, _gc_t0)
+
+
+#endif /* INCLUDED_GC_SPU_MACS_H */
diff --git a/gcell/include/gcell/spu/libfft.h b/gcell/include/gcell/spu/libfft.h
new file mode 100644 (file)
index 0000000..dd387be
--- /dev/null
@@ -0,0 +1,113 @@
+/* --------------------------------------------------------------  */
+/* (C)Copyright 2008 Free Software Foundation, Inc.                */
+/* (C)Copyright 2001,2007,                                         */
+/* International Business Machines Corporation,                    */
+/* Sony Computer Entertainment, Incorporated,                      */
+/* Toshiba Corporation,                                            */
+/*                                                                 */
+/* All Rights Reserved.                                            */
+/*                                                                 */
+/* Redistribution and use in source and binary forms, with or      */
+/* without modification, are permitted provided that the           */
+/* following conditions are met:                                   */
+/*                                                                 */
+/* - Redistributions of source code must retain the above copyright*/
+/*   notice, this list of conditions and the following disclaimer. */
+/*                                                                 */
+/* - Redistributions in binary form must reproduce the above       */
+/*   copyright notice, this list of conditions and the following   */
+/*   disclaimer in the documentation and/or other materials        */
+/*   provided with the distribution.                               */
+/*                                                                 */
+/* - Neither the name of IBM Corporation nor the names of its      */
+/*   contributors may be used to endorse or promote products       */
+/*   derived from this software without specific prior written     */
+/*   permission.                                                   */
+/*                                                                 */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
+/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
+/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
+/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
+/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
+/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
+/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
+/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
+/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
+/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
+/* --------------------------------------------------------------  */
+/* PROLOG END TAG zYx                                              */
+
+#ifndef INCLUDED_LIBFFT_H
+#define INCLUDED_LIBFFT_H
+
+// must be defined before inclusion of fft_1d_r2.h
+#define MAX_FFT_1D_SIZE 4096
+
+/* fft_1d_r2
+ * ---------
+ * Performs a single precision, complex Fast Fourier Transform using 
+ * the DFT (Discrete Fourier Transform) with radix-2 decimation in time. 
+ * The input <in> is an array of complex numbers of length (1<<log2_size)
+ * entries. The result is returned in the array of complex numbers specified
+ * by <out>. Note: This routine can support an in-place transformation
+ * by specifying <in> and <out> to be the same array.
+ *
+ * This implementation utilizes the Cooley-Tukey algorithm consisting 
+ * of <log2_size> stages. The basic operation is the butterfly.
+ *
+ *          p --------------------------> P = p + q*Wi
+ *                        \      /
+ *                         \    /
+ *                          \  /
+ *                           \/
+ *                           /\
+ *                          /  \
+ *                         /    \
+ *               ____     /      \
+ *          q --| Wi |-----------------> Q = p - q*Wi
+ *               ----
+ *
+ * This routine also requires pre-computed twiddle values, W. W is an
+ * array of single precision complex numbers of length 1<<(log2_size-2) 
+ * and is computed as follows:
+ *
+ *     for (i=0; i<n/4; i++)
+ *         W[i].real =  cos(i * 2*PI/n);
+ *         W[i].imag = -sin(i * 2*PI/n);
+ *      }
+ *
+ * This array actually only contains the first half of the twiddle
+ * factors. Due for symmetry, the second half of the twiddle factors
+ * are implied and equal:
+ *
+ *     for (i=0; i<n/4; i++)
+ *         W[i+n/4].real =  W[i].imag =  sin(i * 2*PI/n);
+ *         W[i+n/4].imag = -W[i].real = -cos(i * 2*PI/n);
+ *      }
+ *
+ * Further symmetry allows one to generate the twiddle factor table 
+ * using half the number of trig computations as follows:
+ *
+ *      W[0].real = 1.0;
+ *      W[0].imag = 0.0;
+ *     for (i=1; i<n/4; i++)
+ *         W[i].real =  cos(i * 2*PI/n);
+ *         W[n/4 - i].imag = -W[i].real;
+ *      }
+ *
+ * The complex numbers are packed into quadwords as follows:
+ *
+ *    quadword                       complex
+ *  array element                   array elements
+ *             -----------------------------------------------------
+ *       i    |  real 2*i   |  imag 2*i  | real 2*i+1  | imag 2*i+1 | 
+ *             -----------------------------------------------------
+ *
+ */
+
+void fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size);
+
+#endif /* INCLUDED_LIBFFT_H */
diff --git a/gcell/lib/Makefile.am b/gcell/lib/Makefile.am
new file mode 100644 (file)
index 0000000..e7b3493
--- /dev/null
@@ -0,0 +1,50 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = spu runtime general wrapper .
+
+# generate libgcell.la from the convenience libraries in subdirs
+
+lib_LTLIBRARIES = libgcell.la libgcell-qa.la
+
+libgcell_la_SOURCES = 
+libgcell_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
+
+libgcell_qa_la_SOURCES = 
+libgcell_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
+
+libgcell_la_LIBADD = \
+       runtime/libruntime.la \
+       wrapper/libwrapper.la \
+       -lspe2 \
+       $(OMNITHREAD_LA)
+
+libgcell_qa_la_LIBADD = \
+       runtime/libruntime-qa.la \
+       wrapper/libwrapper-qa.la \
+       $(CPPUNIT_LIBS)
+
+
+
+
+
+
diff --git a/gcell/lib/general/Makefile.am b/gcell/lib/general/Makefile.am
new file mode 100644 (file)
index 0000000..bd5a4de
--- /dev/null
@@ -0,0 +1,23 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+
diff --git a/gcell/lib/general/spu/fft_1d_r2.c b/gcell/lib/general/spu/fft_1d_r2.c
new file mode 100644 (file)
index 0000000..0a87e74
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/spu/libfft.h>
+#include <gcell/spu/fft_1d_r2.h>
+#include <assert.h>
+
+/*
+ * invoke the inline version
+ */
+void 
+fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size)
+{
+  assert((1 << log2_size) <= MAX_FFT_1D_SIZE);
+
+  _fft_1d_r2(out, in, W, log2_size);
+}
diff --git a/gcell/lib/general/spu/memset.S b/gcell/lib/general/spu/memset.S
new file mode 100644 (file)
index 0000000..39eabce
--- /dev/null
@@ -0,0 +1,185 @@
+/* -*- asm -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/spu/gc_spu_macs.h>
+
+       .file "memset.S"
+
+       /*
+        * Computes this, only a lot faster...
+        *
+        *      void *
+        *      memset(void *pv, int c, size_t n)
+        *      {
+        *        unsigned char *p = (unsigned char *) pv;
+        *        size_t i;
+        *        for (i = 0; i < n; i++)
+        *          p[i] = c;
+        *      
+        *        return pv;
+        *      }
+        */
+       
+#define        p_arg   arg1    // we're going to clobber arg1 w/ the return value
+#define        c       arg2    // the constant we're writing
+#define        n       arg3    // how many bytes to write
+
+#define        p       r13     // where we're writing
+#define        t0      r14
+#define t1     r15
+#define        mask    r16
+#define        old     r17
+#define an     r18     // aligned n (n rounded down to mod 16 boundary)
+#define        next_p  r19
+#define        cond1   r20
+#define        cond2   r21                             
+#define m      r22
+#define r      r23
+       
+       PROC_ENTRY(memset)
+       
+       // Hint the return from do_head, in case we go that way.
+       // There's pretty much nothing to can do to hint the branch to it.
+       hbrr    do_head_br, head_complete
+       
+       MR(p, p_arg)    // leaves p, the return value, in the correct reg (r3)
+       BRZ_RETURN(n)
+
+       MODULO(t0, p, 16)       // is p%16 == 0?
+       VSPLTB(c, c, 3)         // splat byte in preferred slot of c into all slots
+       brnz    t0, do_head     // no, handle it
+head_complete:
+
+       /*
+        * preconditions:       
+        *   p%16 == 0, n > 0
+        */
+       hbrr    middle_loop_br, middle_loop
+       
+       ROUND_DOWN(an, n, 16)   // an is "aligned n"
+       MODULO(n, n, 16)        // what's left over in the last quad
+       brz     an, do_tail     // no whole quad words; skip to tail
+       clgti   t0, an, 127     // an >= 128?
+       brz     t0, middle2     // nope, go handle the cases between 0 and 112
+
+       /*
+        * 128 bytes / iteration
+        */
+       .p2align 4
+middle_loop:
+       ai      an, an, -128
+         stqd  c,  0*16(p)
+       ai      next_p, p, 128
+         stqd  c,  1*16(p)
+       cgti    cond1, an, 127
+         stqd  c,  2*16(p)
+
+         stqd  c,  3*16(p)
+         stqd  c,  4*16(p)
+         stqd  c,  5*16(p)
+         stqd  c,  6*16(p)
+       
+       MR(p, next_p)
+         stqd  c,  7*16-128(next_p)
+       or      cond2, n, an
+middle_loop_br:
+         brnz  cond1, middle_loop
+       
+       /*
+        * if an and n are both zero, return now 
+        */
+       BRZ_RETURN(cond2)
+
+       /*
+        * otherwise handle last of full quad words 
+        *
+        *   0 <= an < 128, p%16 == 0
+        */
+middle2:
+       /*
+        * if an == 0, go handle the final non-full quadword
+        */
+       brz     an, do_tail
+       hbrr    middle2_loop_br, middle2_loop
+       
+       .p2align 3
+middle2_loop:  
+       ai      next_p, p, 16
+         stqd  c, 0(p)
+       ai      an, an, -16
+         LMR(p, next_p)
+middle2_loop_br:
+         brnz  an, middle2_loop
+       
+       /* We're done with the full quadwords. */
+       
+       /*
+        * Handle the final partial quadword.
+        * We'll be modifying only the left hand portion of the quad.
+        *
+        * preconditions:
+        *   an == 0, 0 <= n < 16, p%16 == 0
+        */
+do_tail:
+       HINT_RETURN(do_tail_ret)
+       il      mask, -1
+       sfi     t1, n, 16               // t1 = 16 - n
+       lqd     old, 0(p)
+       shlqby  mask, mask, t1
+       selb    t0, old, c, mask
+       stqd    t0, 0(p)
+do_tail_ret:   
+       RETURN()
+
+       /*
+        * ----------------------------------------------------------------
+        * Handle the first partial quadword
+        *
+        * preconditions:
+        *   p%16 != 0
+        *
+         * postconditions:
+         *   p%16 == 0 or n == 0
+         *
+         *        |-- m --|
+         *     +----------------+----------------+
+         *     |  ////////      |                |
+         *     +----------------+----------------+
+         *        |----- r -----|
+         *        p
+         * ----------------------------------------------------------------
+        */
+do_head:
+       lqd     old, 0(p)
+       MODULO_NEG(r, p, 16)
+       il      mask, -1
+       UMIN(m, r, n)
+       shlqby  mask, mask, m   // 1's in the top, m*8 0's in the bottom
+       MR(t1, p)
+       sf      t0, m, r        // t0 = r - m
+       a       p, p, m         // p += m
+       rotqby  mask, mask, t0  // rotate 0's to the right place        
+       sf      n, m, n         // n -= m
+       selb    t0, c, old, mask // merge
+       stqd    t0, 0(t1)
+       BRZ_RETURN(n)
+do_head_br:
+       br      head_complete
diff --git a/gcell/lib/general/spu/qa_memset.c b/gcell/lib/general/spu/qa_memset.c
new file mode 100644 (file)
index 0000000..e51b02c
--- /dev/null
@@ -0,0 +1,201 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_declare_proc.h>
+#include <spu_intrinsics.h>
+#include <spu_mfcio.h>
+#include <string.h>
+#include <stdio.h>
+
+
+#define MAX_QA_BYTES  1024
+#define        MAX_OFFSET    32
+#define        ALIGNMENT     16
+#define        K             0xA5
+
+// FIXME should be passed at gcell init time
+//static const int TIMEBASE = 79800000; // ps3
+static const int TIMEBASE = 26666666; // qs21
+
+typedef void* (*memset_fptr)(void *s, int val, size_t n);
+
+void *
+memset_ref(void *sv, int c, size_t n)
+{
+  unsigned char *s = (unsigned char *) sv;
+  size_t i;
+  for (i = 0; i < n; i++)
+    s[i] = c;
+
+  return sv;
+}
+
+static bool
+check_before(unsigned char *buf, size_t len, size_t offset)
+{
+  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+  bool ok = true;
+  int i;
+
+  for (i = -16; i < 0; i++){
+    unsigned char expected = (&p[i] - buf) & 0xff;
+    if (p[i] != expected){
+      printf("b:memset(%p, 0x%x, %zu) <offset %2zd> [%3d] expected %02x, got %02x\n",
+            p, K, len, offset, i, K, p[i]);
+      ok = false;
+    }
+  }
+  return ok;
+}
+
+static bool
+check_middle(unsigned char *buf, size_t len, size_t offset)
+{
+  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+  bool ok = true;
+  size_t i;
+
+  for (i = 0; i < len; i++){
+    unsigned char expected = K;
+    if (p[i] != expected){
+      printf("m:memset(%p, 0x%x, %zu) <offset %2zd> [%3zd] expected %02x, got %02x\n",
+            p, K, len, offset, i, expected, p[i]);
+      ok = false;
+    }
+  }
+  return ok;
+}
+
+static bool
+check_after(unsigned char *buf, size_t len, size_t offset)
+{
+  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+  bool ok = true;
+  size_t i;
+
+  for (i = len; i < len + 16; i++){
+    unsigned char expected = (&p[i] - buf) & 0xff;
+    if (p[i] != expected){
+      printf("a:memset(%p, 0x%x, %zu) <offset %2zd> [%3zd] expected %02x, got %02x\n",
+            p, K, len, offset, i, expected, p[i]);
+      ok = false;
+    }
+  }
+  return ok;
+}
+
+
+static bool
+test_memset_aux(memset_fptr f,
+               unsigned char *buf, size_t buflen, size_t len, size_t offset)
+{
+  size_t i;
+
+  // init buffer to non-zero known state
+  for (i = 0; i < buflen; i++)
+    buf[i] = i;
+  
+  // Our working buffer.  Starts 16 bytes + offset into buf.
+  // We offset by 16 so that we can see if data before is getting damaged.
+  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+
+  (*f)(p, K, len);
+
+  bool ok = true;
+  ok &= check_before(buf, len, offset);
+  ok &= check_middle(buf, len, offset);
+  ok &= check_after(buf, len, offset);
+
+  return ok;
+}
+
+bool
+test_memset(memset_fptr f)
+{
+  size_t BUFLEN = MAX_QA_BYTES + 2*sizeof(vector unsigned char) + MAX_OFFSET;
+  unsigned char unaligned_buf[BUFLEN + ALIGNMENT -1];
+  unsigned char *aligned_buf =
+    (unsigned char *)((((intptr_t) unaligned_buf) + ALIGNMENT - 1) & -ALIGNMENT);
+
+  // printf("unaligned = %p\n", unaligned_buf);
+  // printf("aligned   = %p\n", aligned_buf);
+
+  size_t len;
+  size_t offset;
+  bool ok = true;
+
+  for (len = 0; len < MAX_QA_BYTES; len++){
+    for (offset = 0; offset <= MAX_OFFSET; offset++){
+      ok &= test_memset_aux(f, aligned_buf, BUFLEN, len, offset);
+    }
+  }
+
+  return ok;
+}
+
+// returns bytes/s
+float
+benchmark_memset(memset_fptr f, bool aligned)
+{
+  static const int SIZE = 32768;
+  unsigned char buf[SIZE];
+  uint32_t     t0, t1;
+  int          nbytes;
+
+  spu_write_decrementer(0xffffffff);
+
+  if (aligned){
+    nbytes = SIZE;
+    t0 = spu_read_decrementer();
+    (*f)(buf, 0x55, nbytes);
+    (*f)(buf, 0x55, nbytes);
+    (*f)(buf, 0x55, nbytes);
+    (*f)(buf, 0x55, nbytes);
+    t1 = spu_read_decrementer();
+  }
+  else {
+    nbytes = SIZE - 2;
+    t0 = spu_read_decrementer();
+    (*f)(buf + 1, 0x55, nbytes);
+    (*f)(buf + 1, 0x55, nbytes);
+    (*f)(buf + 1, 0x55, nbytes);
+    (*f)(buf + 1, 0x55, nbytes);
+    t1 = spu_read_decrementer();
+  }
+
+  //printf("delta ticks: %d\n", t0 - t1);
+  return (float) nbytes * 4 / ((t0 - t1) * 1.0/TIMEBASE);
+}
+
+/*
+ * Implement the standard QA stub.
+ * No input arguments, 1 bool output.
+ */
+static void
+gcs_qa_memset(const gc_job_direct_args_t *input _UNUSED,
+             gc_job_direct_args_t *output,
+             const gc_job_ea_args_t *eaa _UNUSED)
+{
+  bool ok = test_memset(memset);
+  output->arg[0].u32 = ok;
+}
+
+GC_DECLARE_PROC(gcs_qa_memset, "qa_memset");
diff --git a/gcell/lib/runtime/Makefile.am b/gcell/lib/runtime/Makefile.am
new file mode 100644 (file)
index 0000000..2c65391
--- /dev/null
@@ -0,0 +1,66 @@
+#
+# Copyright 2007,2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/ibm/sync/ppu_source
+
+
+AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(MBLOCK_INCLUDES) $(CPPUNIT_INCLUDES) \
+       $(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) $(WITH_INCLUDES)
+
+
+dist_bin_SCRIPTS = gcell-embedspu-libtool
+
+noinst_LTLIBRARIES = libruntime.la libruntime-qa.la
+
+libruntime_la_SOURCES = \
+       gc_aligned_alloc.cc \
+       gc_job_manager.cc \
+       gc_job_manager_impl.cc \
+       gc_jd_queue.c \
+       gc_jd_stack.c \
+       gc_proc_def_utils.cc
+
+libruntime_qa_la_SOURCES = \
+       qa_gcell_runtime.cc \
+       qa_jd_queue.cc \
+       qa_jd_stack.cc \
+       qa_job_manager.cc
+
+
+noinst_HEADERS = \
+       gc_client_thread_info.h \
+       gc_job_manager_impl.h \
+       gc_proc_def_utils.h \
+       qa_jd_queue.h \
+       qa_jd_stack.h \
+       qa_job_manager.h \
+       qa_gcell_runtime.h
+
+# generate a libtool.lo that contains an embeded SPU executable
+gcell_runtime_qa.lo: ../spu/gcell_runtime_qa
+       $(GCELL_EMBEDSPU_LIBTOOL) $< $@
+
+libruntime_qa_la_LIBADD = \
+       gcell_runtime_qa.lo \
+       libruntime.la
+
+CLEANFILES = gcell_runtime_qa.lo
diff --git a/gcell/lib/runtime/gc_aligned_alloc.cc b/gcell/lib/runtime/gc_aligned_alloc.cc
new file mode 100644 (file)
index 0000000..905154e
--- /dev/null
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gcell/gc_aligned_alloc.h>
+#include <stdlib.h>
+#include <stdexcept>
+#include <string.h>
+
+// custom deleter of anything that can be freed with "free"
+class free_deleter {
+public:
+  void operator()(void *p) {
+    free(p);
+  }
+};
+
+void *
+gc_aligned_alloc(size_t size, size_t alignment)
+{
+  void *p = 0;
+  if (posix_memalign(&p, alignment, size) != 0){
+    perror("posix_memalign");
+    throw std::runtime_error("memory");
+  }
+  memset(p, 0, size);          // zero the memory
+  return p;
+}
+
+boost::shared_ptr<void>
+gc_aligned_alloc_sptr(size_t size, size_t alignment)
+{
+  return boost::shared_ptr<void>(gc_aligned_alloc(size, alignment),
+                                free_deleter());
+}
diff --git a/gcell/lib/runtime/gc_client_thread_info.h b/gcell/lib/runtime/gc_client_thread_info.h
new file mode 100644 (file)
index 0000000..fbb35d9
--- /dev/null
@@ -0,0 +1,81 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GC_CLIENT_THREAD_INFO_H
+#define INCLUDED_GC_CLIENT_THREAD_INFO_H
+
+#include <omnithread.h>
+#include <boost/utility.hpp>
+
+enum gc_ct_state {
+  CT_NOT_WAITING,
+  CT_WAIT_ALL,
+  CT_WAIT_ANY,
+};
+
+/*
+ * \brief per client-thread data used by gc_job_manager
+ *
+ * "Client threads" are any threads that invoke methods on
+ * gc_job_manager.  We use pthread_set_specific to store a pointer to
+ * one of these for each thread that comes our way.
+ */
+class gc_client_thread_info : boost::noncopyable {
+public:
+  gc_client_thread_info() :
+    d_free(1), d_cond(&d_mutex), d_state(CT_NOT_WAITING),
+    d_jobs_done(0), d_njobs_waiting_for(0),
+    d_jobs_waiting_for(0){ }
+
+  ~gc_client_thread_info() {
+    d_free = 1;
+    d_state = CT_NOT_WAITING;
+    d_jobs_done = 0;
+    d_njobs_waiting_for = 0;
+    d_jobs_waiting_for = 0;
+  }
+
+  //! is this cti free? (1->free, 0->in use)
+  uint32_t       d_free;
+
+  //! which client info are we?
+  uint16_t       d_client_id;
+
+  //! hold this mutex to manipulate anything below here
+  omni_mutex     d_mutex;
+
+  //! signaled by event handler to wake client thread up
+  omni_condition  d_cond;
+
+  //! Is this client waiting?
+  gc_ct_state    d_state;
+  
+  //! Jobs that have finished and not yet been waited for (bitvector)
+  unsigned long         *d_jobs_done;
+
+  //! # of jobs we're waiting for
+  unsigned int    d_njobs_waiting_for;
+
+  //! Jobs that client thread is waiting for
+  gc_job_desc   **d_jobs_waiting_for;
+
+};
+
+#endif /* INCLUDED_GC_CLIENT_THREAD_INFO_H */
diff --git a/gcell/lib/runtime/gc_jd_queue.c b/gcell/lib/runtime/gc_jd_queue.c
new file mode 100644 (file)
index 0000000..aeabd30
--- /dev/null
@@ -0,0 +1,78 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_jd_queue.h>
+#include <gcell/memory_barrier.h>
+#include <mutex_init.h>
+#include <mutex_lock.h>
+#include <mutex_unlock.h>
+
+void 
+gc_jd_queue_init(gc_jd_queue_t *q)
+{
+  _mutex_init(ptr_to_ea(&q->mutex));
+  q->head = 0;
+  q->tail = 0;
+  smp_wmb();
+}
+  
+void
+gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item)
+{
+  item->sys.next = 0;
+  _mutex_lock(ptr_to_ea(&q->mutex));
+  smp_rmb();           // import barrier
+
+  if (q->tail == 0){    // currently empty
+    q->tail = q->head = jdp_to_ea(item);
+  }
+  else {               // not empty, append
+    ea_to_jdp(q->tail)->sys.next = jdp_to_ea(item);
+    q->tail = jdp_to_ea(item);
+  }
+
+  smp_wmb();           // orders stores above before clearing of mutex
+  _mutex_unlock(ptr_to_ea(&q->mutex));
+}
+
+gc_job_desc_t *
+gc_jd_queue_dequeue(gc_jd_queue_t *q)
+{
+  _mutex_lock(ptr_to_ea(&q->mutex));
+  smp_rmb();           // import barrier
+  
+  gc_eaddr_t item_ea = q->head;
+  if (item_ea == 0){   // empty
+    _mutex_unlock(ptr_to_ea(&q->mutex));
+    return 0;
+  }
+
+  q->head = ea_to_jdp(item_ea)->sys.next;
+  if (q->head == 0)    // now emtpy
+    q->tail = 0;
+
+  gc_job_desc_t *item = ea_to_jdp(item_ea);
+  item->sys.next = 0;
+
+  smp_wmb();           // orders stores above before clearing of mutex
+  _mutex_unlock(ptr_to_ea(&q->mutex));
+  return item;
+}
diff --git a/gcell/lib/runtime/gc_jd_stack.c b/gcell/lib/runtime/gc_jd_stack.c
new file mode 100644 (file)
index 0000000..4d865ac
--- /dev/null
@@ -0,0 +1,168 @@
+/* -*- c -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_jd_stack.h>
+#include <gcell/memory_barrier.h>
+
+/*
+ * begin extract from ppu_intrinics.h
+ * FIXME handle this a different way
+ */
+
+#if !defined(__PPU__) && !defined(__ppc__) && !defined(__ppc64__)
+    && !defined(__GNUC__)
+  #error ppu_intrinsics.h included on wrong platform/compiler
+#endif
+
+#define __lwarx(base) __extension__            \
+  ({unsigned int result;                       \
+    typedef  struct {char a[4];} wordsize;     \
+    wordsize *ptrp = (wordsize*)(base);                \
+  __asm__ volatile ("lwarx %0,%y1"             \
+          : "=r" (result)                      \
+          : "Z" (*ptrp));                      \
+  result; })
+
+#ifdef __powerpc64__
+#define __ldarx(base) __extension__                    \
+  ({unsigned long long result;                         \
+    typedef  struct {char a[8];} doublewordsize;       \
+    doublewordsize *ptrp = (doublewordsize*)(base);    \
+  __asm__ volatile ("ldarx %0,%y1"                     \
+          : "=r" (result)                              \
+          : "Z" (*ptrp));                              \
+  result; })
+#endif /* __powerpc64__ */
+
+#define __stwcx(base, value) __extension__     \
+  ({unsigned int result;                       \
+    typedef  struct {char a[4];} wordsize;     \
+    wordsize *ptrp = (wordsize*)(base);                \
+  __asm__ volatile ("stwcx. %2,%y1\n"          \
+          "\tmfocrf %0,0x80"                   \
+          : "=r" (result),                     \
+            "=Z" (*ptrp)                       \
+          : "r" (value));                      \
+  ((result & 0x20000000) >> 29); })
+
+
+#ifdef __powerpc64__
+#define __stdcx(base, value) __extension__             \
+  ({unsigned long long result;                         \
+    typedef  struct {char a[8];} doublewordsize;       \
+    doublewordsize *ptrp = (doublewordsize*)(base);    \
+  __asm__ volatile ("stdcx. %2,%y1\n"                  \
+          "\tmfocrf %0,0x80"                           \
+          : "=r" (result),                             \
+            "=Z" (*ptrp)                               \
+          : "r" (value));                              \
+  ((result & 0x20000000) >> 29); })
+#endif /* __powerpc64__ */
+
+
+/*
+ * --- end extract from ppu_intrinics.h --
+ */
+
+
+void 
+gc_jd_stack_init(gc_jd_stack_t *stack)
+{
+  stack->top = 0;
+}
+  
+
+#ifdef __powerpc64__  // 64-bit mode
+
+void 
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item)
+{
+  gc_eaddr_t   top;
+  gc_eaddr_t   item_ea = ptr_to_ea(item);
+  unsigned int done;
+
+  do {
+    top = __ldarx(&stack->top);
+    item->sys.next = top;
+    smp_wmb();       // order store of item->next before store of stack->top
+    done = __stdcx(&stack->top, item_ea);
+  } while (unlikely(done == 0));
+}
+
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack)
+{
+  gc_eaddr_t   s;
+  gc_eaddr_t   t;
+  unsigned int done;
+
+  do {
+    s  = __ldarx(&stack->top);
+    if (s == 0)                        /* stack's empty */
+      return 0;
+    t = ((gc_job_desc_t *) ea_to_ptr(s))->sys.next;
+    done = __stdcx(&stack->top, t);
+  } while (unlikely(done == 0));
+
+  return ea_to_ptr(s);
+}
+
+#else  // 32-bit mode
+
+/*
+ * In 32-bit mode, gc_eaddr's will have the top 32-bits zero.
+ * The ldarx/stdcx instructions aren't available in 32-bit mode,
+ * thus we use lwarx/stwcx on the low 32-bits of the 64-bit addresses.
+ * Since we're big-endian, the low 32-bits are at word offset 1.
+ */
+void 
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item)
+{
+  gc_eaddr_t   top;
+  unsigned int done;
+
+  do {
+    top = __lwarx((int32_t *)(&stack->top) + 1);
+    item->sys.next = top;
+    smp_wmb();       // order store of item->sys.next before store of stack->top
+    done = __stwcx((int32_t *)(&stack->top) + 1, item);
+  } while (unlikely(done == 0));
+}
+
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack)
+{
+  gc_eaddr_t   s;
+  gc_eaddr_t   t;
+  unsigned int done;
+
+  do {
+    s  = __lwarx((int32_t *)(&stack->top) + 1);
+    if (s == 0)                        /* stack's empty */
+      return 0;
+    t = ((gc_job_desc_t *) ea_to_ptr(s))->sys.next;
+    done = __stwcx((int32_t *)(&stack->top) + 1, (uint32_t) t);
+  } while (unlikely(done == 0));
+
+  return ea_to_ptr(s);
+}
+
+#endif
diff --git a/gcell/lib/runtime/gc_job_manager.cc b/gcell/lib/runtime/gc_job_manager.cc
new file mode 100644 (file)
index 0000000..d96bc53
--- /dev/null
@@ -0,0 +1,186 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gcell/gc_job_manager.h>
+#include "gc_job_manager_impl.h"
+#include <boost/weak_ptr.hpp>
+#include <stdio.h>
+
+
+static boost::weak_ptr<gc_job_manager> s_singleton;
+
+
+// custom deleter of gc_job_desc allocated via alloc_job_desc_sptr
+class job_desc_deleter {
+  gc_job_manager_sptr  d_mgr;
+public:
+  job_desc_deleter(gc_job_manager_sptr mgr) : d_mgr(mgr) {}
+
+  void operator()(gc_job_desc *jd) {
+    d_mgr->free_job_desc(jd);
+  }
+};
+
+
+
+gc_job_manager_sptr
+gc_make_job_manager(const gc_jm_options *options)
+{
+  return gc_job_manager_sptr(new gc_job_manager_impl(options));
+}
+
+gc_job_manager::gc_job_manager(const gc_jm_options *options)
+{
+  // nop
+}
+
+gc_job_manager::~gc_job_manager()
+{
+  // nop
+}
+
+void
+gc_job_manager::set_debug(int debug)
+{
+  // nop
+}
+
+int
+gc_job_manager::debug()
+{
+  return 0;
+}
+
+void 
+gc_job_manager::set_singleton(gc_job_manager_sptr mgr)
+{
+  s_singleton = mgr;
+}
+
+gc_job_manager_sptr 
+gc_job_manager::singleton()
+{
+  return gc_job_manager_sptr(s_singleton);
+}
+
+gc_job_desc_sptr 
+gc_job_manager::make_jd_sptr(gc_job_manager_sptr mgr, gc_job_desc *jd)
+{
+  return gc_job_desc_sptr(jd, job_desc_deleter(mgr));
+}
+
+gc_job_desc_sptr 
+gc_job_manager::alloc_job_desc(gc_job_manager_sptr mgr)
+{
+  return make_jd_sptr(mgr, mgr->alloc_job_desc());
+}
+
+
+// ------------------------------------------------------------------------
+
+
+// custom deleter
+class spe_program_handle_deleter {
+public:
+  void operator()(spe_program_handle_t *program) {
+    if (program){
+      int r = spe_image_close(program);
+      if (r != 0){
+       perror("spe_image_close");
+      }
+    }
+  }
+};
+
+// nop custom deleter
+class nop_spe_program_handle_deleter {
+public:
+  void operator()(spe_program_handle_t *program) {
+  }
+};
+
+spe_program_handle_sptr 
+gc_program_handle_from_filename(const std::string &filename)
+{
+  return spe_program_handle_sptr(spe_image_open(filename.c_str()),
+                                spe_program_handle_deleter());
+}
+
+
+spe_program_handle_sptr 
+gc_program_handle_from_address(spe_program_handle_t *handle)
+{
+  return spe_program_handle_sptr(handle, nop_spe_program_handle_deleter());
+}
+
+const std::string
+gc_job_status_string(gc_job_status_t status)
+{
+  switch(status){
+  case JS_OK:                  return "JS_OK";
+  case JS_SHUTTING_DOWN:       return "JS_SHUTTING_DOWN";
+  case JS_TOO_MANY_CLIENTS:    return "JS_TOO_MANY_CLIENTS";
+  case JS_UNKNOWN_PROC:                return "JS_UNKNOWN_PROC";
+  case JS_BAD_DIRECTION:       return "JS_BAD_DIRECTION";
+  case JS_BAD_EAH:             return "JS_BAD_EAH";
+  case JS_BAD_N_DIRECT:                return "JS_BAD_N_DIRECT";
+  case JS_BAD_N_EA:            return "JS_BAD_N_EA";
+  case JS_ARGS_TOO_LONG:       return "JS_ARGS_TOO_LONG";
+  case JS_BAD_JUJU:            return "JS_BAD_JUJU";
+  case JS_BAD_JOB_DESC:                return "JS_BAD_JOB_DESC";
+  default:
+    char buf[100];
+    snprintf(buf, sizeof(buf), "unknown gc_job_status_t (%d)\n", status);
+    return buf;
+  }
+}
+
+/*
+ * exception classes
+ */
+
+gc_exception::gc_exception(const std::string &msg)
+  : runtime_error(msg)
+{
+}
+
+gc_unknown_proc::gc_unknown_proc(const std::string &msg)
+  : gc_exception("gc_unknown_proc: " + msg)
+{
+}
+
+gc_bad_alloc::gc_bad_alloc(const std::string &msg)
+  : gc_exception("gc_bad_alloc: " + msg)
+{
+}
+
+gc_bad_align::gc_bad_align(const std::string &msg)
+  : gc_exception("gc_bad_align: " + msg)
+{
+}
+
+gc_bad_submit::gc_bad_submit(const std::string &name, gc_job_status_t status)
+  : gc_exception("gc_bad_submit(" + name + "): " + gc_job_status_string(status))
+{
+}
diff --git a/gcell/lib/runtime/gc_job_manager_impl.cc b/gcell/lib/runtime/gc_job_manager_impl.cc
new file mode 100644 (file)
index 0000000..629019f
--- /dev/null
@@ -0,0 +1,1249 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "gc_job_manager_impl.h"
+#include <gcell/gc_mbox.h>
+#include <gcell/gc_aligned_alloc.h>
+#include <gcell/memory_barrier.h>
+#include <gc_proc_def_utils.h>
+#include <atomic_dec_if_positive.h>
+#include <stdio.h>
+#include <stdexcept>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+
+static const size_t CACHE_LINE_SIZE = 128;
+
+static const unsigned int DEFAULT_MAX_JOBS = 128;
+static const unsigned int DEFAULT_MAX_CLIENT_THREADS = 64;
+
+// FIXME this really depends on the SPU code...
+static const unsigned int MAX_TOTAL_INDIRECT_LENGTH = 16 * 1024;
+
+
+static bool          s_key_initialized = false;
+static pthread_key_t s_client_key;
+
+static int s_worker_debug = 0;
+
+// custom deleter of gang_contexts for use with boost::shared_ptr
+class gang_deleter {
+public:
+  void operator()(spe_gang_context_ptr_t ctx) {
+    if (ctx){
+      int r = spe_gang_context_destroy(ctx);
+      if (r != 0){
+       perror("spe_gang_context_destroy");
+      }
+    }
+  }
+};
+
+
+// custom deleter of anything that can be freed with "free"
+class free_deleter {
+public:
+  void operator()(void *p) {
+    free(p);
+  }
+};
+
+
+/*
+ * Called when client thread is destroyed.
+ * We mark our client info free.
+ */
+static void
+client_key_destructor(void *p)
+{
+  ((gc_client_thread_info *) p)->d_free = 1;
+}
+
+static bool
+is_power_of_2(uint32_t x)
+{
+  return (x != 0) && !(x & (x - 1));
+}
+
+////////////////////////////////////////////////////////////////////////
+
+
+gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options)
+  : d_debug(0), d_spu_args(0),
+    d_eh_cond(&d_eh_mutex), d_eh_thread(0), d_eh_state(EHS_INIT),
+    d_shutdown_requested(false),
+    d_client_thread(0), d_ea_args_maxsize(0),
+    d_proc_def(0), d_proc_def_ls_addr(0), d_nproc_defs(0)
+{
+  if (!s_key_initialized){
+    int r = pthread_key_create(&s_client_key, client_key_destructor);
+    if (r != 0)
+      throw std::runtime_error("pthread_key_create");
+    s_key_initialized = true;
+  }
+
+  // ensure it's zero
+  pthread_setspecific(s_client_key, 0);
+
+  if (options != 0)
+    d_options = *options;
+
+  // provide the real default for those indicated with a zero
+  if (d_options.max_jobs == 0)
+    d_options.max_jobs = DEFAULT_MAX_JOBS;
+  if (d_options.max_client_threads == 0)
+    d_options.max_client_threads = DEFAULT_MAX_CLIENT_THREADS;
+
+  if (!d_options.program_handle){
+    fprintf(stderr, "gc_job_manager: options->program_handle must be non-zero\n");
+    throw std::runtime_error("gc_job_manager: options->program_handle must be non-zero");
+  }
+
+  int ncpu_nodes = spe_cpu_info_get(SPE_COUNT_PHYSICAL_CPU_NODES, -1);
+  int nusable_spes = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, -1);
+
+  if (debug()){
+    printf("cpu_nodes = %d\n", ncpu_nodes);
+    for (int i = 0; i < ncpu_nodes; i++){
+      printf("node[%d].physical_spes = %2d\n", i,
+            spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, i));
+      printf("node[%d].usable_spes   = %2d\n", i,
+            spe_cpu_info_get(SPE_COUNT_USABLE_SPES, i));
+    }
+  }
+
+  // clamp nspes
+  d_options.nspes = std::min(d_options.nspes, (unsigned int) MAX_SPES);
+  nusable_spes = std::min(nusable_spes, (int) MAX_SPES);
+
+  //
+  // sanity check requested number of spes.
+  //
+  if (d_options.nspes == 0)    // use all of them
+    d_options.nspes = nusable_spes;
+  else {
+    if (d_options.nspes > (unsigned int) nusable_spes){
+      fprintf(stderr,
+             "gc_job_manager: warning: caller requested %d spes.  There are only %d available.\n",
+             d_options.nspes, nusable_spes);
+      if (d_options.gang_schedule){
+       // If we're gang scheduling we'll never get scheduled if we
+       // ask for more than are available.
+       throw std::out_of_range("gang_scheduling: not enough spes available");
+      }
+      else {   // FIXME clamp to usable.  problem on PS3 when overcommited
+       fprintf(stderr, "gc_job_manager: clamping nspes to %d\n", nusable_spes);
+       d_options.nspes = nusable_spes;
+      }
+    }
+  }
+
+  if (d_options.use_affinity){
+    printf("gc_job_manager: warning: affinity request was ignored\n");
+  }
+
+  if (d_options.gang_schedule){
+    d_gang = spe_gang_context_sptr(spe_gang_context_create(0), gang_deleter());
+    if (!d_gang){
+      perror("gc_job_manager_impl[spe_gang_context_create]");
+      throw std::runtime_error("spe_gang_context_create");
+    }
+  }
+
+  // ----------------------------------------------------------------
+  // initalize the job queue
+  
+  d_queue = (gc_jd_queue_t *) gc_aligned_alloc(sizeof(gc_jd_queue_t), CACHE_LINE_SIZE);
+  _d_queue_boost =
+    boost::shared_ptr<void>((void *) d_queue, free_deleter());
+  gc_jd_queue_init(d_queue);
+
+
+  // ----------------------------------------------------------------
+  // create the spe contexts
+
+  // 1 spu_arg struct for each SPE
+  assert(sizeof(gc_spu_args_t) % 16 == 0);
+  d_spu_args =
+    (gc_spu_args_t *) gc_aligned_alloc(MAX_SPES * sizeof(gc_spu_args_t), 16);
+  _d_spu_args_boost =
+    boost::shared_ptr<void>((void *) d_spu_args, free_deleter());
+
+  // 2 completion info structs for each SPE (we double buffer them)
+  assert(sizeof(gc_comp_info_t) % CACHE_LINE_SIZE == 0);
+  d_comp_info =
+    (gc_comp_info_t *) gc_aligned_alloc(2 * MAX_SPES * sizeof(gc_comp_info_t),
+                                       CACHE_LINE_SIZE);
+  _d_comp_info_boost =
+    boost::shared_ptr<void>((void *) d_comp_info, free_deleter());
+
+
+  // get a handle to the spe program
+
+  spe_program_handle_t *spe_image = d_options.program_handle.get();
+
+  // fish proc_def table out of SPE ELF file
+
+  if (!gcpd_find_table(spe_image, &d_proc_def, &d_nproc_defs, &d_proc_def_ls_addr)){
+    fprintf(stderr, "gc_job_manager_impl: couldn't find gc_proc_defs in SPE ELF file.\n");
+    throw std::runtime_error("no gc_proc_defs");
+  }
+  // fprintf(stderr, "d_proc_def_ls_addr = 0x%0x\n", d_proc_def_ls_addr);
+
+  int spe_flags = (SPE_EVENTS_ENABLE
+                  | SPE_CFG_SIGNOTIFY1_OR
+                  | SPE_CFG_SIGNOTIFY2_OR);
+  
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    // FIXME affinity stuff goes here
+    d_worker[i].spe_ctx = spe_context_create(spe_flags, d_gang.get());;
+    if (d_worker[i].spe_ctx == 0){
+      perror("spe_context_create");
+      throw std::runtime_error("spe_context_create");
+    }
+    d_worker[i].spe_idx = i;
+    d_worker[i].spu_args = &d_spu_args[i];
+    d_worker[i].spu_args->queue = ptr_to_ea(d_queue);
+    d_worker[i].spu_args->comp_info[0] = ptr_to_ea(&d_comp_info[2*i+0]);
+    d_worker[i].spu_args->comp_info[1] = ptr_to_ea(&d_comp_info[2*i+1]);
+    d_worker[i].spu_args->spu_idx = i;
+    d_worker[i].spu_args->nspus = d_options.nspes;
+    d_worker[i].spu_args->proc_def_ls_addr = d_proc_def_ls_addr;
+    d_worker[i].spu_args->nproc_defs = d_nproc_defs;
+    d_worker[i].spu_args->log.base = 0;
+    d_worker[i].spu_args->log.nentries = 0;
+    d_worker[i].state = WS_INIT;
+
+    int r = spe_program_load(d_worker[i].spe_ctx, spe_image);
+    if (r != 0){
+      perror("spe_program_load");
+      throw std::runtime_error("spe_program_load");
+    }
+  }
+
+  setup_logfiles();
+
+  // ----------------------------------------------------------------
+  // initalize the free list of job descriptors
+  
+  d_free_list = (gc_jd_stack_t *) gc_aligned_alloc(sizeof(gc_jd_stack_t), CACHE_LINE_SIZE);
+  // This ensures that the memory associated with d_free_list is
+  // automatically freed in the destructor or if an exception occurs
+  // here in the constructor.
+  _d_free_list_boost =
+    boost::shared_ptr<void>((void *) d_free_list, free_deleter());
+  gc_jd_stack_init(d_free_list);
+
+  if (debug()){
+    printf("sizeof(d_jd[0]) = %d (0x%x)\n", sizeof(d_jd[0]), sizeof(d_jd[0]));
+    printf("max_jobs = %u\n", d_options.max_jobs);
+  }
+
+  // Initialize the array of job descriptors.
+  d_jd = (gc_job_desc_t *) gc_aligned_alloc(sizeof(d_jd[0]) * d_options.max_jobs, CACHE_LINE_SIZE);
+  _d_jd_boost = boost::shared_ptr<void>((void *) d_jd, free_deleter());
+
+
+  // set unique job_id
+  for (int i = 0; i < (int) d_options.max_jobs; i++)
+    d_jd[i].sys.job_id = i;
+
+  // push them onto the free list
+  for (int i = d_options.max_jobs - 1; i >= 0; i--)
+    free_job_desc(&d_jd[i]);
+
+  // ----------------------------------------------------------------
+  // initialize d_client_thread
+
+  {
+    gc_client_thread_info_sa cti(
+         new gc_client_thread_info[d_options.max_client_threads]);
+
+    d_client_thread.swap(cti);
+
+    for (unsigned int i = 0; i < d_options.max_client_threads; i++)
+      d_client_thread[i].d_client_id = i;
+  }
+
+  // ----------------------------------------------------------------
+  // initialize bitvectors
+
+  // initialize d_bvlen, the number of longs in job related bitvectors.
+  int bits_per_long = sizeof(unsigned long) * 8;
+  d_bvlen = (d_options.max_jobs + bits_per_long - 1) / bits_per_long;
+
+  // allocate all bitvectors in a single cache-aligned chunk
+  size_t nlongs = d_bvlen * d_options.max_client_threads;
+  void *p = gc_aligned_alloc(nlongs * sizeof(unsigned long), CACHE_LINE_SIZE);
+  _d_all_bitvectors = boost::shared_ptr<void>(p, free_deleter());
+
+  // Now point the gc_client_thread_info bitvectors into this storage
+  unsigned long *v = (unsigned long *) p;
+
+  for (unsigned int i = 0; i < d_options.max_client_threads; i++, v += d_bvlen)
+    d_client_thread[i].d_jobs_done = v;
+
+
+  // ----------------------------------------------------------------
+  // create the spe event handler & worker (SPE) threads
+
+  create_event_handler();
+
+}
+
+////////////////////////////////////////////////////////////////////////
+
+gc_job_manager_impl::~gc_job_manager_impl()
+{
+  shutdown();
+
+  d_jd = 0;            // handled via _d_jd_boost
+  d_free_list = 0;     // handled via _d_free_list_boost
+  d_queue = 0;         // handled via _d_queue_boost
+
+  // clear cti, since we've deleted the underlying data
+  pthread_setspecific(s_client_key, 0);
+
+  unmap_logfiles();
+}
+
+bool
+gc_job_manager_impl::shutdown()
+{
+  omni_mutex_lock      l(d_eh_mutex);
+
+  d_shutdown_requested = true;         // set flag for event handler thread
+
+  // should only happens during early QA code
+  if (d_eh_thread == 0 && d_eh_state == EHS_INIT)
+    return false;
+
+  while (d_eh_state != EHS_DEAD)       // wait for it to finish
+    d_eh_cond.wait();
+
+  return true;
+}
+
+int
+gc_job_manager_impl::nspes() const
+{
+  return d_options.nspes;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void
+gc_job_manager_impl::bv_zero(unsigned long *bv)
+{
+  memset(bv, 0, sizeof(unsigned long) * d_bvlen);
+}
+
+inline void
+gc_job_manager_impl::bv_clr(unsigned long *bv, unsigned int bitno)
+{
+  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
+  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
+  bv[wi] &= ~(1UL << bi);
+}
+
+inline void
+gc_job_manager_impl::bv_set(unsigned long *bv, unsigned int bitno)
+{
+  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
+  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
+  bv[wi] |= (1UL << bi);
+}
+
+inline bool
+gc_job_manager_impl::bv_isset(unsigned long *bv, unsigned int bitno)
+{
+  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
+  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
+  return (bv[wi] & (1UL << bi)) != 0;
+}
+
+inline bool
+gc_job_manager_impl::bv_isclr(unsigned long *bv, unsigned int bitno)
+{
+  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
+  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
+  return (bv[wi] & (1UL << bi)) == 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+gc_job_desc *
+gc_job_manager_impl::alloc_job_desc()
+{
+  // stack is lock free, and safe to call from any thread
+  gc_job_desc *jd = gc_jd_stack_pop(d_free_list);
+  if (jd == 0)
+    throw gc_bad_alloc("alloc_job_desc: none available");
+
+  return jd;
+}
+
+void
+gc_job_manager_impl::free_job_desc(gc_job_desc *jd)
+{
+  // stack is lock free, thus safe to call from any thread
+  if (jd != 0)
+    gc_jd_stack_push(d_free_list, jd);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+/*
+ * We check as much as we can here on the PPE side, so that the SPE
+ * doesn't have to.
+ */
+static bool
+check_direct_args(gc_job_desc *jd, gc_job_direct_args *args)
+{
+  if (args->nargs > MAX_ARGS_DIRECT){
+    jd->status = JS_BAD_N_DIRECT;
+    return false;
+  }
+
+  return true;
+}
+
+static bool
+check_ea_args(gc_job_desc *jd, gc_job_ea_args *p)
+{
+  if (p->nargs > MAX_ARGS_EA){
+    jd->status = JS_BAD_N_EA;
+    return false;
+  }
+
+  uint32_t dir_union = 0;
+
+  for (unsigned int i = 0; i < p->nargs; i++){
+    dir_union |= p->arg[i].direction;
+    switch(p->arg[i].direction){
+    case GCJD_DMA_GET:
+    case GCJD_DMA_PUT:
+      break;
+
+    default:
+      jd->status = JS_BAD_DIRECTION;
+      return false;
+    }
+  }
+
+  if (p->nargs > 1){
+    unsigned int common_eah = (p->arg[0].ea_addr) >> 32;
+    for (unsigned int i = 1; i < p->nargs; i++){
+      if ((p->arg[i].ea_addr >> 32) != common_eah){
+       jd->status = JS_BAD_EAH;
+       return false;
+      }
+    }
+  }
+
+  jd->sys.direction_union = dir_union;
+  return true;
+}
+
+bool
+gc_job_manager_impl::submit_job(gc_job_desc *jd)
+{
+  if (unlikely(d_shutdown_requested)){
+    jd->status = JS_SHUTTING_DOWN;
+    return false;
+  }
+
+  // Ensure it's one of our job descriptors
+
+  if (jd < d_jd || jd >= &d_jd[d_options.max_jobs]){
+    jd->status = JS_BAD_JOB_DESC;
+    return false;
+  }
+
+  // Ensure we've got a client_thread_info assigned to this thread.
+  
+  gc_client_thread_info *cti =
+    (gc_client_thread_info *) pthread_getspecific(s_client_key);
+  if (unlikely(cti == 0)){
+    if ((cti = alloc_cti()) == 0){
+      fprintf(stderr, "gc_job_manager_impl::submit_job: Too many client threads.\n");
+      jd->status = JS_TOO_MANY_CLIENTS;
+      return false;
+    }
+    int r = pthread_setspecific(s_client_key, cti);
+    if (r != 0){
+      jd->status = JS_BAD_JUJU;
+      fprintf(stderr, "pthread_setspecific failed (return = %d)\n", r);
+      return false;
+    }
+  }
+
+  if (jd->proc_id == GCP_UNKNOWN_PROC){
+    jd->status = JS_UNKNOWN_PROC;
+    return false;
+  }
+
+  if (!check_direct_args(jd, &jd->input))
+    return false;
+
+  if (!check_direct_args(jd, &jd->output))
+    return false;
+
+  if (!check_ea_args(jd, &jd->eaa))
+    return false;
+
+  jd->status = JS_OK;
+  jd->sys.client_id = cti->d_client_id;
+
+  // FIXME keep count of jobs in progress?
+  
+  gc_jd_queue_enqueue(d_queue, jd);
+  return true;
+}
+
+bool
+gc_job_manager_impl::wait_job(gc_job_desc *jd)
+{
+  bool done;
+  return wait_jobs(1, &jd, &done, GC_WAIT_ANY) == 1 && jd->status == JS_OK;
+}
+
+int
+gc_job_manager_impl::wait_jobs(unsigned int njobs,
+                              gc_job_desc *jd[],
+                              bool done[],
+                              gc_wait_mode mode)
+{
+  unsigned int i;
+
+  gc_client_thread_info *cti =
+    (gc_client_thread_info *) pthread_getspecific(s_client_key);
+  if (unlikely(cti == 0))
+    return -1;
+
+  for (i = 0; i < njobs; i++){
+    done[i] = false;
+    if (unlikely(jd[i]->sys.client_id != cti->d_client_id)){
+      fprintf(stderr, "gc_job_manager_impl::wait_jobs: can't wait for a job you didn't submit\n");
+      return -1;
+    }
+  }
+
+  {
+    omni_mutex_lock    l(cti->d_mutex);
+
+    // setup info for event handler
+    cti->d_state = (mode == GC_WAIT_ANY) ? CT_WAIT_ANY : CT_WAIT_ALL;
+    cti->d_njobs_waiting_for = njobs;
+    cti->d_jobs_waiting_for = jd;
+    assert(cti->d_jobs_done != 0);
+
+    unsigned int ndone = 0;
+
+    // wait for jobs to complete
+    
+    while (1){
+      ndone = 0;
+      for (i= 0; i < njobs; i++){
+       if (done[i])
+         ndone++;
+       else if (bv_isset(cti->d_jobs_done, jd[i]->sys.job_id)){
+         bv_clr(cti->d_jobs_done, jd[i]->sys.job_id);
+         done[i] = true;
+         ndone++;
+       }
+      }
+
+      if (mode == GC_WAIT_ANY && ndone > 0)
+       break;
+
+      if (mode == GC_WAIT_ALL && ndone == njobs)
+       break;
+
+      // FIXME what happens when somebody calls shutdown?
+
+      cti->d_cond.wait();      // wait for event handler to wake us up
+    }
+
+    cti->d_state = CT_NOT_WAITING;  
+    cti->d_njobs_waiting_for = 0;      // tidy up (not reqd)
+    cti->d_jobs_waiting_for = 0;       // tidy up (not reqd)
+    return ndone;
+  }
+}
+
+////////////////////////////////////////////////////////////////////////
+
+bool
+gc_job_manager_impl::send_all_spes(uint32_t msg)
+{
+  bool ok = true;
+
+  for (unsigned int i = 0; i < d_options.nspes; i++)
+    ok &= send_spe(i, msg);
+
+  return ok;
+}
+
+bool
+gc_job_manager_impl::send_spe(unsigned int spe, uint32_t msg)
+{
+  if (spe >= d_options.nspes)
+    return false;
+
+  int r = spe_in_mbox_write(d_worker[spe].spe_ctx, &msg, 1,
+                           SPE_MBOX_ALL_BLOCKING);
+  if (r < 0){
+    perror("spe_in_mbox_write");
+    return false;
+  }
+
+  return r == 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+static void
+pthread_create_failure_msg(int r, const char *which)
+{
+  char buf[256];
+  char *s = 0;
+
+  switch (r){
+  case EAGAIN: s = "EAGAIN"; break;
+  case EINVAL: s = "EINVAL"; break;
+  case EPERM:  s = "EPERM";  break;
+  default:
+    snprintf(buf, sizeof(buf), "Unknown error %d", r);
+    s = buf;
+    break;
+  }
+  fprintf(stderr, "pthread_create[%s] failed: %s\n", which, s);
+}
+
+
+static bool
+start_thread(pthread_t *thread,
+            void *(*start_routine)(void *),  void *arg,
+            const char *msg)
+{
+  pthread_attr_t attr;
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+  // FIXME save sigprocmask
+  // FIXME set sigprocmask
+
+  int r = pthread_create(thread, &attr, start_routine, arg);
+    
+  // FIXME restore sigprocmask
+
+  if (r != 0){
+    pthread_create_failure_msg(r, msg);
+    return false;
+  }
+  return true;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+
+static void *start_worker(void *arg);
+
+static void *
+start_event_handler(void *arg)
+{
+  gc_job_manager_impl *p = (gc_job_manager_impl *) arg;
+  p->event_handler_loop();
+  return 0;
+}
+
+void
+gc_job_manager_impl::create_event_handler()
+{
+  // create the SPE event handler and register our interest in events
+
+  d_spe_event_handler.ptr = spe_event_handler_create();
+  if (d_spe_event_handler.ptr == 0){
+    perror("spe_event_handler_create");
+    throw std::runtime_error("spe_event_handler_create");
+  }
+
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    spe_event_unit_t   eu;
+    memset(&eu, 0, sizeof(eu));
+    eu.events = SPE_EVENT_OUT_INTR_MBOX | SPE_EVENT_SPE_STOPPED;
+    eu.spe = d_worker[i].spe_ctx;
+    eu.data.u32 = i;   // set in events returned by spe_event_wait
+
+    if (spe_event_handler_register(d_spe_event_handler.ptr, &eu) != 0){
+      perror("spe_event_handler_register");
+      throw std::runtime_error("spe_event_handler_register");
+    }
+  }
+
+  // create our event handling thread
+
+  if (!start_thread(&d_eh_thread, start_event_handler, this, "event_handler")){
+    throw std::runtime_error("pthread_create");
+  }
+
+  // create the SPE worker threads
+
+  bool ok = true;
+  for (unsigned int i = 0; ok && i < d_options.nspes; i++){
+    char name[256];
+    snprintf(name, sizeof(name), "worker[%d]", i);
+    ok &= start_thread(&d_worker[i].thread, start_worker,
+                      &d_worker[i], name);
+  }
+
+  if (!ok){
+    //
+    // FIXME Clean up the mess.  Need to terminate event handler and all workers.
+    //
+    // this should cause the workers to exit, unless they're seriously broken
+    send_all_spes(MK_MBOX_MSG(OP_EXIT, 0));
+
+    shutdown();
+
+    throw std::runtime_error("pthread_create");
+  }
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void
+gc_job_manager_impl::set_eh_state(evt_handler_state s)
+{
+  omni_mutex_lock      l(d_eh_mutex);
+  d_eh_state = s;
+  d_eh_cond.broadcast();
+}
+
+void
+gc_job_manager_impl::set_ea_args_maxsize(int maxsize)
+{
+  omni_mutex_lock      l(d_eh_mutex);
+  d_ea_args_maxsize = maxsize;
+  d_eh_cond.broadcast();
+}
+
+void
+gc_job_manager_impl::print_event(spe_event_unit_t *evt)
+{
+  printf("evt: spe = %d events = (0x%x)", evt->data.u32, evt->events);
+
+  if (evt->events & SPE_EVENT_OUT_INTR_MBOX)
+    printf(" OUT_INTR_MBOX");
+  
+  if (evt->events & SPE_EVENT_IN_MBOX)
+    printf(" IN_MBOX");
+  
+  if (evt->events & SPE_EVENT_TAG_GROUP)
+    printf(" TAG_GROUP");
+  
+  if (evt->events & SPE_EVENT_SPE_STOPPED)
+    printf(" SPE_STOPPED");
+
+  printf("\n");
+}
+
+struct job_client_info {
+  uint16_t     job_id;
+  uint16_t     client_id;
+};
+
+static int
+compare_jci_clients(const void *va, const void *vb)
+{
+  const job_client_info *a = (job_client_info *) va;
+  const job_client_info *b = (job_client_info *) vb;
+
+  return a->client_id - b->client_id;
+}
+
+void
+gc_job_manager_impl::notify_clients_jobs_are_done(unsigned int spe_num,
+                                                 unsigned int completion_info_idx)
+{
+  const char *msg = "gc_job_manager_impl::notify_client_job_is_done (INTERNAL ERROR)";
+
+  smp_rmb();  // order reads so we know that data sent from SPE is here
+
+  gc_comp_info_t *ci = &d_comp_info[2 * spe_num + (completion_info_idx & 0x1)];
+
+  if (ci->ncomplete == 0){     // never happens, but ensures code below is correct
+    ci->in_use = 0;
+    return;
+  }
+
+  if (0){
+    static int total_jobs;
+    static int total_msgs;
+    total_msgs++;
+    total_jobs += ci->ncomplete;
+    printf("ppe:     tj = %6d  tm = %6d\n", total_jobs, total_msgs);
+  }
+
+  job_client_info gci[GC_CI_NJOBS];
+
+  /*
+   * Make one pass through and sanity check everything while filling in gci
+   */
+  for (unsigned int i = 0; i < ci->ncomplete; i++){
+    unsigned int job_id = ci->job_id[i];
+
+    if (job_id >= d_options.max_jobs){
+      // internal error, shouldn't happen
+      fprintf(stderr,"%s: invalid job_id = %d\n", msg, job_id);
+      ci->in_use = 0;          // clear flag so SPE knows we're done with it
+      return;
+    }
+    gc_job_desc *jd = &d_jd[job_id];
+
+    if (jd->sys.client_id >= d_options.max_client_threads){
+      // internal error, shouldn't happen
+      fprintf(stderr, "%s: invalid client_id = %d\n", msg, jd->sys.client_id);
+      ci->in_use = 0;          // clear flag so SPE knows we're done with it
+      return;
+    }
+
+    gci[i].job_id = job_id;
+    gci[i].client_id = jd->sys.client_id;
+  }
+
+  // sort by client_id so we only have to lock & signal once / client
+
+  if (ci->ncomplete > 1)
+    qsort(gci, ci->ncomplete, sizeof(gci[0]), compare_jci_clients);
+
+  // "wind-in" 
+
+  gc_client_thread_info *last_cti = &d_client_thread[gci[0].client_id];
+  last_cti->d_mutex.lock();
+  bv_set(last_cti->d_jobs_done, gci[0].job_id);  // mark job done
+
+  for (unsigned int i = 1; i < ci->ncomplete; i++){
+
+    gc_client_thread_info *cti = &d_client_thread[gci[i].client_id];
+
+    if (cti != last_cti){      // new client?
+
+      // yes.  signal old client, unlock old, lock new
+
+      // FIXME we could distinguish between CT_WAIT_ALL & CT_WAIT_ANY
+
+      if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL)
+       last_cti->d_cond.signal();      // wake client thread up
+
+      last_cti->d_mutex.unlock();
+      cti->d_mutex.lock();
+      last_cti = cti;
+    }
+
+    // mark job done
+    bv_set(cti->d_jobs_done, gci[i].job_id);
+  }
+
+  // "wind-out"
+
+  if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL)
+    last_cti->d_cond.signal(); // wake client thread up
+  last_cti->d_mutex.unlock();
+
+  ci->in_use = 0;              // clear flag so SPE knows we're done with it
+}
+
+void
+gc_job_manager_impl::handle_event(spe_event_unit_t *evt)
+{
+  // print_event(evt);
+
+  int spe_num = evt->data.u32;
+
+  // only a single event type can be signaled at a time
+  
+  if (evt->events == SPE_EVENT_OUT_INTR_MBOX) { // SPE sent us 1 or more msgs
+    static const int NMSGS = 32;
+    unsigned int msg[NMSGS];
+    int n = spe_out_intr_mbox_read(evt->spe, msg, NMSGS, SPE_MBOX_ANY_BLOCKING);
+    // printf("spe_out_intr_mbox_read = %d\n", n);
+    if (n < 0){
+      perror("spe_out_intr_mbox_read");
+    }
+    else {
+      for (int i = 0; i < n; i++){
+       switch(MBOX_MSG_OP(msg[i])){
+       case OP_JOBS_DONE:
+         if (debug())
+           printf("eh: job_done (0x%08x) from spu[%d]\n", msg[i], spe_num);
+         notify_clients_jobs_are_done(spe_num, MBOX_MSG_ARG(msg[i]));
+         break;
+
+       case OP_SPU_BUFSIZE:
+         set_ea_args_maxsize(MBOX_MSG_ARG(msg[i]));
+         break;
+
+       case OP_EXIT:
+       default:
+         printf("eh: Unexpected msg (0x%08x) from spu[%d]\n", msg[i], spe_num);
+         break;
+       }
+      }
+    }
+  }
+  else if (evt->events == SPE_EVENT_SPE_STOPPED){ // the SPE stopped
+    spe_stop_info_t si;
+    int r = spe_stop_info_read(evt->spe, &si);
+    if (r < 0){
+      perror("spe_stop_info_read");
+    }
+    else {
+      switch (si.stop_reason){
+      case SPE_EXIT:
+       if (debug()){
+         printf("eh: spu[%d] SPE_EXIT w/ exit_code = %d\n",
+                spe_num, si.result.spe_exit_code);
+       }
+       break;
+      case SPE_STOP_AND_SIGNAL:
+       printf("eh: spu[%d] SPE_STOP_AND_SIGNAL w/ spe_signal_code = 0x%x\n",
+              spe_num, si.result.spe_signal_code);
+       break;
+      case SPE_RUNTIME_ERROR:
+       printf("eh: spu[%d] SPE_RUNTIME_ERROR w/ spe_runtime_error = 0x%x\n",
+              spe_num, si.result.spe_runtime_error);
+       break;
+      case SPE_RUNTIME_EXCEPTION:
+       printf("eh: spu[%d] SPE_RUNTIME_EXCEPTION w/ spe_runtime_exception = 0x%x\n",
+              spe_num, si.result.spe_runtime_exception);
+       break;
+      case SPE_RUNTIME_FATAL:
+       printf("eh: spu[%d] SPE_RUNTIME_FATAL w/ spe_runtime_fatal = 0x%x\n",
+              spe_num, si.result.spe_runtime_fatal);
+       break;
+      case SPE_CALLBACK_ERROR:
+       printf("eh: spu[%d] SPE_CALLBACK_ERROR w/ spe_callback_error = 0x%x\n",
+              spe_num, si.result.spe_callback_error);
+       break;
+      case SPE_ISOLATION_ERROR:
+       printf("eh: spu[%d] SPE_ISOLATION_ERROR w/ spe_isolation_error = 0x%x\n",
+              spe_num, si.result.spe_isolation_error);
+       break;
+      default:
+       printf("eh: spu[%d] UNKNOWN STOP REASON (%d) w/ spu_status = 0x%x\n",
+              spe_num, si.stop_reason, si.spu_status);
+       break;
+      }
+    }
+  }
+#if 0 // not enabled
+  else if (evt->events == SPE_EVENT_IN_MBOX){   // there's room to write to SPE
+    // spe_in_mbox_write (ignore)
+  }
+  else if (evt->events == SPE_EVENT_TAG_GROUP){         // our DMA completed
+    // spe_mfcio_tag_status_read
+  }
+#endif
+  else {
+    fprintf(stderr, "handle_event: unexpected evt->events = 0x%x\n", evt->events);
+    return;
+  }
+}
+
+//
+// This is the "main program" of the event handling thread
+//
+void
+gc_job_manager_impl::event_handler_loop()
+{
+  static const int MAX_EVENTS = 16;
+  static const int TIMEOUT = 20;       // how long to block in milliseconds
+
+  spe_event_unit_t events[MAX_EVENTS];
+
+  if (d_debug)
+    printf("event_handler_loop: starting\n");
+
+  set_eh_state(EHS_RUNNING);
+
+  // ask the first spe for its max bufsize
+  send_spe(0, MK_MBOX_MSG(OP_GET_SPU_BUFSIZE, 0));
+
+  while (1){
+    switch(d_eh_state){
+
+    case EHS_RUNNING:      // normal stuff
+      if (d_shutdown_requested) {
+       set_eh_state(EHS_SHUTTING_DOWN);
+      }
+      break;
+
+    case EHS_SHUTTING_DOWN:
+
+      // FIXME wait until job queue is empty, then tell them to exit
+
+      send_all_spes(MK_MBOX_MSG(OP_EXIT, 0));
+      set_eh_state(EHS_WAITING_FOR_WORKERS_TO_DIE);
+      break;
+
+    case EHS_WAITING_FOR_WORKERS_TO_DIE:
+      {
+       bool all_dead = true;
+       for (unsigned int i = 0; i < d_options.nspes; i++)
+         all_dead &= d_worker[i].state == WS_DEAD;
+
+       if (all_dead){
+         set_eh_state(EHS_DEAD);
+         if (d_debug)
+           printf("event_handler_loop: exiting\n");
+         return;
+       }
+      }
+      break;
+
+    default:
+      set_eh_state(EHS_DEAD);
+      printf("event_handler_loop(default): exiting\n");
+      return;
+    }
+
+    // block waiting for events...
+    int nevents = spe_event_wait(d_spe_event_handler.ptr,
+                                events, MAX_EVENTS, TIMEOUT);
+    if (nevents < 0){
+      perror("spe_wait_event");
+      // FIXME bail?
+    }
+    for (int i = 0; i < nevents; i++){
+      handle_event(&events[i]);
+    }
+  }
+}
+
+////////////////////////////////////////////////////////////////////////
+// This is the top of the SPE worker threads
+
+static void *
+start_worker(void *arg)
+{
+  worker_ctx *w = (worker_ctx *) arg;
+  spe_stop_info_t      si;
+
+  w->state = WS_RUNNING;
+  if (s_worker_debug)
+    printf("worker[%d]: WS_RUNNING\n", w->spe_idx);
+
+  unsigned int entry = SPE_DEFAULT_ENTRY;
+  int r = spe_context_run(w->spe_ctx,  &entry, 0, w->spu_args, 0, &si);
+
+  if (r < 0){                  // error
+    char buf[64];
+    snprintf(buf, sizeof(buf), "worker[%d]: spe_context_run", w->spe_idx);
+    perror(buf);
+  }
+  else if (r == 0){
+    // spe program called exit.
+    if (s_worker_debug)
+      printf("worker[%d]: SPE_EXIT w/ exit_code = %d\n",
+            w->spe_idx, si.result.spe_exit_code);
+  }
+  else {
+    // called stop_and_signal
+    //
+    // I'm not sure we'll ever get here.  I think the event
+    // handler will catch this...
+    printf("worker[%d]: SPE_STOP_AND_SIGNAL w/ spe_signal_code = 0x%x\n",
+          w->spe_idx, si.result.spe_signal_code);
+  }
+
+  // in any event, we're committing suicide now ;)
+  if (s_worker_debug)
+    printf("worker[%d]: WS_DEAD\n", w->spe_idx);
+
+  w->state = WS_DEAD;
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+gc_client_thread_info *
+gc_job_manager_impl::alloc_cti()
+{
+  for (unsigned int i = 0; i < d_options.max_client_threads; i++){
+    if (d_client_thread[i].d_free){
+      // try to atomically grab it
+      if (_atomic_dec_if_positive(ptr_to_ea(&d_client_thread[i].d_free)) == 0){
+       // got it...
+       gc_client_thread_info *cti = &d_client_thread[i];
+       cti->d_state = CT_NOT_WAITING;
+       bv_zero(cti->d_jobs_done);
+       cti->d_njobs_waiting_for = 0;
+       cti->d_jobs_waiting_for = 0;
+       
+       return cti;
+      }
+    }
+  }
+  return 0;
+}
+
+void
+gc_job_manager_impl::free_cti(gc_client_thread_info *cti)
+{
+  assert((size_t) (cti - d_client_thread.get()) < d_options.max_client_threads);
+  cti->d_free = 1;
+}
+
+int
+gc_job_manager_impl::ea_args_maxsize()
+{
+  omni_mutex_lock      l(d_eh_mutex);
+
+  while (d_ea_args_maxsize == 0)       // wait for it to be initialized
+    d_eh_cond.wait();
+
+  return d_ea_args_maxsize;
+}
+
+void
+gc_job_manager_impl::set_debug(int debug)
+{
+  d_debug = debug;
+  s_worker_debug = debug;
+}
+
+int
+gc_job_manager_impl::debug()
+{
+  return d_debug;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void
+gc_job_manager_impl::setup_logfiles()
+{
+  if (!d_options.enable_logging)
+    return;
+
+  if (d_options.log2_nlog_entries == 0)
+    d_options.log2_nlog_entries = 12;
+
+  // must end up a multiple of the page size
+
+  size_t pagesize = getpagesize();
+  size_t s = (1 << d_options.log2_nlog_entries) * sizeof(gc_log_entry_t);
+  s = ((s + pagesize - 1) / pagesize) * pagesize;
+  size_t nentries = s / sizeof(gc_log_entry_t);
+  assert(is_power_of_2(nentries));
+
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    char filename[100];
+    snprintf(filename, sizeof(filename), "spu_log.%02d", i);
+    int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0664);
+    if (fd == -1){
+      perror(filename);
+      return;
+    }
+    lseek(fd, s - 1, SEEK_SET);
+    write(fd, "\0", 1);
+    void *p = mmap(0, s, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+    if (p == MAP_FAILED){
+      perror("gc_job_manager_impl::setup_logfiles: mmap");
+      close(fd);
+      return;
+    }
+    close(fd);
+    memset(p, 0, s);
+    d_spu_args[i].log.base = ptr_to_ea(p);
+    d_spu_args[i].log.nentries = nentries;
+  }
+}
+
+void
+gc_job_manager_impl::sync_logfiles()
+{
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    if (d_spu_args[i].log.base)
+      msync(ea_to_ptr(d_spu_args[i].log.base),
+           d_spu_args[i].log.nentries * sizeof(gc_log_entry_t),
+           MS_ASYNC);
+  }
+}
+
+void
+gc_job_manager_impl::unmap_logfiles()
+{
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    if (d_spu_args[i].log.base)
+      munmap(ea_to_ptr(d_spu_args[i].log.base),
+            d_spu_args[i].log.nentries * sizeof(gc_log_entry_t));
+  }
+}
+
+////////////////////////////////////////////////////////////////////////
+//
+// lookup proc names in d_proc_def table
+
+gc_proc_id_t 
+gc_job_manager_impl::lookup_proc(const std::string &proc_name)
+{
+  for (int i = 0; i < d_nproc_defs; i++)
+    if (proc_name == d_proc_def[i].name)
+      return i;
+
+  throw gc_unknown_proc(proc_name);
+}
+
+std::vector<std::string>
+gc_job_manager_impl::proc_names()
+{
+  std::vector<std::string> r;
+  for (int i = 0; i < d_nproc_defs; i++)
+    r.push_back(d_proc_def[i].name);
+
+  return r;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+worker_ctx::~worker_ctx()
+{
+  if (spe_ctx){
+    int r = spe_context_destroy(spe_ctx);
+    if (r != 0){
+      perror("spe_context_destroy");
+    }
+    spe_ctx = 0;
+  }
+  state = WS_FREE;
+}
diff --git a/gcell/lib/runtime/gc_job_manager_impl.h b/gcell/lib/runtime/gc_job_manager_impl.h
new file mode 100644 (file)
index 0000000..dad7873
--- /dev/null
@@ -0,0 +1,252 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_GC_JOB_MANAGER_IMPL_H
+#define INCLUDED_GC_JOB_MANAGER_IMPL_H
+
+#include <gcell/gc_job_manager.h>
+#include <gcell/gc_jd_stack.h>
+#include <gcell/gc_jd_queue.h>
+#include <gcell/gc_spu_args.h>
+#include "gc_client_thread_info.h"
+#include <libspe2.h>
+#include <vector>
+#include <boost/scoped_array.hpp>
+
+typedef boost::shared_ptr<spe_gang_context> spe_gang_context_sptr;
+typedef boost::shared_ptr<spe_program_handle_t> spe_program_handle_sptr;
+typedef boost::scoped_array<gc_client_thread_info> gc_client_thread_info_sa;
+
+
+enum worker_state {
+  WS_FREE,     // not in use
+  WS_INIT,     // allocated and being initialized
+  WS_RUNNING,  // the thread is running
+  WS_DEAD,     // the thread is dead
+};
+
+struct worker_ctx {
+  volatile worker_state        state;
+  unsigned int         spe_idx;        // [0, nspes-1]
+  spe_context_ptr_t    spe_ctx;
+  pthread_t            thread;
+  gc_spu_args_t                *spu_args;      // pointer to 16-byte aligned struct
+
+  worker_ctx()
+    : state(WS_FREE), spe_idx(0), spe_ctx(0),
+      thread(0), spu_args(0) {}
+  ~worker_ctx();
+};
+
+enum evt_handler_state {
+  EHS_INIT,            // being initialized
+  EHS_RUNNING,         // thread is running
+  EHS_SHUTTING_DOWN,   // in process of shutting down everything
+  EHS_WAITING_FOR_WORKERS_TO_DIE,
+  EHS_DEAD,            // thread is dead
+};
+
+struct spe_event_handler {
+  spe_event_handler_ptr_t      ptr;
+
+  spe_event_handler() : ptr(0) {}
+  ~spe_event_handler(){
+    if (ptr){
+      if (spe_event_handler_destroy(ptr) != 0){
+       perror("spe_event_handler_destroy");
+      }
+    }
+  }
+};
+
+
+/*!
+ * \brief Concrete class that manages SPE jobs.
+ *
+ * This class contains all the implementation details.
+ */
+class gc_job_manager_impl : public gc_job_manager
+{
+  enum { MAX_SPES =  16 };
+
+  int                    d_debug;
+  gc_jm_options                  d_options;
+  spe_program_handle_sptr d_spe_image;
+  spe_gang_context_sptr   d_gang;              // boost::shared_ptr
+
+  worker_ctx            d_worker[MAX_SPES];    // SPE ctx, thread, etc
+  gc_spu_args_t                *d_spu_args;            // 16-byte aligned structs
+  boost::shared_ptr<void> _d_spu_args_boost;   // hack for automatic storage mgmt
+
+  gc_comp_info_t       *d_comp_info;           // 128-byte aligned structs
+  boost::shared_ptr<void> _d_comp_info_boost;  // hack for automatic storage mgmt
+
+  // used to coordinate communication w/ the event handling thread
+  omni_mutex            d_eh_mutex;
+  omni_condition        d_eh_cond;
+  pthread_t             d_eh_thread;           // the event handler thread
+  volatile evt_handler_state   d_eh_state;
+  volatile bool                        d_shutdown_requested;
+  spe_event_handler     d_spe_event_handler;
+  
+
+  // All of the job descriptors are hung off of here.
+  // We allocate them all in a single cache aligned chunk.
+  gc_job_desc_t                *d_jd;                  // [options.max_jobs]
+  boost::shared_ptr<void> _d_jd_boost;         // hack for automatic storage mgmt
+
+  gc_client_thread_info_sa d_client_thread;    // [options.max_client_threads]
+
+  // We use bitvectors to represent the completing state of a job.  Each
+  // bitvector is d_bvlen longs in length.
+  int                   d_bvlen;               // bit vector length in longs
+
+  // This contains the storage for all the bitvectors used by the job
+  // manager.  There's 1 for each client thread, in the d_jobs_done
+  // field.  We allocate them all in a single cache aligned chunk.
+  boost::shared_ptr<void> _d_all_bitvectors;   // hack for automatic storage mgmt
+
+  // Lock free stack where we keep track of the free job descriptors.
+  gc_jd_stack_t                *d_free_list;           // stack of free job descriptors
+  boost::shared_ptr<void> _d_free_list_boost;  // hack for automatic storage mgmt
+
+  // The PPE inserts jobs here; SPEs pull jobs from here.
+  gc_jd_queue_t                *d_queue;               // job queue
+  boost::shared_ptr<void> _d_queue_boost;      // hack for automatic storage mgmt
+
+  int                   d_ea_args_maxsize;
+
+  struct gc_proc_def   *d_proc_def;            // the SPE procedure table
+  uint32_t              d_proc_def_ls_addr;    // the LS address of the table
+  int                   d_nproc_defs;          // number of proc_defs in table
+
+  gc_client_thread_info *alloc_cti();
+  void free_cti(gc_client_thread_info *cti);
+
+  void create_event_handler();
+  void set_eh_state(evt_handler_state s);
+  void set_ea_args_maxsize(int maxsize);
+
+  void notify_clients_jobs_are_done(unsigned int spe_num,
+                                   unsigned int completion_info_idx);
+
+public:
+  void event_handler_loop();   // really private
+
+private:
+  bool send_all_spes(uint32_t msg);
+  bool send_spe(unsigned int spe, uint32_t msg);
+  void print_event(spe_event_unit_t *evt);
+  void handle_event(spe_event_unit_t *evt);
+
+  // bitvector ops
+  void bv_zero(unsigned long *bv);
+  void bv_clr(unsigned long *bv, unsigned int bitno);
+  void bv_set(unsigned long *bv, unsigned int bitno);
+  bool bv_isset(unsigned long *bv, unsigned int bitno);
+  bool bv_isclr(unsigned long *bv, unsigned int bitno);
+
+  void setup_logfiles();
+  void sync_logfiles();
+  void unmap_logfiles();
+
+  friend gc_job_manager_sptr gc_make_job_manager(const gc_jm_options *options);
+  
+  gc_job_manager_impl(const gc_jm_options *options = 0);
+
+public:
+  virtual ~gc_job_manager_impl();
+
+  /*!
+   * Stop accepting new jobs.  Wait for existing jobs to complete.
+   * Return all managed SPE's to the system.
+   */
+  virtual bool shutdown();
+
+  /*!
+   * \brief Return number of SPE's currently allocated to job manager.
+   */
+  virtual int nspes() const;
+
+  /*!
+   * \brief Return a pointer to a properly aligned job descriptor,
+   * or zero if none are available.
+   */
+  virtual gc_job_desc *alloc_job_desc();
+
+  /*
+   *! Return a job descriptor previously allocated with alloc_job_desc()
+   *
+   * \param[in] jd pointer to job descriptor to free.
+   */
+  virtual void free_job_desc(gc_job_desc *jd);
+
+  /*!
+   * \brief Submit a job for asynchronous processing on an SPE.
+   *
+   * \param[in] jd pointer to job description
+   *
+   * The caller must not read or write the job description
+   * or any of the memory associated with any indirect arguments
+   * until after calling wait_job.
+   *
+   * \returns true iff the job was successfully enqueued.
+   * If submit_job returns false, check jd->status for additional info.
+   */
+  virtual bool submit_job(gc_job_desc *jd);
+
+  /*!
+   * \brief Wait for job to complete.
+   *
+   * A thread may only wait for jobs which it submitted.
+   *
+   * \returns true if sucessful, else false.
+   */
+  virtual bool 
+  wait_job(gc_job_desc *jd);
+
+  /*!
+   * \brief wait for 1 or more jobs to complete.
+   *
+   * \param[input] njobs is the length of arrays \p jd and \p done.
+   * \param[input] jd are the jobs that are to be waited for.
+   * \param[output] done indicates whether the corresponding job is complete.
+   * \param[input] mode indicates whether to wait for ALL or ANY of the jobs
+   *   in \p jd to complete.
+   *
+   * A thread may only wait for jobs which it submitted.
+   *
+   * \returns number of jobs completed, or -1 if error.
+   */
+  virtual int
+  wait_jobs(unsigned int njobs,
+           gc_job_desc *jd[], bool done[], gc_wait_mode mode);
+
+  virtual int ea_args_maxsize();
+
+  virtual gc_proc_id_t lookup_proc(const std::string &name);
+  virtual std::vector<std::string> proc_names();
+
+  virtual void set_debug(int debug);
+  virtual int debug();
+};
+
+#endif /* INCLUDED_GC_JOB_MANAGER_IMPL_H */
diff --git a/gcell/lib/runtime/gc_proc_def_utils.cc b/gcell/lib/runtime/gc_proc_def_utils.cc
new file mode 100644 (file)
index 0000000..0250d67
--- /dev/null
@@ -0,0 +1,123 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gc_proc_def_utils.h>
+#include <gcell/gc_declare_proc.h>
+#include <elf.h>
+#include <stdio.h>
+#include <string.h>
+
+static const unsigned char expected[EI_PAD] = {
+  ELFMAG0,
+  ELFMAG1,
+  ELFMAG2,
+  ELFMAG3,
+  ELFCLASS32,
+  ELFDATA2MSB,
+  EV_CURRENT,
+  ELFOSABI_SYSV,
+  0
+};
+
+
+/*
+ * Basically we're going to find the GC_PROC_DEF_SECTION section
+ * in the ELF file and return a pointer to it.  The only things in that
+ * section are gc_proc_def's
+ */
+bool 
+gcpd_find_table(spe_program_handle_t *handle,
+               struct gc_proc_def **table, int *nentries, uint32_t *ls_addr)
+{
+  if (!handle || !table || !nentries)
+    return false;
+
+  *table = 0;
+  *nentries = 0;
+  
+  Elf32_Ehdr *ehdr = (Elf32_Ehdr *)handle->elf_image;
+  if (!ehdr){
+    fprintf(stderr, "gcpd: No ELF image has been loaded\n");
+    return false;
+  }
+
+  // quick check that we're looking at a SPE EXEC object
+
+  if (memcmp(ehdr->e_ident, expected, EI_PAD) != 0){
+    fprintf(stderr, "gcpd: invalid ELF header\n");
+    return false;
+  }
+
+  if (ehdr->e_machine != 0x17){                // confirm machine type (EM_SPU)
+    fprintf(stderr, "gcpd: not an SPE ELF object\n");
+    return false;
+  }
+
+  if (ehdr->e_type != ET_EXEC){
+    fprintf(stderr, "gcpd: invalid SPE ELF type.\n");
+    fprintf(stderr, "gcpd: SPE type %d != %d\n", ehdr->e_type, ET_EXEC);
+    return false;
+  }
+
+  // find the section header table
+
+  Elf32_Shdr *shdr;
+  Elf32_Shdr *sh;
+
+  if (ehdr->e_shentsize != sizeof (*shdr)){
+    fprintf(stderr, "gcpd: invalid section header format.\n");
+    return false;
+  }
+
+  if (ehdr->e_shnum == 0){
+    fprintf(stderr, "gcpd: no section headers in file.\n");
+    return false;
+  }
+
+  shdr = (Elf32_Shdr *) ((char *)ehdr + ehdr->e_shoff);
+  char *str_table = (char *)ehdr + shdr[ehdr->e_shstrndx].sh_offset;
+
+  // traverse the sections looking for GC_PROC_DEF_SECTION
+  
+  for (sh = shdr; sh < &shdr[ehdr->e_shnum]; sh++){
+    if (0){
+      fprintf(stderr, "section name: %s (start: 0x%04x, size: 0x%04x)\n",
+             str_table + sh->sh_name, sh->sh_offset, sh->sh_size);
+    }
+
+    if (strcmp(GC_PROC_DEF_SECTION, str_table+sh->sh_name) == 0){
+      *table = (struct gc_proc_def *)((char *)ehdr + sh->sh_offset);
+      if (sh->sh_size % (sizeof(struct gc_proc_def)) != 0){
+       fprintf(stderr, "gcpd: %s section has invalid format\n", GC_PROC_DEF_SECTION);
+       return false;
+      }
+      *nentries = sh->sh_size / sizeof(struct gc_proc_def);
+      *ls_addr = sh->sh_addr;
+      return true;
+    }
+  }
+
+  return false;
+}
diff --git a/gcell/lib/runtime/gc_proc_def_utils.h b/gcell/lib/runtime/gc_proc_def_utils.h
new file mode 100644 (file)
index 0000000..79c9b51
--- /dev/null
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GC_PROC_DEF_UTILS_H
+#define INCLUDED_GC_PROC_DEF_UTILS_H
+
+#include <gcell/gc_declare_proc.h>
+#include <libspe2.h>
+
+/*!
+ * \brief find the gc_proc_def table in the SPE program
+ *
+ * \param[in]  program is the handle to the loaded SPE program
+ * \param[out] table points to the table, if it's found
+ * \param[out] nentries is set to the number of entries in the table.
+ * \param[out] ls_addr is set to the Local Store address of the table
+ *
+ * \returns true if successful, else false
+ */
+bool
+gcpd_find_table(spe_program_handle_t *program,
+               struct gc_proc_def **table, int *nentries, uint32_t *ls_addr);
+
+
+#endif /* INCLUDED_GC_PROC_DEF_UTILS_H */
diff --git a/gcell/lib/runtime/gcell-embedspu-libtool b/gcell/lib/runtime/gcell-embedspu-libtool
new file mode 100755 (executable)
index 0000000..c206086
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Take a spu executable and turn into into a libtool compatible .lo (and .o) file.
+# This is needed when you want to embed a SPU executable into a shared library.
+#
+# The symbol assigned to the embedded executable is the basename of the
+# output file with an _spx appended.  E.g., if the output filename is
+# my_spe_tricks.lo the symbol name is my_spe_tricks_spx.
+# ("_spx" stands for SPE executable)
+
+if [ $# -ne 2 ]; then
+  echo "usage: gcell-embedspu-libtool spu_executable output_file.lo " 1>&2
+  exit 1
+fi
+
+spu_executable=$1
+lo_file=$2
+symbol_name=${lo_file%%.lo}_spx
+
+# try to make .libs in case it's not there
+mkdir .libs >/dev/null 2>/dev/null
+
+# generate the .o file that wraps the SPU executable
+ppu-embedspu -m32 -fpic ${symbol_name} ${spu_executable} .libs/${symbol_name}.o
+
+# generate the .lo libtool file that points at all the right places
+rm -f $lo_file
+cat >$lo_file.new <<EOF
+# $lo_file - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+pic_object='.libs/${symbol_name}.o'
+non_pic_object=none
+EOF
+
+mv $lo_file.new $lo_file
+
diff --git a/gcell/lib/runtime/qa_gcell_runtime.cc b/gcell/lib/runtime/qa_gcell_runtime.cc
new file mode 100644 (file)
index 0000000..fef9a7f
--- /dev/null
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * This class gathers together all the test cases for the lib
+ * directory into a single test suite.  As you create new test cases,
+ * add them here.
+ */
+
+#include <qa_gcell_runtime.h>
+#include <qa_jd_stack.h>
+#include <qa_jd_queue.h>
+#include <qa_job_manager.h>
+
+CppUnit::TestSuite *
+qa_gcell_runtime::suite()
+{
+  CppUnit::TestSuite   *s = new CppUnit::TestSuite("runtime");
+
+  s->addTest(qa_jd_stack::suite());
+  s->addTest(qa_jd_queue::suite());
+  s->addTest(qa_job_manager::suite());
+
+  return s;
+}
diff --git a/gcell/lib/runtime/qa_gcell_runtime.h b/gcell/lib/runtime/qa_gcell_runtime.h
new file mode 100644 (file)
index 0000000..36180c9
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_QA_GCELL_RUNTIME_H
+#define INCLUDED_QA_GCELL_RUNTIME_H
+
+#include <cppunit/TestSuite.h>
+
+//! collect all the tests for the runtime directory
+
+class qa_gcell_runtime {
+public:
+  //! return suite of tests
+  static CppUnit::TestSuite *suite();
+};
+
+
+#endif /* INCLUDED_QA_GCELL_RUNTIME_H */
diff --git a/gcell/lib/runtime/qa_jd_queue.cc b/gcell/lib/runtime/qa_jd_queue.cc
new file mode 100644 (file)
index 0000000..35ab9d8
--- /dev/null
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_jd_queue.h"
+#include <cppunit/TestAssert.h>
+#include <gcell/gc_jd_queue.h>
+#include <stdio.h>
+
+
+
+static const int NJDS = 16;
+static gc_jd_queue_t queue;
+static gc_job_desc_t jds[NJDS];
+
+// no brainer, single threaded basic checkout
+void
+qa_jd_queue::t1()
+{
+  // N.B., queue allocated stuff doesn't obey ((aligned (N))) attributes
+  //const int NJDS = 8;
+  //gc_jd_queue_t queue;
+  //gc_job_desc_t jds[NJDS];
+
+  //printf("&queue   = %p\n", &queue);
+  //printf("&jds[0] = %p\n", &jds[0]);
+  //printf("&jds[1] = %p\n", &jds[1]);
+
+  CPPUNIT_ASSERT(((uintptr_t) &queue & 0x7f) == 0);
+  CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
+  CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
+
+  gc_jd_queue_init(&queue);
+
+  CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
+
+  gc_jd_queue_enqueue(&queue, &jds[0]);
+  CPPUNIT_ASSERT_EQUAL(&jds[0], gc_jd_queue_dequeue(&queue));
+
+  CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
+
+  for (int i = 0; i < NJDS; i++)
+    gc_jd_queue_enqueue(&queue, &jds[i]);
+
+  for (int i = 0; i < NJDS; i++)
+    CPPUNIT_ASSERT_EQUAL(&jds[i], gc_jd_queue_dequeue(&queue));
+
+  CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
+}
+
+// FIXME multithreaded (running on PPE)
+void
+qa_jd_queue::t2()
+{
+}
+
+// FIXME multithreaded (running on PPE & SPE)
+void
+qa_jd_queue::t3()
+{
+}
diff --git a/gcell/lib/runtime/qa_jd_queue.h b/gcell/lib/runtime/qa_jd_queue.h
new file mode 100644 (file)
index 0000000..5e1aab8
--- /dev/null
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_QA_JD_QUEUE_H
+#define INCLUDED_QA_JD_QUEUE_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_jd_queue : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_jd_queue);
+  CPPUNIT_TEST(t1);
+  CPPUNIT_TEST(t2);
+  CPPUNIT_TEST(t3);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void t1();
+  void t2();
+  void t3();
+};
+
+
+#endif /* INCLUDED_QA_JD_QUEUE_H */
diff --git a/gcell/lib/runtime/qa_jd_stack.cc b/gcell/lib/runtime/qa_jd_stack.cc
new file mode 100644 (file)
index 0000000..ce4ce2d
--- /dev/null
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_jd_stack.h"
+#include <cppunit/TestAssert.h>
+#include <gcell/gc_jd_stack.h>
+#include <stdio.h>
+
+
+
+static const int NJDS = 8;
+static gc_jd_stack_t stack;
+static gc_job_desc_t jds[NJDS];
+
+// no brainer, single threaded basic checkout
+void
+qa_jd_stack::t1()
+{
+  // N.B., stack allocated stuff doesn't obey ((aligned (N))) attributes
+  //const int NJDS = 8;
+  //gc_jd_stack_t stack;
+  //gc_job_desc_t jds[NJDS];
+
+  //printf("&stack   = %p\n", &stack);
+  //printf("&jds[0] = %p\n", &jds[0]);
+  //printf("&jds[1] = %p\n", &jds[1]);
+
+  CPPUNIT_ASSERT(((uintptr_t) &stack & 0x7f) == 0);
+  CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
+  CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
+
+  gc_jd_stack_init(&stack);
+
+  CPPUNIT_ASSERT(gc_jd_stack_pop(&stack) == 0);
+
+  for (int i = 0; i < NJDS; i++)
+    gc_jd_stack_push(&stack, &jds[i]);
+
+  for (int i = 0; i < NJDS; i++)
+    CPPUNIT_ASSERT_EQUAL(&jds[NJDS - i - 1], gc_jd_stack_pop(&stack));
+
+  CPPUNIT_ASSERT(gc_jd_stack_pop(&stack) == 0);
+}
+
+// FIXME multithreaded (running on PPE)
+void
+qa_jd_stack::t2()
+{
+}
diff --git a/gcell/lib/runtime/qa_jd_stack.h b/gcell/lib/runtime/qa_jd_stack.h
new file mode 100644 (file)
index 0000000..1546bbf
--- /dev/null
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_QA_JD_STACK_H
+#define INCLUDED_QA_JD_STACK_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_jd_stack : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_jd_stack);
+  CPPUNIT_TEST(t1);
+  CPPUNIT_TEST(t2);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void t1();
+  void t2();
+
+};
+
+
+
+#endif /* INCLUDED_QA_JD_STACK_H */
diff --git a/gcell/lib/runtime/qa_job_manager.cc b/gcell/lib/runtime/qa_job_manager.cc
new file mode 100644 (file)
index 0000000..45cf26c
--- /dev/null
@@ -0,0 +1,790 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_job_manager.h"
+#include <cppunit/TestAssert.h>
+#include <gcell/gc_job_manager.h>
+#include <stdexcept>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+#include <string.h>
+
+#include <malloc.h>
+
+// handle to embedded SPU executable w/ QA routines
+extern spe_program_handle_t gcell_runtime_qa_spx;
+
+#if 0
+static void
+gc_msleep(unsigned long millisecs)
+{
+  int r;
+  struct timespec tv;
+  tv.tv_sec = millisecs / 1000;
+  tv.tv_nsec = (millisecs - (tv.tv_sec * 1000)) * 1000000;
+  
+  while (1){
+    r = nanosleep(&tv, &tv);
+    if (r == 0)
+      return;
+    if (r == -1 && errno == EINTR)
+      continue;
+    perror("nanosleep");
+    return;
+  }
+}
+#endif
+
+void
+qa_job_manager::leak_check(test_t t, const std::string &name)
+{
+  struct mallinfo before, after;
+
+  before = mallinfo();
+  (this->*t)();
+  after = mallinfo();
+
+  size_t delta = after.uordblks - before.uordblks;
+  if (delta != 0){
+    std::cout << name << " leaked memory\n";
+    printf("  before.uordblks = %6d\n", before.uordblks);
+    printf("  after.uordblks  = %6d\n",  after.uordblks);
+    printf("  delta = %d\n", after.uordblks - before.uordblks);
+  }
+}
+
+void
+qa_job_manager::t0()
+{
+  //leak_check(&qa_job_manager::t1_body, "t1-0");
+}
+
+void
+qa_job_manager::t1()
+{
+  t1_body();           // leaks 800 bytes first time, could be one-time inits
+  leak_check(&qa_job_manager::t1_body, "t1");
+}
+
+void
+qa_job_manager::t2()
+{
+  leak_check(&qa_job_manager::t2_body, "t2");
+}
+
+void
+qa_job_manager::t3()
+{
+  t3_body();           // leaks first time only, could be cppunit
+  leak_check(&qa_job_manager::t3_body, "t3");
+}
+
+void
+qa_job_manager::t4()
+{
+  leak_check(&qa_job_manager::t4_body, "t4");
+}
+
+void
+qa_job_manager::t5()
+{
+  leak_check(&qa_job_manager::t5_body, "t5");
+}
+
+void
+qa_job_manager::t6()
+{
+  leak_check(&qa_job_manager::t6_body, "t6");
+}
+
+void
+qa_job_manager::t7()
+{
+  leak_check(&qa_job_manager::t7_body, "t7");
+}
+
+void
+qa_job_manager::t8()
+{
+  leak_check(&qa_job_manager::t8_body, "t8");
+}
+
+void
+qa_job_manager::t9()
+{
+  leak_check(&qa_job_manager::t9_body, "t9");
+}
+
+void
+qa_job_manager::t10()
+{
+  leak_check(&qa_job_manager::t10_body, "t10");
+}
+
+void
+qa_job_manager::t11()
+{
+  leak_check(&qa_job_manager::t11_body, "t11");
+}
+
+void
+qa_job_manager::t12()
+{
+  leak_check(&qa_job_manager::t12_body, "t12");
+}
+
+void
+qa_job_manager::t13()
+{
+  leak_check(&qa_job_manager::t13_body, "t13");
+}
+
+void
+qa_job_manager::t14()
+{
+  leak_check(&qa_job_manager::t14_body, "t14");
+}
+
+void
+qa_job_manager::t15()
+{
+  leak_check(&qa_job_manager::t15_body, "t15");
+}
+
+// ----------------------------------------------------------------
+
+void
+qa_job_manager::t1_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  mgr = gc_make_job_manager(&opts);
+}
+
+void
+qa_job_manager::t2_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 100;
+  opts.gang_schedule = false;
+  mgr = gc_make_job_manager(&opts);
+}
+
+void
+qa_job_manager::t3_body()
+{
+  // This leaks memory the first time it's invoked, but I'm not sure
+  // if it's us or the underlying exception handling mechanism, or
+  // cppunit.  cppunit is the prime suspect.
+
+#if 0
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 100;
+  opts.gang_schedule = true;
+  CPPUNIT_ASSERT_THROW(mgr = gc_make_job_manager(&opts), std::out_of_range);
+#endif
+}
+
+static void
+init_jd(gc_job_desc *jd, gc_proc_id_t proc_id)
+{
+  jd->proc_id = proc_id;
+  jd->input.nargs = 0;
+  jd->output.nargs = 0;
+  jd->eaa.nargs = 0;
+}
+
+void
+qa_job_manager::t4_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+  //mgr->set_debug(-1);
+  static const int NJOBS = 32;
+  gc_job_desc *jds[NJOBS];
+  bool done[NJOBS];
+
+  gc_proc_id_t gcp_no_such;
+  CPPUNIT_ASSERT_THROW(gcp_no_such = mgr->lookup_proc("--no-such-proc-name--"), gc_unknown_proc);
+
+  gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
+  CPPUNIT_ASSERT(gcp_qa_nop != GCP_UNKNOWN_PROC);
+
+  for (int i = 0; i < NJOBS; i++){
+    jds[i] = mgr->alloc_job_desc();
+    init_jd(jds[i], gcp_qa_nop);
+  }
+
+  for (int i = 0; i < NJOBS; i++){
+    if (!mgr->submit_job(jds[i])){
+      printf("%d: submit_job(jds[%d]) failed, status = %d\n",
+            __LINE__, i, jds[i]->status);
+    }
+  }
+
+  int n = mgr->wait_jobs(NJOBS, jds, done, GC_WAIT_ALL);
+  CPPUNIT_ASSERT_EQUAL(NJOBS, n);
+
+  for (int i = 0; i < NJOBS; i++){
+    mgr->free_job_desc(jds[i]);
+  }
+}
+
+void
+qa_job_manager::t5_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 0;      // use them all
+  mgr = gc_make_job_manager(&opts);
+  //mgr->set_debug(-1);
+  static const int NJOBS = 32;
+  gc_job_desc *jds[NJOBS];
+  bool done[NJOBS];
+
+  gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
+
+  for (int i = 0; i < NJOBS; i++){
+    jds[i] = mgr->alloc_job_desc();
+    init_jd(jds[i], gcp_qa_nop);
+  }
+
+  for (int i = 0; i < NJOBS; i++){
+    if (!mgr->submit_job(jds[i])){
+      printf("%d: submit_job(jds[%d]) failed, status = %d\n",
+            __LINE__, i, jds[i]->status);
+    }
+  }
+
+  int n = mgr->wait_jobs(NJOBS, jds, done, GC_WAIT_ALL);
+  CPPUNIT_ASSERT_EQUAL(NJOBS, n);
+
+  for (int i = 0; i < NJOBS; i++){
+    mgr->free_job_desc(jds[i]);
+  }
+}
+
+void
+qa_job_manager::t6_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;      
+  mgr = gc_make_job_manager(&opts);
+  gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
+  gc_job_desc *jd = mgr->alloc_job_desc();
+
+  
+  // test for success with gcp_qa_nop procedure
+  init_jd(jd, gcp_qa_nop);
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+  }
+
+  // test for JS_UNKNOWN_PROC with bogus procedure
+  init_jd(jd, -2);
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_UNKNOWN_PROC, jd->status);
+  }
+
+  mgr->free_job_desc(jd);
+}
+
+static int
+sum_shorts(short *p, int nshorts)
+{
+  int total = 0;
+  for (int i = 0; i < nshorts; i++)
+    total += p[i];
+
+  return total;
+}
+
+static void
+test_sum_shorts(gc_job_manager_sptr mgr, short *buf, int nshorts)
+{
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
+
+  init_jd(jd, gcp_qa_sum_shorts);
+  jd->eaa.nargs = 1;
+  jd->eaa.arg[0].ea_addr = ptr_to_ea(buf);
+  jd->eaa.arg[0].direction = GCJD_DMA_GET;
+  jd->eaa.arg[0].get_size = nshorts * sizeof(short);
+  
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+    int expected = sum_shorts(buf, nshorts);
+    int actual = jd->output.arg[0].s32;
+    CPPUNIT_ASSERT_EQUAL(expected, actual);
+  }
+
+  mgr->free_job_desc(jd);
+}
+
+static const int NS = 32768;
+static short short_buf[NS] _AL128;     // for known alignment
+
+//
+// test all "get" alignments and sizes
+//
+void
+qa_job_manager::t7_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+
+  int ea_args_maxsize = mgr->ea_args_maxsize();
+
+  for (int i = 0; i < NS; i++) // init buffer with known qty
+    short_buf[i] = 0x1234 + i;
+  
+  for (int offset = 0; offset <= 128; offset++){
+    for (int len = 0; len <= 128; len++){
+      test_sum_shorts(mgr, &short_buf[offset], len);
+    }
+  }
+
+  // confirm maximum length
+  for (int offset = 0; offset <= 64; offset++){
+    test_sum_shorts(mgr, &short_buf[offset], ea_args_maxsize/sizeof(short));
+  }
+}
+
+//
+// test "get" args too long
+//
+void
+qa_job_manager::t8_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
+
+  init_jd(jd, gcp_qa_sum_shorts);
+  jd->eaa.nargs = 1;
+  jd->eaa.arg[0].ea_addr = 0;
+  jd->eaa.arg[0].direction = GCJD_DMA_GET;
+  jd->eaa.arg[0].get_size = 1 << 20;
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_ARGS_TOO_LONG, jd->status);
+  }
+
+  mgr->free_job_desc(jd);
+}
+
+//
+// test MAX_ARGS_EA "get" case
+//
+void
+qa_job_manager::t9_body()
+{
+  static const int N = 127;
+  static const int M = 201;
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
+
+  init_jd(jd, gcp_qa_sum_shorts);
+  jd->eaa.nargs = MAX_ARGS_EA;
+  for (int i = 0; i < MAX_ARGS_EA; i++){
+    jd->eaa.arg[i].direction = GCJD_DMA_GET;
+    jd->eaa.arg[i].ea_addr = ptr_to_ea(&short_buf[i * M]);
+    jd->eaa.arg[i].get_size = N * sizeof(short);
+  }
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+    for (int i = 0; i < MAX_ARGS_EA; i++){
+      int expected = sum_shorts(&short_buf[i * M], N);
+      int actual = jd->output.arg[i].s32;
+      CPPUNIT_ASSERT_EQUAL(expected, actual);
+    }
+  }
+
+  mgr->free_job_desc(jd);
+}
+
+static bool
+confirm_const(const unsigned char *buf, size_t len, unsigned char v)
+{
+  bool ok = true;
+
+  for (size_t i = 0; i < len; i++){
+    if (buf[i] != v){
+      ok = false;
+      printf("confirm_const: buf[%6d] = 0x%02x, expected = 0x%02x\n",
+            i, buf[i], v);
+    }
+  }
+
+  return ok;
+}
+
+static bool
+confirm_seq(const unsigned char *buf, size_t len, unsigned char v)
+{
+  bool ok = true;
+
+  for (size_t i = 0; i < len; i++, v++){
+    if (buf[i] != v){
+      ok = false;
+      printf("confirm_seq: buf[%6d] = 0x%02x, expected = 0x%02x\n",
+            i, buf[i], v);
+    }
+  }
+
+  return ok;
+}
+
+static void
+test_put_seq(gc_job_manager_sptr mgr, int offset, int len, int starting_val)
+{
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
+
+  unsigned char *buf = (unsigned char *) short_buf;
+  size_t buf_len = sizeof(short_buf);
+  memset(buf, 0xff, buf_len);
+
+  // two cache lines into the buffer, so we can check before and after
+  int fixed_offset = 256;
+
+  init_jd(jd, gcp_qa_put_seq);
+  jd->input.nargs = 1;
+  jd->input.arg[0].s32 = starting_val;
+  jd->eaa.nargs = 1;
+  jd->eaa.arg[0].ea_addr = ptr_to_ea(buf + fixed_offset + offset);
+  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
+  jd->eaa.arg[0].put_size = len;
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+    
+    // check before
+    CPPUNIT_ASSERT(confirm_const(&buf[0], fixed_offset + offset, 0xff)); 
+
+    // check sequence
+    CPPUNIT_ASSERT(confirm_seq(&buf[fixed_offset + offset], len, starting_val));
+
+    // check after
+    CPPUNIT_ASSERT(confirm_const(&buf[fixed_offset + offset + len],
+                                buf_len - fixed_offset - offset - len, 0xff));
+  }
+  mgr->free_job_desc(jd);
+}
+
+//
+// Test all "put" alignments and sizes
+//
+void
+qa_job_manager::t10_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+
+  int starting_val = 13;
+
+  for (int offset = 0; offset <= 128; offset++){
+    for (int len = 0; len <= 128; len++){
+      test_put_seq(mgr, offset, len, starting_val++);
+    }
+  }
+
+  int ea_args_maxsize = mgr->ea_args_maxsize();
+
+  // confirm maximum length
+  for (int offset = 0; offset <= 64; offset++){
+    test_put_seq(mgr, offset, ea_args_maxsize, starting_val++);
+  }
+}
+
+//
+// test "put" args too long
+//
+void
+qa_job_manager::t11_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
+
+  init_jd(jd, gcp_qa_put_seq);
+  jd->input.nargs = 1;
+  jd->input.arg[0].s32 = 0;
+  jd->eaa.nargs = 1;
+  jd->eaa.arg[0].ea_addr = 0;
+  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
+  jd->eaa.arg[0].put_size = 1 << 20;
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_ARGS_TOO_LONG, jd->status);
+  }
+
+  mgr->free_job_desc(jd);
+}
+
+//
+// test MAX_ARGS_EA "put" case
+//
+void
+qa_job_manager::t12_body()
+{
+  static const int N = 127;
+  static const int M = 201;
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
+
+  unsigned char *buf = (unsigned char *) short_buf;
+  size_t buf_len = sizeof(short_buf);
+  memset(buf, 0xff, buf_len);
+
+  // two cache lines into the buffer, so we can check before and after
+  int fixed_offset = 256;
+
+  int starting_val = 13;
+
+  init_jd(jd, gcp_qa_put_seq);
+  jd->input.nargs = 1;
+  jd->input.arg[0].s32 = starting_val;
+  jd->eaa.nargs = MAX_ARGS_EA;
+  for (int i = 0; i < MAX_ARGS_EA; i++){
+    jd->eaa.arg[i].direction = GCJD_DMA_PUT;
+    jd->eaa.arg[i].ea_addr = ptr_to_ea(&buf[i * M + fixed_offset]);
+    jd->eaa.arg[i].put_size = N;
+  }
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+    for (int i = 0; i < MAX_ARGS_EA; i++){
+      CPPUNIT_ASSERT(confirm_seq(&buf[i * M + fixed_offset], N, starting_val));
+      starting_val += N;
+    }
+  }
+
+  mgr->free_job_desc(jd);
+}
+
+//
+// test qa_copy primitive
+//
+void
+qa_job_manager::t13_body()
+{
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+
+  memset(short_buf, 0, sizeof(short_buf));
+  for (int i = 0; i < NS/2; i++)       // init buffer with known qty
+    short_buf[i] = 0x1234 + i;
+
+  int nshorts = NS/2;
+
+  gc_job_desc *jd = mgr->alloc_job_desc();
+  gc_proc_id_t gcp_qa_copy = mgr->lookup_proc("qa_copy");
+
+#if 0
+  printf("gcq_qa_copy = %d\n", gcp_qa_copy);
+  std::vector<std::string> procs = mgr->proc_names();
+  for (unsigned int i = 0; i < procs.size(); ++i)
+    std::cout << procs[i] << std::endl;
+#endif
+
+  init_jd(jd, gcp_qa_copy);
+  jd->eaa.nargs = 2;
+  jd->eaa.arg[0].ea_addr = ptr_to_ea(&short_buf[nshorts]);
+  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
+  jd->eaa.arg[0].put_size = nshorts * sizeof(short);
+  
+  jd->eaa.arg[1].ea_addr = ptr_to_ea(&short_buf[0]);
+  jd->eaa.arg[1].direction = GCJD_DMA_GET;
+  jd->eaa.arg[1].get_size = nshorts * sizeof(short);
+  
+
+  if (!mgr->submit_job(jd)){
+    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+    CPPUNIT_ASSERT_EQUAL(0, jd->output.arg[0].s32);
+
+    bool ok = true;
+    for (int i = 0; i < nshorts; i++){
+      if (short_buf[i] != short_buf[i + nshorts])
+       ok = false;
+    }
+    CPPUNIT_ASSERT(ok);
+  }
+  mgr->free_job_desc(jd);
+}
+
+/*
+ * Parallel submission of NJOBS "put" jobs will test double buffered puts.
+ */
+void
+qa_job_manager::t14_body()
+{
+  //return;
+
+  //static const int NJOBS = 64;
+  static const int NJOBS = 128;
+  static const int LEN_PER_JOB = 1021;
+  unsigned char    buf[NJOBS * LEN_PER_JOB];
+  gc_job_desc_t          *jd[NJOBS];
+  bool            done[NJOBS];
+
+  static const int STARTING_VAL = 13;
+
+  memset(buf, 0xff, LEN_PER_JOB * NJOBS);
+
+  gc_job_manager_sptr mgr;
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  mgr = gc_make_job_manager(&opts);
+
+
+  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
+
+  // do all the initialization up front
+
+  for (int i = 0, val = STARTING_VAL; i < NJOBS; i++, val += 3){
+    jd[i] = mgr->alloc_job_desc();
+    init_jd(jd[i], gcp_qa_put_seq);
+    jd[i]->input.nargs = 1;
+    jd[i]->input.arg[0].s32 = val;
+    jd[i]->eaa.nargs = 1;
+    jd[i]->eaa.arg[0].ea_addr = ptr_to_ea(&buf[i * LEN_PER_JOB]);
+    jd[i]->eaa.arg[0].direction = GCJD_DMA_PUT;
+    jd[i]->eaa.arg[0].put_size = LEN_PER_JOB;
+  }
+
+  // submit them all
+
+  for (int i = 0; i < NJOBS; i++){
+    if (!mgr->submit_job(jd[i])){
+      printf("%d: submit_job(jd[%2d]) failed, status = %d\n", __LINE__, i, jd[i]->status);
+    }
+  }
+
+  // wait for them all
+
+  int n = mgr->wait_jobs(NJOBS, jd, done, GC_WAIT_ALL);
+  CPPUNIT_ASSERT_EQUAL(NJOBS, n);
+
+  // check results
+
+  for (int i = 0, val = STARTING_VAL; i < NJOBS; i++, val += 3){
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd[i]->status);
+    CPPUNIT_ASSERT(confirm_seq(&buf[i * LEN_PER_JOB], LEN_PER_JOB, val));
+  }
+  
+  // cleanup
+  for (int i = 0; i < NJOBS; i++)
+    mgr->free_job_desc(jd[i]);
+}
+
+void
+qa_job_manager::t15_body()
+{
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa_spx);
+  opts.nspes = 1;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+  gc_job_manager::set_singleton(mgr);
+
+  CPPUNIT_ASSERT(gc_job_manager::singleton());
+  mgr.reset();
+  CPPUNIT_ASSERT_THROW(gc_job_manager::singleton(), boost::bad_weak_ptr);
+}
diff --git a/gcell/lib/runtime/qa_job_manager.h b/gcell/lib/runtime/qa_job_manager.h
new file mode 100644 (file)
index 0000000..ab3325b
--- /dev/null
@@ -0,0 +1,89 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_QA_JOB_MANAGER_H
+#define INCLUDED_QA_JOB_MANAGER_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_job_manager;
+typedef void (qa_job_manager::*test_t)();
+
+
+class qa_job_manager : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_job_manager);
+  CPPUNIT_TEST(t0);
+  CPPUNIT_TEST(t1);
+  CPPUNIT_TEST(t2);
+  CPPUNIT_TEST(t3);
+  CPPUNIT_TEST(t4);
+  CPPUNIT_TEST(t5);
+  CPPUNIT_TEST(t6);
+  CPPUNIT_TEST(t7);
+  CPPUNIT_TEST(t8);
+  CPPUNIT_TEST(t9);
+  CPPUNIT_TEST(t10);
+  CPPUNIT_TEST(t11);
+  CPPUNIT_TEST(t12);
+  CPPUNIT_TEST(t13);
+  CPPUNIT_TEST(t14);
+  CPPUNIT_TEST(t15);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void leak_check(test_t t, const std::string &name);
+
+  void t0();
+  void t1();
+  void t1_body();
+  void t2();
+  void t2_body();
+  void t3();
+  void t3_body();
+  void t4();
+  void t4_body();
+  void t5();
+  void t5_body();
+  void t6();
+  void t6_body();
+  void t7();
+  void t7_body();
+  void t8();
+  void t8_body();
+  void t9();
+  void t9_body();
+  void t10();
+  void t10_body();
+  void t11();
+  void t11_body();
+  void t12();
+  void t12_body();
+  void t13();
+  void t13_body();
+  void t14();
+  void t14_body();
+  void t15();
+  void t15_body();
+
+};
+
+#endif /* INCLUDED_QA_JOB_MANAGER_H */
diff --git a/gcell/lib/runtime/spu/gc_delay.c b/gcell/lib/runtime/spu/gc_delay.c
new file mode 100644 (file)
index 0000000..4d58935
--- /dev/null
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/spu/gc_delay.h>
+#include <gcell/compiler.h>
+
+inline static void
+gc_udelay_1us(void)
+{
+  unsigned int i = 158;
+
+  do {  // 20 clocks per iteration of the loop
+    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
+    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
+    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
+    asm ("nop $127; nop $127");
+  } while(--i != 0);
+}
+
+void
+gc_udelay(unsigned int usecs)
+{
+  unsigned int i;
+  for (i = 0; i < usecs; i++)
+    gc_udelay_1us();
+}
+
+void
+gc_cdelay(unsigned int cpu_cycles)
+{
+  if (cpu_cycles < 40) // roughly the amount of overhead
+    return;
+  
+  cpu_cycles >>= 2;    // about 4 cycles / loop
+
+  while (cpu_cycles-- != 0){
+    asm ("nop $127");  // keeps compiler from removing the loop
+  }
+}
+
diff --git a/gcell/lib/runtime/spu/gc_logging.c b/gcell/lib/runtime/spu/gc_logging.c
new file mode 100644 (file)
index 0000000..48b7e5f
--- /dev/null
@@ -0,0 +1,77 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_logging.h>
+#include <gcell/gc_spu_args.h>
+#include <spu_intrinsics.h>
+#include <spu_mfcio.h>
+
+static gc_eaddr_t     log_base_ea;     // base address of log entries in EA
+static uint32_t              log_idx_mask;     // nentries - 1
+static uint32_t              log_idx;          // current log entry index
+static uint32_t              log_seqno;
+
+static int           log_tags;         // two consecutive tags
+static int           tmp_buffer_busy;  // bitmask: buffer busy state
+static int           tmp_buffer_idx;   // 0 or 1
+static gc_log_entry_t tmp_buffer[2];
+
+void
+_gc_log_init(gc_log_t info)
+{
+  spu_write_decrementer(~0);
+
+  log_base_ea = info.base;
+  log_idx_mask = info.nentries - 1;
+  log_idx = 0;
+  log_seqno = 0;
+
+  log_tags = mfc_multi_tag_reserve(2);
+  tmp_buffer_busy = 0;
+  tmp_buffer_idx = 0;
+
+  gc_log_write0(GCL_SS_SYS, 0);
+}
+
+void
+_gc_log_write(gc_log_entry_t entry)
+{
+  if (log_base_ea == 0)
+    return;
+
+  entry.seqno = log_seqno++;
+  entry.timestamp = spu_read_decrementer();
+
+  if (tmp_buffer_busy & (1 << tmp_buffer_idx)){
+    mfc_write_tag_mask(1 << (log_tags + tmp_buffer_idx));
+    mfc_read_tag_status_all();
+  }
+
+  tmp_buffer[tmp_buffer_idx] = entry;  // save local copy
+
+  mfc_put(&tmp_buffer[tmp_buffer_idx],
+         log_base_ea + log_idx * sizeof(entry), sizeof(entry),
+         log_tags + tmp_buffer_idx, 0, 0);
+
+  tmp_buffer_busy |= (1 << tmp_buffer_idx);
+  tmp_buffer_idx ^= 0x1;
+  log_idx = (log_idx + 1) & log_idx_mask;
+}
diff --git a/gcell/lib/runtime/spu/gc_main.c b/gcell/lib/runtime/spu/gc_main.c
new file mode 100644 (file)
index 0000000..0866c3c
--- /dev/null
@@ -0,0 +1,708 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+// #define ENABLE_GC_LOGGING   // define to enable logging
+
+#include <spu_intrinsics.h>
+#include <spu_mfcio.h>
+#include <sync_utils.h>
+#include "gc_spu_config.h"
+#include "spu_buffers.h"
+#include <gcell/gc_spu_args.h>
+#include <gcell/gc_job_desc.h>
+#include <gcell/gc_mbox.h>
+#include <gcell/gc_declare_proc.h>
+#include <gcell/spu/gc_jd_queue.h>
+#include <gcell/spu/gc_random.h>
+#include <gcell/spu/gc_delay.h>
+
+#include <string.h>
+#include <assert.h>
+#include <stdio.h>
+
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+//! round x down to p2 boundary (p2 must be a power-of-2)
+#define ROUND_DN(x, p2) ((x) & ~((p2)-1))
+
+//! round x up to p2 boundary (p2 must be a power-of-2)
+#define ROUND_UP(x, p2) (((x)+((p2)-1)) & ~((p2)-1))
+
+
+#define USE_LLR_LOST_EVENT     0       // define to 0 or 1
+
+int                    gc_sys_tag;     // tag for misc DMA operations
+static gc_spu_args_t   spu_args;
+
+static struct gc_proc_def *gc_proc_def;        // procedure entry points
+
+// ------------------------------------------------------------------------
+
+// state for DMA'ing arguments in and out
+
+static int get_tag;            // 1 tag for job arg gets
+static int put_tags;           // 2 tags for job arg puts
+
+static int pb_idx = 0;         // current put buffer index (0 or 1)
+
+// bitmask (bit per put buffer): bit is set if DMA is started but not complete
+static int put_in_progress = 0;
+#define PBI_MASK(_pbi_) (1 << (_pbi_))
+
+// ------------------------------------------------------------------------
+
+// our working copy of the completion info
+static gc_comp_info_t  comp_info = {  
+  .in_use = 1,
+  .ncomplete = 0
+};
+
+static int ci_idx = 0;         // index of current comp_info
+static int ci_tags;            // two consecutive dma tags
+
+// ------------------------------------------------------------------------
+
+/*
+ * Wait until EA copy of comp_info[idx].in_use is 0
+ */
+static void
+wait_for_ppe_to_be_done_with_comp_info(int idx)
+{
+  char _tmp[256];
+  char *buf = (char *) ALIGN(_tmp, 128);       // get cache-aligned buffer
+  gc_comp_info_t *p = (gc_comp_info_t *) buf;
+
+  assert(sizeof(gc_comp_info_t) == 128);
+
+  do {
+    mfc_get(buf, spu_args.comp_info[idx], 128, gc_sys_tag, 0, 0);
+    mfc_write_tag_mask(1 << gc_sys_tag);
+    mfc_read_tag_status_all();
+    if (p->in_use == 0)
+      return;
+
+    gc_udelay(5);
+
+  } while (1);
+}
+
+static void
+flush_completion_info(void)
+{
+  // events: 0x3X
+
+  static int total_complete = 0;
+
+  if (comp_info.ncomplete == 0)
+    return;
+  
+  // ensure that PPE is done with the buffer we're about to overwrite
+  wait_for_ppe_to_be_done_with_comp_info(ci_idx);
+
+  // dma the comp_info out to PPE
+  int tag = ci_tags + ci_idx;
+  mfc_put(&comp_info, spu_args.comp_info[ci_idx], sizeof(gc_comp_info_t), tag, 0, 0);
+
+  // we need to wait for the completion info to finish, as well as
+  // any EA argument puts.
+
+  int tag_mask = 1 << tag;             // the comp_info tag
+  if (put_in_progress & PBI_MASK(0))
+    tag_mask |= (1 << (put_tags + 0));
+  if (put_in_progress & PBI_MASK(1))
+    tag_mask |= (1 << (put_tags + 1));
+
+  gc_log_write2(GCL_SS_SYS, 0x30, put_in_progress, tag_mask);
+
+  mfc_write_tag_mask(tag_mask);                // the tags we're interested in
+  mfc_read_tag_status_all();           // wait for DMA to complete
+  put_in_progress = 0;                 // mark them all complete
+
+  total_complete += comp_info.ncomplete;
+  gc_log_write4(GCL_SS_SYS, 0x31,
+               put_in_progress, ci_idx, comp_info.ncomplete, total_complete);
+
+  // send PPE a message
+  spu_writech(SPU_WrOutIntrMbox, MK_MBOX_MSG(OP_JOBS_DONE, ci_idx));
+
+  ci_idx ^= 0x1;       // switch buffers
+  comp_info.in_use = 1;
+  comp_info.ncomplete = 0;
+}
+
+// ------------------------------------------------------------------------
+
+static unsigned int backoff;           // current backoff value in clock cycles
+static unsigned int _backoff_start;
+static unsigned int _backoff_cap;
+
+/*
+ * For 3.2 GHz SPE
+ *
+ * 12    4095 cycles    1.3 us
+ * 13    8191 cycles    2.6 us
+ * 14   16383 cycles    5.1 us
+ * 15   32767 cycles   10.2 us
+ * 16                  20.4 us
+ * 17                  40.8 us
+ * 18                  81.9 us
+ * 19                 163.8 us
+ * 20                 327.7 us
+ * 21                 655.4 us
+ */
+static unsigned char log2_backoff_start[16] = {
+// 1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
+// -------------------------------------------------------------
+  12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16
+};
+  
+static unsigned char log2_backoff_cap[16] = {
+// 1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
+// -------------------------------------------------------------
+  17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 21, 21
+};
+  
+static void
+backoff_init(void)
+{
+  _backoff_cap   = (1 << (log2_backoff_cap[(spu_args.nspus - 1) & 0xf])) - 1;
+  _backoff_start = (1 << (log2_backoff_start[(spu_args.nspus - 1) & 0xf])) - 1;
+  
+  backoff = _backoff_start;
+}
+
+static void 
+backoff_reset(void)
+{
+  backoff = _backoff_start;
+}
+
+#if 0
+
+static void
+backoff_delay(void)
+{
+  gc_cdelay(backoff);
+
+  // capped exponential backoff
+  backoff = ((backoff << 1) + 1) & _backoff_cap;
+}
+
+#else
+
+#define RANDOM_WEIGHT  0.2
+
+static void
+backoff_delay(void)
+{
+  gc_cdelay(backoff);
+
+  backoff = ((backoff << 1) + 1);
+  if (backoff > _backoff_cap)
+    backoff = _backoff_cap;
+
+  float r = (RANDOM_WEIGHT * (2.0 * (gc_uniform_deviate() - 0.5)));
+  backoff = backoff * (1.0 + r);
+}
+
+#endif
+
+// ------------------------------------------------------------------------
+
+static inline unsigned int
+make_mask(int nbits)
+{
+  return ~(~0 << nbits);
+}
+
+static unsigned int   dc_work;
+static int            dc_put_tag;
+static unsigned char *dc_ls_base;
+static gc_eaddr_t     dc_ea_base;
+
+// divide and conquer
+static void
+d_and_c(unsigned int offset, unsigned int len)
+{
+  unsigned int mask = make_mask(len) << offset;
+  unsigned int t = mask & dc_work;
+  if (t == 0)          // nothing to do
+    return;
+  if (t == mask){      // got a match, generate dma
+    mfc_put(dc_ls_base + offset, dc_ea_base + offset, len, dc_put_tag, 0, 0);
+  }
+  else {               // bisect
+    len >>= 1;
+    d_and_c(offset, len);
+    d_and_c(offset + len, len);
+  }
+}
+
+// Handle the nasty case of a dma xfer that's less than 16 bytes long.
+// len is guaranteed to be in [1, 15]
+
+static void
+handle_slow_and_tedious_dma(gc_eaddr_t ea, unsigned char *ls,
+                           unsigned int len, int put_tag)
+{
+  // Set up for divide and conquer
+  unsigned int alignment = ((uintptr_t) ls) & 0x7;
+  dc_work = make_mask(len) << alignment;
+  dc_ls_base = (unsigned char *) ROUND_DN((uintptr_t) ls, 8);
+  dc_ea_base = ROUND_DN(ea, (gc_eaddr_t) 8);
+  dc_put_tag = put_tag;
+
+  d_and_c( 0, 8);
+  d_and_c( 8, 8);
+  d_and_c(16, 8);
+}
+
+
+static void
+process_job(gc_eaddr_t jd_ea, gc_job_desc_t *jd)
+{
+  // events: 0x2X
+
+  jd->status = JS_OK;  // assume success
+
+  if (jd->proc_id >= spu_args.nproc_defs)
+    jd->status = JS_UNKNOWN_PROC;
+    
+  else {
+  
+    if (jd->eaa.nargs == 0)
+      (*gc_proc_def[jd->proc_id].proc)(&jd->input, &jd->output, &jd->eaa);
+
+    else {     // handle EA args that must be DMA'd in/out
+
+      gc_job_ea_args_t *eaa = &jd->eaa;
+
+      int NELMS =
+       MAX(MAX_ARGS_EA,
+           (GC_SPU_BUFSIZE + MFC_MAX_DMA_SIZE - 1) / MFC_MAX_DMA_SIZE);
+
+      mfc_list_element_t  dma_get_list[NELMS];
+      //mfc_list_element_t  dma_put_list[NELMS];
+      
+      memset(dma_get_list, 0, sizeof(dma_get_list));
+      //memset(dma_put_list, 0, sizeof(dma_put_list));
+
+      int gli = 0;     // get list index
+      //int pli = 0;   // put list index
+
+      unsigned char *get_base = _gci_getbuf[0];
+      unsigned char *get_t = get_base;
+      unsigned int   total_get_dma_len = 0;
+
+      unsigned char *put_base = _gci_putbuf[pb_idx];
+      unsigned char *put_t = put_base;
+      unsigned int   total_put_alloc = 0;
+      int           put_tag = put_tags + pb_idx;
+
+      // Do we have any "put" args?  If so ensure that previous
+      // dma from this buffer is complete
+
+      gc_log_write2(GCL_SS_SYS, 0x24, put_in_progress, jd->sys.direction_union);
+
+      if ((jd->sys.direction_union & GCJD_DMA_PUT)
+         && (put_in_progress & PBI_MASK(pb_idx))){
+
+       gc_log_write2(GCL_SS_SYS, 0x25, put_in_progress, 1 << put_tag);
+
+       mfc_write_tag_mask(1 << put_tag);       // the tag we're interested in
+       mfc_read_tag_status_all();              // wait for DMA to complete
+       put_in_progress &= ~(PBI_MASK(pb_idx));
+
+       gc_log_write1(GCL_SS_SYS, 0x26, put_in_progress);
+      }
+
+
+      // for now, all EA's must have the same high 32-bits
+      gc_eaddr_t common_ea = eaa->arg[0].ea_addr;
+
+
+      // assign LS addresses for buffers
+      
+      for (unsigned int i = 0; i < eaa->nargs; i++){
+
+       gc_eaddr_t      ea_base = 0;
+       unsigned char  *ls_base;
+       int             offset;
+       unsigned int    dma_len;
+
+       if (eaa->arg[i].direction == GCJD_DMA_GET){
+         ea_base = ROUND_DN(eaa->arg[i].ea_addr, (gc_eaddr_t) CACHE_LINE_SIZE);
+         offset = eaa->arg[i].ea_addr & (CACHE_LINE_SIZE-1);
+         dma_len = ROUND_UP(eaa->arg[i].get_size + offset, CACHE_LINE_SIZE);
+         total_get_dma_len += dma_len;
+
+         if (total_get_dma_len > GC_SPU_BUFSIZE){
+           jd->status = JS_ARGS_TOO_LONG;
+           goto wrap_up;
+         }
+
+         ls_base = get_t;
+         get_t += dma_len;
+         eaa->arg[i].ls_addr = ls_base + offset;
+
+         if (0){
+           assert((mfc_ea2l(eaa->arg[i].ea_addr) & 0x7f) == ((intptr_t)eaa->arg[i].ls_addr & 0x7f));
+           assert((ea_base & 0x7f) == 0);
+           assert(((intptr_t)ls_base & 0x7f) == 0);
+           assert((dma_len & 0x7f) == 0);
+           assert((eaa->arg[i].get_size <= dma_len)
+                  && dma_len <= (eaa->arg[i].get_size + offset + CACHE_LINE_SIZE - 1));
+         }
+
+         // add to dma get list 
+         // FIXME (someday) the dma list is where the JS_BAD_EAH limitation comes from
+
+         while (dma_len != 0){
+           int n = MIN(dma_len, MFC_MAX_DMA_SIZE);
+           dma_get_list[gli].size = n;
+           dma_get_list[gli].eal = mfc_ea2l(ea_base);
+           dma_len -= n;
+           ea_base += n;
+           gli++;
+         }
+       }
+
+       else if (eaa->arg[i].direction == GCJD_DMA_PUT){
+         //
+         // This case is a trickier than the PUT case since we can't
+         // write outside of the bounds of the user provided buffer.
+         // We still align the buffers to 128-bytes for good performance
+         // in the middle portion of the xfers.
+         //
+         ea_base = ROUND_DN(eaa->arg[i].ea_addr, (gc_eaddr_t) CACHE_LINE_SIZE);
+         offset = eaa->arg[i].ea_addr & (CACHE_LINE_SIZE-1);
+
+         uint32_t ls_alloc_len =
+           ROUND_UP(eaa->arg[i].put_size + offset, CACHE_LINE_SIZE);
+
+         total_put_alloc += ls_alloc_len;
+
+         if (total_put_alloc > GC_SPU_BUFSIZE){
+           jd->status = JS_ARGS_TOO_LONG;
+           goto wrap_up;
+         }
+
+         ls_base = put_t;
+         put_t += ls_alloc_len;
+         eaa->arg[i].ls_addr = ls_base + offset;
+
+         if (1){
+           assert((mfc_ea2l(eaa->arg[i].ea_addr) & 0x7f)
+                  == ((intptr_t)eaa->arg[i].ls_addr & 0x7f));
+           assert((ea_base & 0x7f) == 0);
+           assert(((intptr_t)ls_base & 0x7f) == 0);
+         }
+       }
+
+       else
+         assert(0);
+      }
+
+      // fire off the dma to fetch the args and wait for it to complete
+      mfc_getl(get_base, common_ea, dma_get_list, gli*sizeof(dma_get_list[0]), get_tag, 0, 0);
+      mfc_write_tag_mask(1 << get_tag);                // the tag we're interested in
+      mfc_read_tag_status_all();               // wait for DMA to complete
+
+      // do the work
+      (*gc_proc_def[jd->proc_id].proc)(&jd->input, &jd->output, &jd->eaa);
+
+
+      // Do we have any "put" args?  If so copy them out
+      if (jd->sys.direction_union & GCJD_DMA_PUT){
+
+       // Do the copy out using single DMA xfers.  The LS ranges
+       // aren't generally contiguous.
+       
+       bool started_dma = false;
+
+       for (unsigned int i = 0; i < eaa->nargs; i++){
+         if (eaa->arg[i].direction == GCJD_DMA_PUT && eaa->arg[i].put_size != 0){
+           
+           started_dma = true;
+
+           gc_eaddr_t       ea;
+           unsigned char   *ls;
+           unsigned int     len;
+
+           ea = eaa->arg[i].ea_addr;
+           ls = (unsigned char *) eaa->arg[i].ls_addr;
+           len = eaa->arg[i].put_size;
+
+           if (len < 16)
+             handle_slow_and_tedious_dma(ea, ls, len, put_tag);
+           
+           else {
+             if ((ea & 0xf) != 0){
+
+               // printf("1:  ea = 0x%x  len = %5d\n", (int) ea, len);
+               
+               // handle the "pre-multiple-of-16" portion
+               // do 1, 2, 4, or 8 byte xfers as required
+
+               if (ea & 0x1){                          // do a 1-byte xfer
+                 mfc_put(ls, ea, 1, put_tag, 0, 0);
+                 ea += 1;
+                 ls += 1;
+                 len -= 1;
+               }
+               if (ea & 0x2){                          // do a 2-byte xfer
+                 mfc_put(ls, ea, 2, put_tag, 0, 0);
+                 ea += 2;
+                 ls += 2;
+                 len -= 2;
+               }
+               if (ea & 0x4){                          // do a 4-byte xfer
+                 mfc_put(ls, ea, 4, put_tag, 0, 0);
+                 ea += 4;
+                 ls += 4;
+                 len -= 4;
+               }
+               if (ea & 0x8){                          // do an 8-byte xfer
+                 mfc_put(ls, ea, 8, put_tag, 0, 0);
+                 ea += 8;
+                 ls += 8;
+                 len -= 8;
+               }
+             }
+
+             if (1){
+               // printf("2:  ea = 0x%x  len = %5d\n", (int) ea, len);
+               assert((ea & 0xf) == 0);
+               assert((((intptr_t) ls) & 0xf) == 0);
+             }
+
+             // handle the "multiple-of-16" portion
+
+             int aligned_len = ROUND_DN(len, 16);
+             len = len & (16 - 1);
+
+             while (aligned_len != 0){
+               int dma_len = MIN(aligned_len, MFC_MAX_DMA_SIZE);
+               mfc_put(ls, ea, dma_len, put_tag, 0, 0);
+               ea += dma_len;
+               ls += dma_len;
+               aligned_len -= dma_len;
+             }
+
+             if (1){
+               // printf("3:  ea = 0x%x  len = %5d\n", (int)ea, len);
+               assert((ea & 0xf) == 0);
+               assert((((intptr_t) ls) & 0xf) == 0);
+             }
+
+             // handle "post-multiple-of-16" portion
+
+             if (len != 0){
+
+               if (len >= 8){                          // do an 8-byte xfer
+                 mfc_put(ls, ea, 8, put_tag, 0, 0);
+                 ea += 8;
+                 ls += 8;
+                 len -= 8;
+               }
+               if (len >= 4){                          // do a 4-byte xfer
+                 mfc_put(ls, ea, 4, put_tag, 0, 0);
+                 ea += 4;
+                 ls += 4;
+                 len -= 4;
+               }
+               if (len >= 2){                          // do a 2-byte xfer
+                 mfc_put(ls, ea, 2, put_tag, 0, 0);
+                 ea += 2;
+                 ls += 2;
+                 len -= 2;
+               }
+               if (len >= 1){                          // do a 1-byte xfer
+                 mfc_put(ls, ea, 1, put_tag, 0, 0);
+                 ea += 1;
+                 ls += 1;
+                 len -= 1;
+               }
+               if (1)
+                 assert(len == 0);
+             }
+           }
+         }
+       }
+       if (started_dma){
+         put_in_progress |= PBI_MASK(pb_idx);          // note it's running
+         gc_log_write2(GCL_SS_SYS, 0x27, put_in_progress, pb_idx);
+         pb_idx ^= 1;                                  // toggle current buffer
+       }
+      }
+    }
+  }
+
+ wrap_up:;     // semicolon creates null statement for C99 compliance
+
+  // Copy job descriptor back out to EA.
+  // (The dma will be waited on in flush_completion_info)
+  int tag = ci_tags + ci_idx;                  // use the current completion tag
+  mfc_put(jd, jd_ea, sizeof(*jd), tag, 0, 0);
+
+  // Tell PPE we're done with the job.
+  //
+  // We queue these up until we run out of room, or until we can send
+  // the info to the PPE w/o blocking.  The blocking check is in
+  // main_loop
+
+  comp_info.job_id[comp_info.ncomplete++] = jd->sys.job_id;
+
+  if (comp_info.ncomplete == GC_CI_NJOBS){
+    gc_log_write0(GCL_SS_SYS, 0x28);
+    flush_completion_info();
+  }
+}
+
+static void
+main_loop(void)
+{
+  // events: 0x1X
+
+  static gc_job_desc_t jd;     // static gets us proper alignment
+  gc_eaddr_t           jd_ea;
+  int                  total_jobs = 0;
+
+#if (USE_LLR_LOST_EVENT)
+  // setup events
+  spu_writech(SPU_WrEventMask, MFC_LLR_LOST_EVENT);
+
+  // prime the pump
+  while (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, ci_tags + ci_idx, &jd))
+    process_job(jd_ea, &jd);
+  // we're now holding a lock-line reservation
+#endif
+
+  while (1){
+
+#if (USE_LLR_LOST_EVENT)
+
+    if (unlikely(spu_readchcnt(SPU_RdEventStat))){
+      //
+      // execute standard event handling prologue
+      //
+      int status = spu_readch(SPU_RdEventStat);
+      int mask = spu_readch(SPU_RdEventMask);
+      spu_writech(SPU_WrEventMask, mask & ~status);    // disable active events
+      spu_writech(SPU_WrEventAck, status);             // ack active events
+
+      // execute per-event actions
+
+      if (status & MFC_LLR_LOST_EVENT){
+       //
+       // We've lost a line reservation.  This is most likely caused
+       // by somebody doing something to the queue.  Go look and see
+       // if there's anything for us.
+       //
+       while (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, ci_tags + ci_idx, &jd))
+         process_job(jd_ea, &jd);
+      }
+
+      //
+      // execute standard event handling epilogue
+      //
+      spu_writech(SPU_WrEventMask, mask);      // restore event mask
+    }
+
+#else
+
+    // try to get a job from the job queue 
+    if (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, ci_tags + ci_idx, &jd)){
+      total_jobs++;
+      gc_log_write2(GCL_SS_SYS, 0x10, jd.sys.job_id, total_jobs);
+
+      process_job(jd_ea, &jd); 
+
+      gc_log_write2(GCL_SS_SYS, 0x11, jd.sys.job_id, total_jobs);
+      backoff_reset(); 
+    }
+    else
+      backoff_delay();
+
+#endif
+
+    // any msgs for us?
+
+    if (unlikely(spu_readchcnt(SPU_RdInMbox))){
+      int msg = spu_readch(SPU_RdInMbox);
+      // printf("spu[%d] mbox_msg: 0x%08x\n", spu_args.spu_idx, msg);
+      if (MBOX_MSG_OP(msg) == OP_EXIT){
+       flush_completion_info();
+       return;
+      }
+      if (MBOX_MSG_OP(msg) == OP_GET_SPU_BUFSIZE){
+       spu_writech(SPU_WrOutIntrMbox, MK_MBOX_MSG(OP_SPU_BUFSIZE, GC_SPU_BUFSIZE_BASE));
+      }
+    }
+
+    // If we've got job completion info for the PPE and we can send a
+    // message without blocking, do it.
+
+    if (comp_info.ncomplete != 0 && spu_readchcnt(SPU_WrOutIntrMbox) != 0){
+      gc_log_write0(GCL_SS_SYS, 0x12);
+      flush_completion_info();
+    }
+  }
+}
+
+
+int
+main(unsigned long long spe_id __attribute__((unused)),
+     unsigned long long argp,
+     unsigned long long envp __attribute__((unused)))
+{
+  gc_sys_tag = mfc_tag_reserve();      // allocate a tag for our misc DMA operations
+  get_tag  = mfc_tag_reserve();
+  ci_tags  = mfc_multi_tag_reserve(2);
+  put_tags = mfc_multi_tag_reserve(2);
+
+#if 0  
+  printf("gc_sys_tag = %d\n", gc_sys_tag);
+  printf("get_tag    = %d\n", get_tag);
+  printf("ci_tags    = %d\n", ci_tags);
+  printf("put_tags   = %d\n", put_tags);
+#endif
+
+  // dma the args in
+  mfc_get(&spu_args, argp, sizeof(spu_args), gc_sys_tag, 0, 0);
+  mfc_write_tag_mask(1 << gc_sys_tag); // the tag we're interested in
+  mfc_read_tag_status_all();           // wait for DMA to complete
+
+  // initialize pointer to procedure entry table
+  gc_proc_def = (gc_proc_def_t *) spu_args.proc_def_ls_addr;
+
+  gc_set_seed(spu_args.spu_idx);
+
+  // initialize logging
+  _gc_log_init(spu_args.log);
+
+  backoff_init();              // initialize backoff parameters
+
+  main_loop();
+  return 0;
+}
diff --git a/gcell/lib/runtime/spu/gc_random.c b/gcell/lib/runtime/spu/gc_random.c
new file mode 100644 (file)
index 0000000..214309b
--- /dev/null
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <gcell/spu/gc_random.h>
+
+static int last_val = 0;
+
+#define        M  714025       // values from Numerical Recipes in C, 1988
+#define A    4096
+#define C  150889
+
+void 
+gc_set_seed(int seed)
+{
+  last_val = ((unsigned int) seed) % M;
+}
+
+float
+gc_uniform_deviate(void)
+{
+  last_val = (last_val * A + C) % M;
+  return (float) last_val / (float) M;
+}
diff --git a/gcell/lib/runtime/spu/gc_spu_config.h b/gcell/lib/runtime/spu/gc_spu_config.h
new file mode 100644 (file)
index 0000000..d0b131e
--- /dev/null
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GCELL_GC_SPU_CONFIG_H
+#define INCLUDED_GCELL_GC_SPU_CONFIG_H
+
+#include <gcell/gc_job_desc.h>
+
+#define CACHE_LINE_SIZE             128              // in bytes
+#define        GC_SPU_BUFSIZE_BASE  (40 * 1024)      //  must be multiple of CACHE_LINE_SIZE
+#define        GC_SPU_BUFSIZE (GC_SPU_BUFSIZE_BASE + MAX_ARGS_EA * CACHE_LINE_SIZE)
+
+#define NGETBUFS       1       // single buffer job arg gets
+#define        NPUTBUFS        2       // double buffer job arg puts
+
+#endif /* INCLUDED_GCELL_GC_SPU_CONFIG_H */
diff --git a/gcell/lib/runtime/spu/gc_spu_jd_queue.c b/gcell/lib/runtime/spu/gc_spu_jd_queue.c
new file mode 100644 (file)
index 0000000..42deac3
--- /dev/null
@@ -0,0 +1,112 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/spu/gc_jd_queue.h>
+#include <gcell/spu/gc_delay.h>
+#include <gcell/spu/gc_random.h>
+#include "mutex_lock.h"
+#include "mutex_unlock.h"
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+extern int gc_sys_tag;
+
+#define        INITIAL_BACKOFF    32.0
+#define MAX_BACKOFF    16384.0
+#define        RANDOM_WEIGHT       0.2
+
+static float
+next_backoff(float backoff)
+{
+  // exponential with random
+  float t = backoff * 2.0;
+  if (t > MAX_BACKOFF)
+    t = MAX_BACKOFF;
+
+  float r = (RANDOM_WEIGHT * (2.0 * (gc_uniform_deviate() - 0.5)));
+  t = t * (1.0 + r);
+
+  return t;
+}
+
+bool
+gc_jd_queue_dequeue(gc_eaddr_t q, gc_eaddr_t *item_ea,
+                   int jd_tag, gc_job_desc_t *item)
+{
+  int  status;
+  char         _tmp[256];
+  gc_jd_queue_t *local_q =
+    (gc_jd_queue_t *) ALIGN(_tmp, 128);                // get cache-aligned buffer
+  
+  float backoff = next_backoff(INITIAL_BACKOFF);
+
+  do {
+    // Copy the queue structure in and get a lock line reservation.
+    // (The structure is 128-byte aligned and completely fills a cache-line)
+
+    mfc_getllar(local_q, q, 0, 0);
+    spu_readch(MFC_RdAtomicStat);
+
+    if (local_q->mutex != 0)           // somebody else has it locked
+      return false;
+
+    if (local_q->head == 0)            // the queue is empty
+      return false;
+
+    // Try to acquire the lock
+
+    local_q->mutex = 1;
+    mfc_putllc(local_q, q, 0, 0);
+    status = spu_readch(MFC_RdAtomicStat);
+
+    if (status != 0){
+      gc_cdelay((int) backoff);
+      backoff = next_backoff(backoff);
+    }
+
+  } while (status != 0);
+
+  // we're now holding the lock
+    
+  // copy in job descriptor at head of queue
+  *item_ea = local_q->head;
+  
+  // We must use the fence with the jd_tag to ensure that any
+  // previously initiated put of a job desc is locally ordered before
+  // the get of the new one.
+  mfc_getf(item, local_q->head, sizeof(gc_job_desc_t), jd_tag, 0, 0);
+  mfc_write_tag_mask(1 << jd_tag);     // the tag we're interested in
+  mfc_read_tag_status_all();           // wait for DMA to complete
+
+  local_q->head = item->sys.next;
+  item->sys.next = 0;
+  if (local_q->head == 0)              // now empty?
+    local_q->tail = 0;
+
+  // Copy the queue struct back out and unlock the mutex in one fell swoop.
+  // We use the unconditional put since it's faster and we own the lock.
+
+  local_q->mutex = 0;
+  mfc_putlluc(local_q, q, 0, 0);
+  spu_readch(MFC_RdAtomicStat);
+
+  return true;
+}
diff --git a/gcell/lib/runtime/spu/gcell_runtime_qa.c b/gcell/lib/runtime/spu/gcell_runtime_qa.c
new file mode 100644 (file)
index 0000000..47a4b5b
--- /dev/null
@@ -0,0 +1,105 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_declare_proc.h>
+#include <gcell/spu/gc_delay.h>
+#include <string.h>
+
+
+static void
+qa_nop(const gc_job_direct_args_t *input _UNUSED,
+       gc_job_direct_args_t *output _UNUSED,
+       const gc_job_ea_args_t *eaa _UNUSED)
+{
+}
+
+GC_DECLARE_PROC(qa_nop, "qa_nop");
+
+static int
+sum_shorts(short *p, int nshorts)
+{
+  int total = 0;
+  for (int i = 0; i < nshorts; i++)
+    total += p[i];
+
+  return total;
+}
+
+static void
+qa_sum_shorts(const gc_job_direct_args_t *input _UNUSED,
+             gc_job_direct_args_t *output,
+             const gc_job_ea_args_t *eaa)
+{
+  for (unsigned int i = 0; i < eaa->nargs; i++){
+    short *p = eaa->arg[i].ls_addr;
+    int n = eaa->arg[i].get_size / sizeof(short);
+    output->arg[i].s32 = sum_shorts(p, n);
+    //printf("qa_sum_shorts(%p, %d) = %d\n",  p, n, output->arg[i].s32);
+  }
+}
+
+GC_DECLARE_PROC(qa_sum_shorts, "qa_sum_shorts");
+
+static void
+write_seq(unsigned char *p, int nbytes, int counter)
+{
+  for (int i = 0; i < nbytes; i++)
+    p[i] = counter++;
+}
+
+static void
+qa_put_seq(const gc_job_direct_args_t *input,
+          gc_job_direct_args_t *output _UNUSED,
+          const gc_job_ea_args_t *eaa)
+{
+  int counter = input->arg[0].s32;
+
+  for (unsigned int i = 0; i < eaa->nargs; i++){
+    unsigned char *p = eaa->arg[i].ls_addr;
+    int n = eaa->arg[i].put_size;
+    write_seq(p, n, counter);
+    counter += n;
+  }
+}
+
+GC_DECLARE_PROC(qa_put_seq, "qa_put_seq");
+
+static void
+qa_copy(const gc_job_direct_args_t *input _UNUSED,
+       gc_job_direct_args_t *output,
+       const gc_job_ea_args_t *eaa)
+{
+  if (eaa->nargs != 2
+      || eaa->arg[0].direction != GCJD_DMA_PUT
+      || eaa->arg[1].direction != GCJD_DMA_GET){
+    output->arg[0].s32 = -1;
+    return;
+  }
+
+  output->arg[0].s32 = 0;
+  unsigned n = eaa->arg[0].put_size;
+  if (eaa->arg[1].get_size < n)
+    n = eaa->arg[1].get_size;
+  
+  memcpy(eaa->arg[0].ls_addr, eaa->arg[1].ls_addr, n);
+}
+
+GC_DECLARE_PROC(qa_copy, "qa_copy");
diff --git a/gcell/lib/runtime/spu/spu_buffers.c b/gcell/lib/runtime/spu/spu_buffers.c
new file mode 100644 (file)
index 0000000..29ae99d
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "spu_buffers.h"
+#include <gcell/compiler.h>
+
+static unsigned char _getbuf[NGETBUFS][GC_SPU_BUFSIZE] _AL128;
+static unsigned char _putbuf[NPUTBUFS][GC_SPU_BUFSIZE] _AL128;
+
+unsigned char *_gci_getbuf[NGETBUFS] = {
+  _getbuf[0]
+};
+
+unsigned char *_gci_putbuf[NPUTBUFS] = {
+  _putbuf[0],
+  _putbuf[1]
+};
diff --git a/gcell/lib/runtime/spu/spu_buffers.h b/gcell/lib/runtime/spu/spu_buffers.h
new file mode 100644 (file)
index 0000000..24811dc
--- /dev/null
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_SPU_BUFFERS_H
+#define INCLUDED_SPU_BUFFERS_H
+
+#include "gc_spu_config.h"
+
+//! pointer to input buffer
+extern unsigned char *_gci_getbuf[NGETBUFS];
+
+//! pointers to output buffers
+extern unsigned char *_gci_putbuf[NPUTBUFS];
+
+#endif /* INCLUDED_SPU_BUFFERS_H */
diff --git a/gcell/lib/spu/Makefile.am b/gcell/lib/spu/Makefile.am
new file mode 100644 (file)
index 0000000..5afa40e
--- /dev/null
@@ -0,0 +1,138 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+# We're building a single .a file from files in several
+# subdirectories.  We use the "single Makefile, multiple subdirectory"
+# automake alternative. We're doing this because we're faking out
+# automake and getting it to build for 2 architectures at the same
+# time, the PPE (powerpc64) and the SPE.  The easiest way to handle
+# the SPE was to just build a static library using automake's built in
+# rules, since trying to get libtool to handle two architectures in
+# the same tree seemed untenable.
+
+include $(top_srcdir)/Makefile.common.spu
+
+IBM_SPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/ibm/sync/spu_source
+AM_CPPFLAGS = $(GCELL_SPU_INCLUDES) $(IBM_SPU_SYNC_INCLUDES)
+
+libspu_LIBRARIES = libgcell_spu.a
+
+# ----------------------------------------------------------------
+# files in the lib/runtime/spu directory
+
+runtime_srcdir = $(srcdir)/../runtime/spu
+
+runtime_spu_sources = \
+       $(runtime_srcdir)/gc_delay.c \
+       $(runtime_srcdir)/gc_spu_jd_queue.c \
+       $(runtime_srcdir)/spu_buffers.c \
+       $(runtime_srcdir)/gc_logging.c \
+       $(runtime_srcdir)/gc_main.c \
+       $(runtime_srcdir)/gc_random.c
+
+
+runtime_spu_headers =
+
+runtime_spu_noinst_headers = \
+       $(runtime_srcdir)/gc_spu_config.h \
+       $(runtime_srcdir)/spu_buffers.h 
+
+# ----------------------------------------------------------------
+# files in the lib/general/spu directory
+
+general_srcdir = $(srcdir)/../general/spu
+
+general_spu_sources = \
+       $(general_srcdir)/fft_1d_r2.c \
+       $(general_srcdir)/memset.S
+
+general_spu_headers =
+# These now live in include/gcell/spu
+#general_spu_headers = \
+#      $(general_srcdir)/gc_spu_macs.h \
+#      $(general_srcdir)/libfft.h
+
+general_spu_noinst_headers =
+# As do these
+#general_spu_noinst_headers = \
+#      $(general_srcdir)/fft_1d.h \
+#      $(general_srcdir)/fft_1d_r2.h
+
+# The QA code for (usually) non-PPE visible support routines in lib/general/spu
+general_spu_qa_sources = \
+       $(general_srcdir)/qa_memset.c
+
+# ----------------------------------------------------------------
+# files in the lib/wrapper/spu directory
+
+wrapper_srcdir = $(srcdir)/../wrapper/spu
+
+wrapper_spu_sources = \
+       $(wrapper_srcdir)/gcs_fft_1d_r2.c
+
+wrapper_spu_headers =
+
+wrapper_spu_noinst_headers =
+
+# ----------------------------------------------------------------
+# build the library from the files in the three directories
+
+libgcell_spu_a_SOURCES = \
+       $(runtime_spu_sources) \
+       $(general_spu_sources) \
+       $(wrapper_spu_sources)
+
+gcellspuinclude_HEADERS = \
+       $(runtime_spu_headers) \
+       $(general_spu_headers) \
+       $(wrapper_spu_headers)
+
+noinst_HEADERS = \
+       $(runtime_spu_noinst_headers) \
+       $(general_spu_noinst_headers) \
+       $(wrapper_spu_noinst_headers)
+
+# ----------------------------------------------------------------
+# build some SPU executables
+
+libspu_PROGRAMS = \
+       gcell_all
+
+noinst_PROGRAMS = \
+       gcell_runtime_qa \
+       gcell_general_qa
+
+#
+# All known non-QA gcell procs (at least until they get too big).
+#
+gcell_all_SOURCES = $(wrapper_spu_sources)
+gcell_all_LDADD = libgcell_spu.a
+
+#
+# The QA code required for testing the runtime.
+#
+gcell_runtime_qa_SOURCES = $(runtime_srcdir)/gcell_runtime_qa.c
+gcell_runtime_qa_LDADD = libgcell_spu.a
+
+#
+# The QA code required for testing the SPE support routines in lib/general/spu
+#
+gcell_general_qa_SOURCES = $(general_spu_qa_sources)
+gcell_general_qa_LDADD = libgcell_spu.a
diff --git a/gcell/lib/wrapper/Makefile.am b/gcell/lib/wrapper/Makefile.am
new file mode 100644 (file)
index 0000000..5a8e328
--- /dev/null
@@ -0,0 +1,71 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+AM_CPPFLAGS = $(DEFINES) $(GCELL_INCLUDES) $(FFTW3F_CFLAGS) $(WITH_INCLUDES)
+
+noinst_LTLIBRARIES = libwrapper.la libwrapper-qa.la
+
+#
+# generate libtool.lo's that contain embedded SPU executables
+#
+gcell_all.lo: ../spu/gcell_all
+       $(GCELL_EMBEDSPU_LIBTOOL) $< $@ 
+
+gcell_general_qa.lo: ../spu/gcell_general_qa
+       $(GCELL_EMBEDSPU_LIBTOOL) $< $@
+
+
+
+# The primary library
+
+libwrapper_la_SOURCES = \
+       gcp_fft_1d_r2.cc
+
+libwrapper_la_LIBADD = \
+       gcell_all.lo
+
+
+# The QA library
+
+libwrapper_qa_la_SOURCES = \
+       qa_gcell_general.cc \
+       qa_gcell_wrapper.cc \
+       qa_gcp_fft_1d_r2.cc
+
+libwrapper_qa_la_LIBADD = \
+       gcell_general_qa.lo \
+       -lfftw3f
+
+# Headers
+
+# Moved to include/gcell
+#gcellinclude_HEADERS = \
+#      gcp_fft_1d_r2.h
+
+noinst_HEADERS = \
+       qa_gcell_general.h \
+       qa_gcell_wrapper.h \
+       qa_gcp_fft_1d_r2.h
+
+
+CLEANFILES = gcell_all.lo gcell_general_qa.lo
+
diff --git a/gcell/lib/wrapper/gcp_fft_1d_r2.cc b/gcell/lib/wrapper/gcp_fft_1d_r2.cc
new file mode 100644 (file)
index 0000000..9e7e00f
--- /dev/null
@@ -0,0 +1,119 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gcell/gcp_fft_1d_r2.h>
+#include <stdint.h>
+#include <stdexcept>
+#include <math.h>
+
+static void
+init_jd(gc_job_desc *jd,
+       gc_proc_id_t proc_id,
+       unsigned log2_fft_length,
+       bool shift,
+       std::complex<float> *out,
+       const std::complex<float> *in,
+       const std::complex<float> *twiddle,
+       const float *window)
+{
+  jd->proc_id = proc_id;
+  jd->input.nargs = 2;
+  jd->output.nargs = 0;
+  jd->eaa.nargs = 4;
+
+  jd->input.arg[0].u32 = log2_fft_length;
+  jd->input.arg[1].u32 = shift;
+  unsigned int fft_length = 1 << log2_fft_length;
+
+  jd->eaa.arg[0].ea_addr = ptr_to_ea(out);
+  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
+  jd->eaa.arg[0].put_size = sizeof(std::complex<float>) * fft_length;
+
+  jd->eaa.arg[1].ea_addr = ptr_to_ea(const_cast<std::complex<float>*>(in));
+  jd->eaa.arg[1].direction = GCJD_DMA_GET;
+  jd->eaa.arg[1].get_size = sizeof(std::complex<float>) * fft_length;
+
+  jd->eaa.arg[2].ea_addr = ptr_to_ea(const_cast<std::complex<float>*>(twiddle));
+  jd->eaa.arg[2].direction = GCJD_DMA_GET;
+  jd->eaa.arg[2].get_size = sizeof(std::complex<float>) * fft_length / 4;
+
+  jd->eaa.arg[3].ea_addr = ptr_to_ea(const_cast<float*>(window));
+  jd->eaa.arg[3].direction = GCJD_DMA_GET;
+  if (window == 0)
+    jd->eaa.arg[3].get_size = 0;
+  else
+    jd->eaa.arg[3].get_size = sizeof(float) * fft_length;
+}
+
+  
+gc_job_desc_sptr
+gcp_fft_1d_r2_submit(gc_job_manager_sptr mgr,
+                    unsigned int log2_fft_length,
+                    bool forward,
+                    bool shift,
+                    std::complex<float> *out,
+                    const std::complex<float> *in,
+                    const std::complex<float> *twiddle,
+                    const float *window)
+{
+  unsigned int fft_length = 1 << log2_fft_length;
+  if (fft_length > 4096)
+    throw std::invalid_argument("fft_length > 4096");
+
+  if ((intptr_t)out & 0xf)
+    throw gc_bad_align("out");
+  if ((intptr_t)in & 0xf)
+    throw gc_bad_align("in");
+  if ((intptr_t)twiddle & 0xf)
+    throw gc_bad_align("twiddle");
+  if ((intptr_t)window & 0xf)
+    throw gc_bad_align("window");
+
+  std::string proc_name;
+  if (forward)
+    proc_name = "fwd_fft_1d_r2";
+  else
+    proc_name = "inv_fft_1d_r2";
+
+  gc_proc_id_t fft_id = mgr->lookup_proc(proc_name);
+  gc_job_desc_sptr jd = gc_job_manager::alloc_job_desc(mgr);
+  init_jd(jd.get(), fft_id, log2_fft_length, shift, out, in, twiddle, window);
+  if (!mgr->submit_job(jd.get())){
+    gc_job_status_t s = jd->status;
+    throw gc_bad_submit(proc_name, s);
+  }
+  return jd;
+}
+
+void
+gcp_fft_1d_r2_twiddle(unsigned int log2_fft_length, std::complex<float> *twiddle)
+{
+  unsigned int n = 1 << log2_fft_length;
+
+  twiddle[0].real() = 1.0;
+  twiddle[0].imag() = 0.0;
+  for (unsigned i=1; i < n/4; i++){
+    twiddle[i].real() =  cos(i * 2*M_PI/n);
+    twiddle[n/4 - i].imag() = -twiddle[i].real();
+  }
+}
diff --git a/gcell/lib/wrapper/qa_gcell_general.cc b/gcell/lib/wrapper/qa_gcell_general.cc
new file mode 100644 (file)
index 0000000..af97198
--- /dev/null
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_gcell_general.h"
+#include <cppunit/TestAssert.h>
+
+#include <stdio.h>
+#include <stdlib.h>    // random, posix_memalign
+#include <algorithm>
+#include <string.h>
+#include <gcell/gc_job_manager.h>
+
+
+// handle to embedded SPU executable
+extern spe_program_handle_t gcell_general_qa_spx;
+
+gc_job_desc_sptr
+gcp_qa_general_submit(gc_job_manager_sptr mgr, const std::string &proc_name)
+{
+  gc_proc_id_t proc_id = mgr->lookup_proc(proc_name);
+  gc_job_desc_sptr jd = gc_job_manager::alloc_job_desc(mgr);
+
+  jd->proc_id = proc_id;
+  jd->input.nargs = 0;
+  jd->output.nargs = 1;
+  jd->eaa.nargs = 0;
+
+  if (!mgr->submit_job(jd.get())){
+    gc_job_status_t s = jd->status;
+    throw gc_bad_submit(proc_name, s);
+  }
+  return jd;
+}
+
+
+bool
+qa_gcell_general::generic_test_body(const std::string &proc_name)
+{
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_general_qa_spx);
+  opts.nspes = 1;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+  gc_job_desc_sptr jd = gcp_qa_general_submit(mgr, proc_name);
+  if (!mgr->wait_job(jd.get())){
+    fprintf(stderr, "wait_job for %s failed: %s\n",
+           proc_name.c_str(),
+           gc_job_status_string(jd->status).c_str());
+    CPPUNIT_ASSERT(0);
+  }
+
+  return jd->output.arg[0].u32;                // bool result from SPE code
+}
+
+/*
+ * ------------------------------------------------------------------------
+ *                 Add more calls to SPE QA code here...
+ * ------------------------------------------------------------------------
+ */
+void
+qa_gcell_general::test_memset()
+{
+  CPPUNIT_ASSERT(generic_test_body("qa_memset"));
+}
+
diff --git a/gcell/lib/wrapper/qa_gcell_general.h b/gcell/lib/wrapper/qa_gcell_general.h
new file mode 100644 (file)
index 0000000..f1e64e7
--- /dev/null
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_QA_GCELL_GENERAL_H
+#define INCLUDED_QA_GCELL_GENERAL_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_gcell_general : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_gcell_general);
+  CPPUNIT_TEST(test_memset);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void test_memset();
+
+  bool generic_test_body(const std::string &proc_name);
+};
+
+#endif /* INCLUDED_QA_GCELL_GENERAL_H */
diff --git a/gcell/lib/wrapper/qa_gcell_wrapper.cc b/gcell/lib/wrapper/qa_gcell_wrapper.cc
new file mode 100644 (file)
index 0000000..d53c610
--- /dev/null
@@ -0,0 +1,41 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * This class gathers together all the test cases for the lib/wrapper
+ * directory into a single test suite.  As you create new test cases,
+ * add them here.
+ */
+
+#include <qa_gcell_wrapper.h>
+#include <qa_gcell_general.h>
+#include <qa_gcp_fft_1d_r2.h>
+
+CppUnit::TestSuite *
+qa_gcell_wrapper::suite()
+{
+  CppUnit::TestSuite   *s = new CppUnit::TestSuite("wrapper");
+
+  s->addTest(qa_gcell_general::suite());
+  s->addTest(qa_gcp_fft_1d_r2::suite());
+
+  return s;
+}
diff --git a/gcell/lib/wrapper/qa_gcell_wrapper.h b/gcell/lib/wrapper/qa_gcell_wrapper.h
new file mode 100644 (file)
index 0000000..cb29db8
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_QA_GCELL_WRAPPER_H
+#define INCLUDED_QA_GCELL_WRAPPER_H
+
+#include <cppunit/TestSuite.h>
+
+//! collect all the tests for the wrapper directory
+
+class qa_gcell_wrapper {
+public:
+  //! return suite of tests
+  static CppUnit::TestSuite *suite();
+};
+
+
+#endif /* INCLUDED_QA_GCELL_WRAPPER_H */
diff --git a/gcell/lib/wrapper/qa_gcp_fft_1d_r2.cc b/gcell/lib/wrapper/qa_gcp_fft_1d_r2.cc
new file mode 100644 (file)
index 0000000..742c624
--- /dev/null
@@ -0,0 +1,208 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "qa_gcp_fft_1d_r2.h"
+#include <cppunit/TestAssert.h>
+#include <gcell/gcp_fft_1d_r2.h>
+#include <fftw3.h>
+#include <stdio.h>
+#include <stdlib.h>    // random, posix_memalign
+#include <algorithm>
+#include <string.h>
+
+typedef boost::shared_ptr<void> void_sptr;
+
+// handle to embedded SPU executable
+extern spe_program_handle_t gcell_all_spx;
+
+/*
+ * Return pointer to cache-aligned chunk of storage of size size bytes.
+ * Throw if can't allocate memory.  The storage should be freed
+ * with "free" when done.  The memory is initialized to zero.
+ */
+static void *
+aligned_alloc(size_t size, size_t alignment = 128)
+{
+  void *p = 0;
+  if (posix_memalign(&p, alignment, size) != 0){
+    perror("posix_memalign");
+    throw std::runtime_error("memory");
+  }
+  memset(p, 0, size);          // zero the memory
+  return p;
+}
+
+class free_deleter {
+public:
+  void operator()(void *p) {
+    free(p);
+  }
+};
+
+static boost::shared_ptr<void>
+aligned_alloc_sptr(size_t size, size_t alignment = 128)
+{
+  return boost::shared_ptr<void>(aligned_alloc(size, alignment), free_deleter());
+}
+
+// test forward FFT
+void
+qa_gcp_fft_1d_r2::t1()
+{
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_all_spx);
+  opts.nspes = 1;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+#if 1
+  for (int log2_fft_size = 5; log2_fft_size <= 12; log2_fft_size++){
+    test(mgr, log2_fft_size, true);
+  }
+#else
+  test(mgr, 5, true);
+#endif
+}
+
+// test inverse FFT
+void
+qa_gcp_fft_1d_r2::t2()
+{
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_all_spx);
+  opts.nspes = 1;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+#if 1
+  for (int log2_fft_size = 5; log2_fft_size <= 12; log2_fft_size++){
+    test(mgr, log2_fft_size, false);
+  }
+#else
+  test(mgr, 5, false);
+#endif
+}
+
+void
+qa_gcp_fft_1d_r2::t3()
+{
+  // FIXME Test fwd and inv with windowing option
+}
+
+void
+qa_gcp_fft_1d_r2::t4()
+{
+  // FIXME Test fwd and inv with shift option
+}
+
+static inline float
+abs_diff(std::complex<float> x, std::complex<float> y)
+{
+  return std::max(std::abs(x.real()-y.real()),
+                 std::abs(x.imag()-y.imag()));
+}
+
+static float
+float_abs_rel_error(float ref, float actual)
+{
+  float delta = ref - actual;
+  if (std::abs(ref) < 1e-18)
+    ref = 1e-18;
+  return std::abs(delta/ref);
+}
+
+static float
+abs_rel_error(std::complex<float> ref, std::complex<float> actual)
+{
+  return std::max(float_abs_rel_error(ref.real(), actual.real()),
+                 float_abs_rel_error(ref.imag(), actual.imag()));
+}
+
+void 
+qa_gcp_fft_1d_r2::test(gc_job_manager_sptr mgr, int log2_fft_size, bool forward)
+{
+  int fft_size = 1 << log2_fft_size;
+
+  // allocate aligned buffers with boost shared_ptr's
+  void_sptr fftw_in_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
+  void_sptr fftw_out_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
+  void_sptr cell_in_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
+  void_sptr cell_out_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
+  void_sptr cell_twiddle_void = aligned_alloc_sptr(fft_size/4 * sizeof(std::complex<float>), 128);
+
+  // cast them to the type we really want
+  std::complex<float> *fftw_in = (std::complex<float> *) fftw_in_void.get();
+  std::complex<float> *fftw_out = (std::complex<float> *) fftw_out_void.get();
+  std::complex<float> *cell_in = (std::complex<float> *) cell_in_void.get();
+  std::complex<float> *cell_out = (std::complex<float> *) cell_out_void.get();
+  std::complex<float> *cell_twiddle = (std::complex<float> *) cell_twiddle_void.get();
+
+  gcp_fft_1d_r2_twiddle(log2_fft_size, cell_twiddle);
+
+  srandom(1);          // we want reproducibility
+
+  // initialize the input buffers
+  for (int i = 0; i < fft_size; i++){
+    std::complex<float> t((float) (random() & 0xfffff), (float) (random() & 0xfffff));
+    fftw_in[i] = t;
+    cell_in[i] = t;
+  }
+
+  // ------------------------------------------------------------------------
+  // compute the reference answer
+  fftwf_plan plan = fftwf_plan_dft_1d (fft_size,
+                                      reinterpret_cast<fftwf_complex *>(fftw_in), 
+                                      reinterpret_cast<fftwf_complex *>(fftw_out),
+                                      forward ? FFTW_FORWARD : FFTW_BACKWARD,
+                                      FFTW_ESTIMATE);
+  if (plan == 0){
+    fprintf(stderr, "qa_gcp_fft_1d_r2: error creating FFTW plan\n");
+    throw std::runtime_error ("fftwf_plan_dft_r2c_1d failed");
+  }
+  
+  fftwf_execute(plan);
+  fftwf_destroy_plan(plan);
+
+  // ------------------------------------------------------------------------
+  // compute the answer on the cell
+  gc_job_desc_sptr jd = gcp_fft_1d_r2_submit(mgr, log2_fft_size, forward, false,
+                                            cell_out, cell_in, cell_twiddle, 0);
+  if (!mgr->wait_job(jd.get())){
+    fprintf(stderr, "wait_job failed: %s\n", gc_job_status_string(jd->status).c_str());
+    CPPUNIT_ASSERT(0);
+  }
+
+  // ------------------------------------------------------------------------
+  // compute the maximum of the relative error
+  float max_rel = 0.0;
+  for (int i = 0; i < fft_size; i++){
+    max_rel = std::max(max_rel, abs_rel_error(fftw_out[i], cell_out[i]));
+    if (0)
+      printf("(%16.3f, %16.3fj)  (%16.3f, %16.3fj)  (%16.3f, %16.3fj)\n",
+            fftw_out[i].real(), fftw_out[i].imag(),
+            cell_out[i].real(), cell_out[i].imag(),
+            fftw_out[i].real() - cell_out[i].real(),
+            fftw_out[i].imag() - cell_out[i].imag());
+  }
+
+  fprintf(stdout, "%s fft_size = %4d  max_rel_error = %e\n",
+         forward ? "fwd" : "rev", fft_size, max_rel);
+
+  CPPUNIT_ASSERT(max_rel <= 5e-3);
+}
diff --git a/gcell/lib/wrapper/qa_gcp_fft_1d_r2.h b/gcell/lib/wrapper/qa_gcp_fft_1d_r2.h
new file mode 100644 (file)
index 0000000..339ddd2
--- /dev/null
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_QA_GCP_FFT_1D_R2_H
+#define INCLUDED_QA_GCP_FFT_1D_R2_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+#include <gcell/gc_job_manager.h>
+
+class qa_gcp_fft_1d_r2 : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_gcp_fft_1d_r2);
+  CPPUNIT_TEST(t1);
+  CPPUNIT_TEST(t2);
+  CPPUNIT_TEST(t3);
+  CPPUNIT_TEST(t4);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void t1();
+  void t2();
+  void t3();
+  void t4();
+
+  void test(gc_job_manager_sptr mgr, int log2_fft_size, bool forward);
+};
+
+
+
+#endif /* INCLUDED_QA_GCP_FFT_1D_R2_H */
diff --git a/gcell/lib/wrapper/spu/gcs_fft_1d_r2.c b/gcell/lib/wrapper/spu/gcs_fft_1d_r2.c
new file mode 100644 (file)
index 0000000..582757a
--- /dev/null
@@ -0,0 +1,94 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gcell/gc_declare_proc.h>
+#include <gcell/spu/libfft.h>
+#include <assert.h>
+
+/*
+ * v is really vector complex<float>
+ */
+static void
+conjugate_vector(vector float *v, int nelements)
+{
+  vector float k = {1, -1, 1, -1};
+  int i;
+  for (i = 0; i < nelements; i++)
+    v[i] *= k;
+}
+
+static void
+gcs_fwd_fft_1d_r2(const gc_job_direct_args_t *input,
+                 gc_job_direct_args_t *output __attribute__((unused)),
+                 const gc_job_ea_args_t *eaa)
+{
+  vector float *out = (vector float *) eaa->arg[0].ls_addr;    // complex
+  vector float *in = (vector float *) eaa->arg[1].ls_addr;     // complex
+  vector float *twiddle = (vector float *) eaa->arg[2].ls_addr;        // complex
+  vector float *window = (vector float *) eaa->arg[3].ls_addr; // float
+
+  int log2_fft_length = input->arg[0].u32;
+  int shift = input->arg[1].u32;       // non-zero if we should apply fftshift
+
+  if (eaa->arg[3].get_size){   // apply window
+    // FIXME pointwise multiply in *= window
+    assert(0);
+  }
+
+  fft_1d_r2(out, in, twiddle, log2_fft_length);
+
+  if (shift){
+    // FIXME apply "fftshift" to output data in-place
+    assert(0);
+  }
+}
+
+GC_DECLARE_PROC(gcs_fwd_fft_1d_r2, "fwd_fft_1d_r2");
+
+static void
+gcs_inv_fft_1d_r2(const gc_job_direct_args_t *input,
+                 gc_job_direct_args_t *output __attribute__((unused)),
+                 const gc_job_ea_args_t *eaa)
+{
+  vector float *out = (vector float *) eaa->arg[0].ls_addr;    // complex
+  vector float *in = (vector float *) eaa->arg[1].ls_addr;     // complex
+  vector float *twiddle = (vector float *) eaa->arg[2].ls_addr;        // complex
+  vector float *window = (vector float *) eaa->arg[3].ls_addr; // float
+
+  int log2_fft_length = input->arg[0].u32;
+  int shift = input->arg[1].u32;       // non-zero if we should apply fftshift
+
+  if (eaa->arg[3].get_size){   // apply window
+    // FIXME pointwise multiply in *= window
+    assert(0);
+  }
+
+  if (shift){
+    // FIXME apply "fftshift" to input data in-place
+    assert(0);
+  }
+
+  conjugate_vector(in, 1 << (log2_fft_length - 1));
+  fft_1d_r2(out, in, twiddle, log2_fft_length);
+  conjugate_vector(out, 1 << (log2_fft_length - 1));
+}
+
+GC_DECLARE_PROC(gcs_inv_fft_1d_r2, "inv_fft_1d_r2");
diff --git a/gcell/src/Makefile.am b/gcell/src/Makefile.am
deleted file mode 100644 (file)
index af76eb6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-SUBDIRS = include lib apps ibm
diff --git a/gcell/src/apps/Makefile.am b/gcell/src/apps/Makefile.am
deleted file mode 100644 (file)
index 7dd6956..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-SUBDIRS = spu .
-
-AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) \
-       $(GCELL_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
-
-
-GCELL_QA_LA = $(top_builddir)/gcell/src/lib/libgcell-qa.la
-
-TESTS = test_all
-
-
-bin_PROGRAMS = \
-       test_all \
-       benchmark_dma \
-       benchmark_nop
-
-
-test_all_SOURCES = test_all.cc
-test_all_LDADD = $(GCELL_QA_LA) $(GCELL_LA)
-
-benchmark_dma_SOURCES = benchmark_dma.cc
-benchmark_dma_LDADD = spu/benchmark_procs $(GCELL_LA)
-
-benchmark_nop_SOURCES = benchmark_nop.cc
-benchmark_nop_LDADD = spu/benchmark_procs $(GCELL_LA)
diff --git a/gcell/src/apps/benchmark_dma.cc b/gcell/src/apps/benchmark_dma.cc
deleted file mode 100644 (file)
index 7dfaa4c..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if defined(HAVE_CONFIG_H)
-#include <config.h>
-#endif
-#include "gc_job_manager.h"
-#include <omni_time.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <boost/scoped_array.hpp>
-#include <assert.h>
-
-// handle to embedded SPU executable that contains benchmark routines
-// (The name of the variable (benchmark_procs) is the name of the spu executable.)
-extern spe_program_handle_t benchmark_procs;
-
-static gc_proc_id_t gcp_benchmark_udelay = GCP_UNKNOWN_PROC;
-
-#define        BENCHMARK_PUT           0x1
-#define        BENCHMARK_GET           0x2
-#define        BENCHMARK_GET_PUT       (BENCHMARK_PUT|BENCHMARK_GET)
-
-
-#if 0
-static bool
-power_of_2_p(unsigned long x)
-{
-  int nbits = sizeof(x) * 8;
-  for (int i = 0; i < nbits; i++)
-    if (x == (1UL << i))
-      return true;
-
-  return false;
-}
-#endif
-
-static void
-init_jd(gc_job_desc *jd, unsigned int usecs,
-       unsigned char *getbuf, unsigned char *putbuf, size_t buflen,
-       int getput_mask)
-{
-  jd->proc_id = gcp_benchmark_udelay;
-  jd->input.nargs = 1;
-  jd->input.arg[0].u32 = usecs;
-  jd->output.nargs = 0;
-
-  switch(getput_mask & BENCHMARK_GET_PUT){
-
-  case BENCHMARK_GET:
-    jd->eaa.nargs = 1;
-    jd->eaa.arg[0].direction = GCJD_DMA_GET;
-    jd->eaa.arg[0].ea_addr = ptr_to_ea(getbuf);
-    jd->eaa.arg[0].get_size = buflen;
-    break;
-
-  case BENCHMARK_PUT:
-    jd->eaa.nargs = 1;
-    jd->eaa.arg[0].direction = GCJD_DMA_PUT;
-    jd->eaa.arg[0].ea_addr = ptr_to_ea(putbuf);
-    jd->eaa.arg[0].put_size = buflen;
-    break;
-    
-  case BENCHMARK_GET_PUT:
-    jd->eaa.nargs = 2;
-    jd->eaa.arg[0].direction = GCJD_DMA_GET;
-    jd->eaa.arg[0].ea_addr = ptr_to_ea(getbuf);
-    jd->eaa.arg[0].get_size = buflen;
-    jd->eaa.arg[1].direction = GCJD_DMA_PUT;
-    jd->eaa.arg[1].ea_addr = ptr_to_ea(putbuf);
-    jd->eaa.arg[1].put_size = buflen;
-    break;
-  }
-}
-
-static void
-run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size, int getput_mask)
-{
-  static const int64_t TOTAL_SIZE_DMA = 5LL << 30;
-  static const int NJDS = 64;
-  unsigned int njobs = (unsigned int)(TOTAL_SIZE_DMA / dma_size);
-  //unsigned int njobs = NJDS * 16;
-  unsigned int nsubmitted = 0;
-  unsigned int ncompleted = 0;
-  gc_job_desc *all_jds[NJDS];
-  gc_job_desc *jds[2][NJDS];
-  unsigned int njds[2];
-  unsigned int ci;             // current index
-  bool done[NJDS];
-  
-  static const unsigned int BUFSIZE = (32 << 10) * NJDS;
-  unsigned char *getbuf = new unsigned char[BUFSIZE];
-  boost::scoped_array<unsigned char> _getbuf(getbuf);
-  unsigned char *putbuf = new unsigned char[BUFSIZE];
-  boost::scoped_array<unsigned char> _putbuf(putbuf);
-  int gbi = 0;
-
-  // touch all pages to force allocation now
-  for (unsigned int i = 0; i < BUFSIZE; i += 4096){
-    getbuf[i] = 0;
-    putbuf[i] = 0;
-  }
-
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&benchmark_procs);
-  opts.nspes = nspes;
-  //opts.enable_logging = true;
-  //opts.log2_nlog_entries = 13;
-  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
-
-  if ((gcp_benchmark_udelay = mgr->lookup_proc("benchmark_udelay")) == GCP_UNKNOWN_PROC){
-    fprintf(stderr, "lookup_proc: failed to find \"benchmark_udelay\"\n");
-    return;
-  }
-
-  // allocate and init all job descriptors
-  for (int i = 0; i < NJDS; i++){
-    if (gbi + dma_size > BUFSIZE)
-      gbi = 0;
-
-    all_jds[i] = mgr->alloc_job_desc();
-    if (all_jds[i] == 0){
-      fprintf(stderr, "alloc_job_desc() returned 0\n");
-      return;
-    }
-    init_jd(all_jds[i], usecs, &getbuf[gbi], &putbuf[gbi], dma_size, getput_mask);
-    gbi += dma_size;
-  }
-
-  for (int iter = 0; iter < 1; iter++){
-
-    omni_time t_start = omni_time::time();
-
-    nsubmitted = 0;
-    ncompleted = 0;
-
-    ci = 0;
-    njds[0] = 0;
-    njds[1] = 0;
-  
-    // submit the first batch
-    for (int i = 0; i < NJDS; i++){
-      if (mgr->submit_job(all_jds[i])){
-       jds[ci][njds[ci]++] = all_jds[i];
-       nsubmitted++;
-      }
-      else {
-       printf("submit_job(jds[%d]) failed, status = %d\n",
-              i, all_jds[i]->status);
-      }
-    }
-  
-    while (ncompleted < njobs){
-      njds[ci^1] = 0;
-      int n = mgr->wait_jobs(njds[ci], jds[ci], done, GC_WAIT_ANY);
-      // printf("%2d\n", n);
-      if (n < 0){
-       fprintf(stderr, "mgr->wait_jobs failed\n");
-       break;
-      }
-      for (unsigned int i = 0; i < njds[ci]; i++){
-       if (!done[i]){  // remember for next iteration
-         jds[ci^1][njds[ci^1]++] = jds[ci][i];
-       }
-       else {
-         ncompleted++;
-         if (jds[ci][i]->status != JS_OK){
-           printf("js_status = %d, job_id = %d, ncompleted = %d\n",
-                  jds[ci][i]->status, jds[ci][i]->sys.job_id, ncompleted);
-         }
-         if (nsubmitted < njobs){                  // submit another one
-           if (mgr->submit_job(jds[ci][i])){
-             jds[ci^1][njds[ci^1]++] = jds[ci][i];  // remember for next iter
-             nsubmitted++;
-           }
-           else {
-             printf("submit_job(jds[%d]) failed, status = %d\n",
-                    i, jds[ci][i]->status);
-           }
-         }
-       }
-      }
-      ci ^= 1; // toggle current
-    }
-
-    // stop timing
-    omni_time t_stop = omni_time::time();
-
-    double delta = (t_stop - t_start).double_time();
-    printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  dma_size: %5d  dma_throughput: %7.3e\n",
-          mgr->nspes(), usecs, delta, dma_size,
-          (double) njobs * dma_size / delta * (getput_mask == BENCHMARK_GET_PUT ? 2.0 : 1.0));
-
-  }
-}
-
-static void
-usage()
-{
-  fprintf(stderr, "usage: benchmark_dma [-p] [-g] [-n <nspes>] [-u <udelay>] [-s <dma_size>]\n");
-  fprintf(stderr, "  you must specify one or both of -p (put) and -g (get)\n");
-}
-
-
-int
-main(int argc, char **argv)
-{
-  unsigned int nspes = 0;
-  unsigned int usecs = 0;
-  unsigned int dma_size = 32 << 10;
-  int getput_mask = 0;
-  int ch;
-
-  while ((ch = getopt(argc, argv, "n:u:s:pg")) != EOF){
-    switch(ch){
-    case 'n':
-      nspes = strtol(optarg, 0, 0);
-      break;
-
-    case 'u':
-      usecs = strtol(optarg, 0, 0);
-      break;
-
-    case 's':
-      dma_size = strtol(optarg, 0, 0);
-      if (dma_size == 0){
-       fprintf(stderr, "-s <dma_size> must be > 0\n");
-       return 1;
-      }
-      break;
-
-    case 'p':
-      getput_mask |= BENCHMARK_PUT;
-      break;
-
-    case 'g':
-      getput_mask |= BENCHMARK_GET;
-      break;
-      
-    case '?':
-    default:
-      usage();
-      return 1;
-    }
-  }
-
-  if (getput_mask == 0){
-    usage();
-    return 1;
-  }
-
-  run_test(nspes, usecs, dma_size, getput_mask);
-  return 0;
-}
diff --git a/gcell/src/apps/benchmark_nop.cc b/gcell/src/apps/benchmark_nop.cc
deleted file mode 100644 (file)
index f427c85..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#if defined(HAVE_CONFIG_H)
-#include <config.h>
-#endif
-#include "gc_job_manager.h"
-#include <omni_time.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-// handle to embedded SPU executable that contains benchmark routines
-// (The name of the variable (benchmark_procs) is the name of the spu executable.)
-extern spe_program_handle_t benchmark_procs;
-
-static gc_proc_id_t gcp_benchmark_udelay = GCP_UNKNOWN_PROC;
-
-static void
-init_jd(gc_job_desc *jd, unsigned int usecs)
-{
-  jd->proc_id = gcp_benchmark_udelay;
-  jd->input.nargs = 1;
-  jd->input.arg[0].u32 = usecs;
-  jd->output.nargs = 0;
-  jd->eaa.nargs = 0;
-}
-
-static void
-run_test(unsigned int nspes, unsigned int usecs, int njobs)
-{
-  static const int NJDS = 64;
-  int nsubmitted = 0;
-  int ncompleted = 0;
-  gc_job_desc *all_jds[NJDS];
-  gc_job_desc *jds[2][NJDS];
-  unsigned int njds[2];
-  unsigned int ci;             // current index
-  bool done[NJDS];
-  
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&benchmark_procs);
-  opts.nspes = nspes;
-  opts.gang_schedule = true;
-  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
-
-  if ((gcp_benchmark_udelay = mgr->lookup_proc("benchmark_udelay")) == GCP_UNKNOWN_PROC){
-    fprintf(stderr, "lookup_proc: failed to find \"benchmark_udelay\"\n");
-    return;
-  }
-
-  // allocate and init all job descriptors
-  for (int i = 0; i < NJDS; i++){
-    all_jds[i] = mgr->alloc_job_desc();
-    init_jd(all_jds[i], usecs);
-  }
-
-  omni_time t_start = omni_time::time();
-
-  ci = 0;
-  njds[0] = 0;
-  njds[1] = 0;
-  
-  // submit the first batch
-  for (int i = 0; i < NJDS; i++){
-    if (mgr->submit_job(all_jds[i])){
-      jds[ci][njds[ci]++] = all_jds[i];
-      nsubmitted++;
-    }
-    else {
-      printf("submit_job(jds[%d]) failed, status = %d\n",
-            i, all_jds[i]->status);
-    }
-  }
-  
-  while (ncompleted < njobs){
-    njds[ci^1] = 0;
-    int n = mgr->wait_jobs(njds[ci], jds[ci], done, GC_WAIT_ANY);
-    // printf("%2d\n", n);
-    if (n < 0){
-      fprintf(stderr, "mgr->wait_jobs failed\n");
-      break;
-    }
-    for (unsigned int i = 0; i < njds[ci]; i++){
-      if (!done[i]){   // remember for next iteration
-       jds[ci^1][njds[ci^1]++] = jds[ci][i];
-      }
-      else {
-       ncompleted++;
-       // printf("ncompleted = %7d\n", ncompleted);
-       if (nsubmitted < njobs){                    // submit another one
-         if (mgr->submit_job(jds[ci][i])){
-           jds[ci^1][njds[ci^1]++] = jds[ci][i];  // remember for next iter
-           nsubmitted++;
-         }
-         else {
-           printf("submit_job(jds[%d]) failed, status = %d\n",
-                  i, jds[ci][i]->status);
-         }
-       }
-      }
-    }
-    ci ^= 1;   // toggle current
-  }
-
-  // stop timing
-  omni_time t_stop = omni_time::time();
-  double delta = (t_stop - t_start).double_time();
-  printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  njobs: %g  speedup: %6.3f\n",
-        mgr->nspes(), usecs, delta, (double) njobs,
-        njobs * usecs * 1e-6 / delta);
-}
-
-int
-main(int argc, char **argv)
-{
-  unsigned int nspes = 0;
-  unsigned int usecs = 0;
-  int njobs = 500000;
-  int ch;
-
-  while ((ch = getopt(argc, argv, "n:u:N:")) != EOF){
-    switch(ch){
-    case 'n':
-      nspes = strtol(optarg, 0, 0);
-      break;
-
-    case 'u':
-      usecs = strtol(optarg, 0, 0);
-      break;
-
-    case 'N':
-      njobs = strtol(optarg, 0, 0);
-      break;
-
-    case '?':
-    default:
-      fprintf(stderr, "usage: benchmark_nop [-n <nspes>] [-u <udelay>] [-N <njobs>]\n");
-      return 1;
-    }
-  }
-
-  run_test(nspes, usecs, njobs);
-  return 0;
-}
diff --git a/gcell/src/apps/gen_script.py b/gcell/src/apps/gen_script.py
deleted file mode 100755 (executable)
index e4bbc74..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import time
-import os
-
-from optparse import OptionParser
-
-
-def get_svn_rev():
-    try:
-        f = os.popen("svn info", "r")
-        lines = f.readlines()
-        f.close()
-    except:
-        return "unk"
-
-    svn_rev = "unk"
-    for l in lines:
-        if l.startswith('Revision:'):
-            t = l.rstrip()
-            svn_rev = t.split()[-1]
-    return svn_rev
-    
-def is_ps3():
-    try:
-        f = open("/proc/cpuinfo")
-        s = f.read()
-    except:
-        return False
-
-    return s.find('PS3') != -1
-
-
-def main():
-
-    def make_fname(suffix):
-        return basename + '.' + suffix
-
-    max_spes_default = 16
-    if is_ps3():
-        max_spes_default = 6
-        
-    parser = OptionParser()
-    parser.add_option("-m", "--max-spes", type="int", default=max_spes_default,
-                      metavar="NSPES",
-                      help="maximum number of SPEs to use [default=%default]")
-    parser.add_option("", "--min-spes", type="int", default=1,
-                      metavar="NSPES",
-                      help="minimum number of SPEs to use [default=%default]")
-    parser.add_option("-p", "--oprofile", action="store_true", default=False,
-                      help="emit oprofile commands")
-    parser.add_option("-t", "--tag", default=None,
-                      help="additional goodie in generated filenames")
-    (options, args) = parser.parse_args()
-    if len(args) != 0:
-        parser.print_help()
-        sys.exit(1)
-
-    svn_rev = get_svn_rev()
-
-    os.environ['TZ'] = 'PST8PDT'        # always pacific
-    time.tzset()
-
-    tag = ''
-    if options.tag:
-        tag = '-' + options.tag
-        
-    basename = 'R-%s%s-%s' % (svn_rev, tag, time.strftime('%Y%m%d-%H%M'))
-
-    base_njobs = int(500e3)
-    njobs = {
-         1 : base_njobs,
-        10 : base_njobs,
-        50 : base_njobs,
-       100 : base_njobs, 
-       200 : int(base_njobs/2),
-       250 : int(base_njobs/2.5),
-       300 : int(base_njobs/3),
-       400 : int(base_njobs/4),
-       500 : int(base_njobs/5)
-        }
-
-    
-    f_results = make_fname('results')
-    f_opreport = make_fname('opreport')
-    f_avg = make_fname('avg')
-    f_png = make_fname('png')
-
-    f = sys.stdout
-    f.write("#!/bin/bash\n")
-
-    if options.oprofile:
-        f.write("opcontrol --stop\n")
-        f.write("opcontrol --reset\n")
-        f.write("opcontrol --start\n")
-
-    f.write("(\n")
-
-    for udelay in (10, 50, 100, 200, 300):
-        for nspes in range(options.min_spes, options.max_spes+1):
-            cmd = "./benchmark_nop -n %d -u %d -N %d\n" % (nspes, udelay, njobs[udelay])
-            f.write(cmd)
-            f.write(cmd)
-
-    f.write(") | tee %s\n" % (f_results,))
-
-    if options.oprofile:
-        f.write("opcontrol --dump\n")
-        f.write("opcontrol --stop\n")
-        f.write("opreport -l | head -100 > %s\n" % (f_opreport,))
-
-    f.write("./split_and_avg_results.py %s > %s\n" % (f_results, f_avg))
-    f.write("./plot_speedup.py %s -o %s\n" % (f_avg, f_png))
-
-
-if __name__ == '__main__':
-    main()
diff --git a/gcell/src/apps/plot_speedup.py b/gcell/src/apps/plot_speedup.py
deleted file mode 100755 (executable)
index 96277f8..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env python
-
-from optparse import OptionParser
-from pylab import *
-from pprint import pprint
-import os.path
-
-
-def add_entry(d, nspes, speedup, work_incr):
-    if d.has_key(work_incr):
-        d[work_incr].append((nspes, speedup))
-    else:
-        d[work_incr] = [(nspes, speedup)]
-    
-def parse_file(f):
-    d = {}
-    for line in f:
-        items = [float(x) for x in line.split()]
-        # print "items =", items
-        nspes = items[0]
-        work_incr = int(1e6 * items[1])
-        speedup = items[4]
-        add_entry(d, nspes, speedup, work_incr)
-    return d
-
-
-class plot_data(object):
-    def __init__(self, filenames, output_filename):
-        self.fig = figure(1, figsize=(8, 6), facecolor='w')
-        self.sp = self.fig.add_subplot(1,1,1)
-        self.sp.set_xlabel("nspes", fontweight="bold")
-        self.sp.set_ylabel("speedup", fontweight="bold")
-        self.sp.grid(True)
-        # print 'rcParams["legend.fontsize"] =', rcParams["legend.fontsize"]
-        rcParams["legend.fontsize"] = 10
-
-
-        self.markers = {
-             10 : 'o',
-             50 : 's',
-            100 : '^',
-            200 : 'D',
-            300 : 'v',
-            400 : '>',
-            500 : 'h'
-            }
-        
-        if len(filenames) == 1:
-            f = filenames[0]
-            d = parse_file(open(f))
-            self.make_single_plot(d, f)
-            
-        else:
-            for f in filenames:
-                d = parse_file(open(f))
-                self.make_plot(d, f, f == filenames[0])
-
-        if output_filename:
-            savefig(output_filename)
-        else:
-            show()
-
-
-    def make_single_plot(self, d, filename):
-        def style(k):
-            return self.markers[k]
-
-        tag, ext = os.path.splitext(os.path.basename(filename))
-        title(tag)
-        keys = d.keys()
-        keys.sort()
-        keys.reverse()
-        for k in keys:
-            vlist = d[k]         # list of 2-tuples
-            xs = [v[0] for v in vlist]
-            ys = [v[1] for v in vlist]
-            plot(xs, ys, style(k), label="%d us" % (k,))
-
-        x = legend(loc=2)
-
-    def make_plot(self, d, filename, first):
-        def style(k):
-            if first:
-                return self.markers[k]
-            else:
-                return 'k' + self.markers[k]
-
-        tag, ext = os.path.splitext(os.path.basename(filename))
-        keys = d.keys()
-        keys.sort()
-        keys.reverse()
-        for k in keys:
-            vlist = d[k]         # list of 2-tuples
-            xs = [v[0] for v in vlist]
-            ys = [v[1] for v in vlist]
-            plot(xs, ys, style(k), label="%s %d us" % (tag, k))
-
-        x = legend(loc=2)
-
-def main():
-    usage="%prog: [options] input_filename..."
-    description = "Plot R*.avg files from benchmark_nop.py"
-    parser = OptionParser(usage=usage, description=description)
-    parser.add_option('-o', '--output', default=None,  metavar="FILE",
-                      help="generate .png file")
-    (options, args) = parser.parse_args()
-    if len(args) < 1:
-        parser.print_help()
-        raise SystemExit, 1
-
-    filenames = args
-    dc = plot_data(filenames, options.output)
-
-
-        
-if __name__ == '__main__':
-    try:
-        main()
-    except KeyboardInterrupt:
-        pass
-
diff --git a/gcell/src/apps/results-071223 b/gcell/src/apps/results-071223
deleted file mode 100644 (file)
index 2716171..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-nspes:  1  udelay:    1  elapsed_time:  26.117  njobs: 1e+06  us/job:  26.117
-nspes:  1  udelay:    1  elapsed_time:  26.058  njobs: 1e+06  us/job:  26.058
-nspes:  1  udelay:    1  elapsed_time:  26.737  njobs: 1e+06  us/job:  26.737
-nspes:  2  udelay:    1  elapsed_time:  23.585  njobs: 1e+06  us/job:  23.585
-nspes:  2  udelay:    1  elapsed_time:  21.958  njobs: 1e+06  us/job:  21.958
-nspes:  2  udelay:    1  elapsed_time:  21.034  njobs: 1e+06  us/job:  21.034
-nspes:  3  udelay:    1  elapsed_time:  25.819  njobs: 1e+06  us/job:  25.819
-nspes:  3  udelay:    1  elapsed_time:  23.719  njobs: 1e+06  us/job:  23.719
-nspes:  3  udelay:    1  elapsed_time:  21.711  njobs: 1e+06  us/job:  21.711
-nspes:  4  udelay:    1  elapsed_time:  20.210  njobs: 1e+06  us/job:  20.210
-nspes:  4  udelay:    1  elapsed_time:  20.558  njobs: 1e+06  us/job:  20.558
-nspes:  4  udelay:    1  elapsed_time:  20.957  njobs: 1e+06  us/job:  20.957
-nspes:  5  udelay:    1  elapsed_time:  24.571  njobs: 1e+06  us/job:  24.571
-nspes:  5  udelay:    1  elapsed_time:  20.207  njobs: 1e+06  us/job:  20.207
-nspes:  5  udelay:    1  elapsed_time:  21.976  njobs: 1e+06  us/job:  21.976
-nspes:  6  udelay:    1  elapsed_time:  22.601  njobs: 1e+06  us/job:  22.601
-nspes:  6  udelay:    1  elapsed_time:  18.794  njobs: 1e+06  us/job:  18.794
-nspes:  6  udelay:    1  elapsed_time:  19.755  njobs: 1e+06  us/job:  19.755
-nspes:  1  udelay:    5  elapsed_time:  28.047  njobs: 1e+06  us/job:  28.047
-nspes:  1  udelay:    5  elapsed_time:  27.265  njobs: 1e+06  us/job:  27.265
-nspes:  1  udelay:    5  elapsed_time:  27.555  njobs: 1e+06  us/job:  27.555
-nspes:  2  udelay:    5  elapsed_time:  21.130  njobs: 1e+06  us/job:  21.130
-nspes:  2  udelay:    5  elapsed_time:  21.067  njobs: 1e+06  us/job:  21.067
-nspes:  2  udelay:    5  elapsed_time:  21.607  njobs: 1e+06  us/job:  21.607
-nspes:  3  udelay:    5  elapsed_time:  23.712  njobs: 1e+06  us/job:  23.712
-nspes:  3  udelay:    5  elapsed_time:  23.658  njobs: 1e+06  us/job:  23.658
-nspes:  3  udelay:    5  elapsed_time:  25.277  njobs: 1e+06  us/job:  25.277
-nspes:  4  udelay:    5  elapsed_time:  22.264  njobs: 1e+06  us/job:  22.264
-nspes:  4  udelay:    5  elapsed_time:  20.970  njobs: 1e+06  us/job:  20.970
-nspes:  4  udelay:    5  elapsed_time:  21.533  njobs: 1e+06  us/job:  21.533
-nspes:  5  udelay:    5  elapsed_time:  21.504  njobs: 1e+06  us/job:  21.504
-nspes:  5  udelay:    5  elapsed_time:  21.956  njobs: 1e+06  us/job:  21.956
-nspes:  5  udelay:    5  elapsed_time:  21.333  njobs: 1e+06  us/job:  21.333
-nspes:  6  udelay:    5  elapsed_time:  20.639  njobs: 1e+06  us/job:  20.639
-nspes:  6  udelay:    5  elapsed_time:  23.022  njobs: 1e+06  us/job:  23.022
-nspes:  6  udelay:    5  elapsed_time:  22.453  njobs: 1e+06  us/job:  22.453
-nspes:  1  udelay:   10  elapsed_time:  27.780  njobs: 1e+06  us/job:  27.780
-nspes:  1  udelay:   10  elapsed_time:  27.683  njobs: 1e+06  us/job:  27.683
-nspes:  1  udelay:   10  elapsed_time:  26.803  njobs: 1e+06  us/job:  26.803
-nspes:  2  udelay:   10  elapsed_time:  20.878  njobs: 1e+06  us/job:  20.878
-nspes:  2  udelay:   10  elapsed_time:  22.430  njobs: 1e+06  us/job:  22.430
-nspes:  2  udelay:   10  elapsed_time:  20.952  njobs: 1e+06  us/job:  20.952
-nspes:  3  udelay:   10  elapsed_time:  22.752  njobs: 1e+06  us/job:  22.752
-nspes:  3  udelay:   10  elapsed_time:  24.294  njobs: 1e+06  us/job:  24.294
-nspes:  3  udelay:   10  elapsed_time:  23.935  njobs: 1e+06  us/job:  23.935
-nspes:  4  udelay:   10  elapsed_time:  20.437  njobs: 1e+06  us/job:  20.437
-nspes:  4  udelay:   10  elapsed_time:  21.498  njobs: 1e+06  us/job:  21.498
-nspes:  4  udelay:   10  elapsed_time:  20.521  njobs: 1e+06  us/job:  20.521
-nspes:  5  udelay:   10  elapsed_time:  22.704  njobs: 1e+06  us/job:  22.704
-nspes:  5  udelay:   10  elapsed_time:  21.106  njobs: 1e+06  us/job:  21.106
-nspes:  5  udelay:   10  elapsed_time:  22.800  njobs: 1e+06  us/job:  22.800
-nspes:  6  udelay:   10  elapsed_time:  21.098  njobs: 1e+06  us/job:  21.098
-nspes:  6  udelay:   10  elapsed_time:  22.749  njobs: 1e+06  us/job:  22.749
-nspes:  6  udelay:   10  elapsed_time:  19.651  njobs: 1e+06  us/job:  19.651
-nspes:  1  udelay:   50  elapsed_time:  54.621  njobs: 1e+06  us/job:  54.621
-nspes:  1  udelay:   50  elapsed_time:  54.548  njobs: 1e+06  us/job:  54.548
-nspes:  1  udelay:   50  elapsed_time:  54.641  njobs: 1e+06  us/job:  54.641
-nspes:  2  udelay:   50  elapsed_time:  30.837  njobs: 1e+06  us/job:  30.837
-nspes:  2  udelay:   50  elapsed_time:  30.933  njobs: 1e+06  us/job:  30.933
-nspes:  2  udelay:   50  elapsed_time:  30.044  njobs: 1e+06  us/job:  30.044
-nspes:  3  udelay:   50  elapsed_time:  24.170  njobs: 1e+06  us/job:  24.170
-nspes:  3  udelay:   50  elapsed_time:  23.798  njobs: 1e+06  us/job:  23.798
-nspes:  3  udelay:   50  elapsed_time:  23.515  njobs: 1e+06  us/job:  23.515
-nspes:  4  udelay:   50  elapsed_time:  23.011  njobs: 1e+06  us/job:  23.011
-nspes:  4  udelay:   50  elapsed_time:  21.382  njobs: 1e+06  us/job:  21.382
-nspes:  4  udelay:   50  elapsed_time:  20.531  njobs: 1e+06  us/job:  20.531
-nspes:  5  udelay:   50  elapsed_time:  24.157  njobs: 1e+06  us/job:  24.157
-nspes:  5  udelay:   50  elapsed_time:  21.119  njobs: 1e+06  us/job:  21.119
-nspes:  5  udelay:   50  elapsed_time:  22.055  njobs: 1e+06  us/job:  22.055
-nspes:  6  udelay:   50  elapsed_time:  19.136  njobs: 1e+06  us/job:  19.136
-nspes:  6  udelay:   50  elapsed_time:  20.607  njobs: 1e+06  us/job:  20.607
-nspes:  6  udelay:   50  elapsed_time:  20.527  njobs: 1e+06  us/job:  20.527
-nspes:  1  udelay:  100  elapsed_time: 107.531  njobs: 1e+06  us/job: 107.531
-nspes:  1  udelay:  100  elapsed_time: 107.607  njobs: 1e+06  us/job: 107.607
-nspes:  1  udelay:  100  elapsed_time: 107.532  njobs: 1e+06  us/job: 107.532
-nspes:  2  udelay:  100  elapsed_time:  53.950  njobs: 1e+06  us/job:  53.950
-nspes:  2  udelay:  100  elapsed_time:  53.920  njobs: 1e+06  us/job:  53.920
-nspes:  2  udelay:  100  elapsed_time:  54.232  njobs: 1e+06  us/job:  54.232
-nspes:  3  udelay:  100  elapsed_time:  37.987  njobs: 1e+06  us/job:  37.987
-nspes:  3  udelay:  100  elapsed_time:  38.778  njobs: 1e+06  us/job:  38.778
-nspes:  3  udelay:  100  elapsed_time:  39.042  njobs: 1e+06  us/job:  39.042
-nspes:  4  udelay:  100  elapsed_time:  31.192  njobs: 1e+06  us/job:  31.192
-nspes:  4  udelay:  100  elapsed_time:  31.090  njobs: 1e+06  us/job:  31.090
-nspes:  4  udelay:  100  elapsed_time:  31.472  njobs: 1e+06  us/job:  31.472
-nspes:  5  udelay:  100  elapsed_time:  28.490  njobs: 1e+06  us/job:  28.490
-nspes:  5  udelay:  100  elapsed_time:  27.574  njobs: 1e+06  us/job:  27.574
-nspes:  5  udelay:  100  elapsed_time:  27.013  njobs: 1e+06  us/job:  27.013
-nspes:  6  udelay:  100  elapsed_time:  26.635  njobs: 1e+06  us/job:  26.635
-nspes:  6  udelay:  100  elapsed_time:  24.036  njobs: 1e+06  us/job:  24.036
-nspes:  6  udelay:  100  elapsed_time:  26.174  njobs: 1e+06  us/job:  26.174
-nspes:  1  udelay:  300  elapsed_time: 320.618  njobs: 1e+06  us/job: 320.618
-nspes:  1  udelay:  300  elapsed_time: 320.635  njobs: 1e+06  us/job: 320.635
-nspes:  1  udelay:  300  elapsed_time: 320.699  njobs: 1e+06  us/job: 320.699
-nspes:  2  udelay:  300  elapsed_time: 160.314  njobs: 1e+06  us/job: 160.314
-nspes:  2  udelay:  300  elapsed_time: 160.340  njobs: 1e+06  us/job: 160.340
-nspes:  2  udelay:  300  elapsed_time: 160.312  njobs: 1e+06  us/job: 160.312
-nspes:  3  udelay:  300  elapsed_time: 106.878  njobs: 1e+06  us/job: 106.878
-nspes:  3  udelay:  300  elapsed_time: 106.875  njobs: 1e+06  us/job: 106.875
-nspes:  3  udelay:  300  elapsed_time: 106.871  njobs: 1e+06  us/job: 106.871
-nspes:  4  udelay:  300  elapsed_time:  80.158  njobs: 1e+06  us/job:  80.158
-nspes:  4  udelay:  300  elapsed_time:  80.163  njobs: 1e+06  us/job:  80.163
-nspes:  4  udelay:  300  elapsed_time:  80.154  njobs: 1e+06  us/job:  80.154
-nspes:  5  udelay:  300  elapsed_time:  64.156  njobs: 1e+06  us/job:  64.156
-nspes:  5  udelay:  300  elapsed_time:  64.250  njobs: 1e+06  us/job:  64.250
-nspes:  5  udelay:  300  elapsed_time:  64.158  njobs: 1e+06  us/job:  64.158
-nspes:  6  udelay:  300  elapsed_time:  53.633  njobs: 1e+06  us/job:  53.633
-nspes:  6  udelay:  300  elapsed_time:  53.541  njobs: 1e+06  us/job:  53.541
-nspes:  6  udelay:  300  elapsed_time:  53.617  njobs: 1e+06  us/job:  53.617
-nspes:  1  udelay:  500  elapsed_time: 533.638  njobs: 1e+06  us/job: 533.638
-nspes:  1  udelay:  500  elapsed_time: 533.649  njobs: 1e+06  us/job: 533.649
-nspes:  1  udelay:  500  elapsed_time: 533.618  njobs: 1e+06  us/job: 533.618
-nspes:  2  udelay:  500  elapsed_time: 266.810  njobs: 1e+06  us/job: 266.810
-nspes:  2  udelay:  500  elapsed_time: 266.814  njobs: 1e+06  us/job: 266.814
-nspes:  2  udelay:  500  elapsed_time: 266.893  njobs: 1e+06  us/job: 266.893
-nspes:  3  udelay:  500  elapsed_time: 177.875  njobs: 1e+06  us/job: 177.875
-nspes:  3  udelay:  500  elapsed_time: 177.878  njobs: 1e+06  us/job: 177.878
-nspes:  3  udelay:  500  elapsed_time: 177.875  njobs: 1e+06  us/job: 177.875
-nspes:  4  udelay:  500  elapsed_time: 133.417  njobs: 1e+06  us/job: 133.417
-nspes:  4  udelay:  500  elapsed_time: 133.483  njobs: 1e+06  us/job: 133.483
-nspes:  4  udelay:  500  elapsed_time: 133.407  njobs: 1e+06  us/job: 133.407
-nspes:  5  udelay:  500  elapsed_time: 106.723  njobs: 1e+06  us/job: 106.723
-nspes:  5  udelay:  500  elapsed_time: 106.728  njobs: 1e+06  us/job: 106.728
-nspes:  5  udelay:  500  elapsed_time: 106.722  njobs: 1e+06  us/job: 106.722
-nspes:  6  udelay:  500  elapsed_time:  88.943  njobs: 1e+06  us/job:  88.943
-nspes:  6  udelay:  500  elapsed_time:  88.941  njobs: 1e+06  us/job:  88.941
-nspes:  6  udelay:  500  elapsed_time:  88.944  njobs: 1e+06  us/job:  88.944
diff --git a/gcell/src/apps/split_and_avg_results.py b/gcell/src/apps/split_and_avg_results.py
deleted file mode 100755 (executable)
index 8a750fa..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-"""
-input file looks like this:
-
-nspes:  1  udelay:   10  elapsed_time:   6.842  njobs: 500000  speedup:  0.731
-nspes:  2  udelay:   10  elapsed_time:   4.093  njobs: 500000  speedup:  1.221
-"""
-
-import sys
-from optparse import OptionParser
-from pprint import pprint
-
-class data(object):
-    def __init__(self, nspes, work_per_job, elapsed_time, njobs):
-        self.nspes = nspes
-        self.work_per_job = work_per_job  # seconds
-        self.elapsed_time = elapsed_time  # seconds
-        self.njobs = njobs
-        self.speedup = work_per_job * njobs / elapsed_time
-
-    def __repr__(self):
-        return "<data nspes=%d work_per_job=%s elapsed_time=%s njobs=%s speedup=%s>" % (
-            self.nspes, (self.work_per_job),
-            (self.elapsed_time),
-            (self.njobs),
-            (self.speedup))
-
-def cmp_data(x, y):
-    t = x.nspes - y.nspes
-    if t == 0:
-        t = x.work_per_job - y.work_per_job
-        if t < 0:
-            return -1
-        elif t > 0:
-            return +1
-        else:
-            return 0
-    return t
-
-def main():
-    usage = "usage: %prog [options] input_filename"
-    parser = OptionParser(usage=usage)
-    (options, args) = parser.parse_args()
-    if len(args) != 1:
-        parser.print_help()
-        raise SystemExit, 1
-    input_filename = args[0]
-
-    
-    m = {}
-    for line in open(input_filename, "r"):
-        s = line.split()
-        nspes = int(s[1])
-        work_per_job = int(s[3]) * 1e-6
-        elapsed_time = float(s[5])
-        njobs = float(s[7])
-        d = data(nspes, work_per_job, elapsed_time, njobs)
-
-        # collect lists that have the same values for nspes and work_per_job
-        # so we can generate an average elapsed_time from all observations
-        key = (nspes, work_per_job)
-        v = m.get(key, [])
-        v.append(d)
-        m[key] = v
-
-    r = []
-    for k, v in m.iteritems():
-        total_elapsed_time = sum([x.elapsed_time for x in v])
-        r.append(data(v[0].nspes,
-                      v[0].work_per_job,
-                      total_elapsed_time/len(v),
-                      v[0].njobs))
-
-    r.sort(cmp_data)
-
-    #pprint(r)
-    for t in r:
-        print t.nspes, t.work_per_job, t.elapsed_time, t.njobs, t.speedup
-
-if __name__ == '__main__':
-    main()
diff --git a/gcell/src/apps/spu/Makefile.am b/gcell/src/apps/spu/Makefile.am
deleted file mode 100644 (file)
index c07a2c3..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-
-include $(top_srcdir)/Makefile.common.spu
-
-AM_CPPFLAGS = $(GCELL_SPU_INCLUDES)
-
-# SPU executables
-
-noinst_PROGRAMS = \
-       benchmark_procs
-
-benchmark_procs_SOURCES = benchmark_procs.c
-benchmark_procs_LDADD = $(GCELL_SPU_LA)
-benchmark_procs_DEPENDENCIES = $(GCELL_SPU_LA)
-
diff --git a/gcell/src/apps/spu/benchmark_procs.c b/gcell/src/apps/spu/benchmark_procs.c
deleted file mode 100644 (file)
index 0fddb2d..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <gc_delay.h>
-#include <gc_declare_proc.h>
-#include <string.h>
-
-static void
-benchmark_udelay(const gc_job_direct_args_t *input,
-                gc_job_direct_args_t *output _UNUSED,
-                const gc_job_ea_args_t *eaa _UNUSED)
-{
-  gc_udelay(input->arg[0].u32);
-}
-
-GC_DECLARE_PROC(benchmark_udelay, "benchmark_udelay");
-
-
-
-static void
-benchmark_put_zeros(const gc_job_direct_args_t *input _UNUSED,
-                   gc_job_direct_args_t *output _UNUSED,
-                   const gc_job_ea_args_t *eaa)
-{
-  for (unsigned int i = 0; i < eaa->nargs; i++){
-    if (eaa->arg[i].direction == GCJD_DMA_PUT)
-      memset(eaa->arg[i].ls_addr, 0, eaa->arg[i].put_size);
-  }
-}
-
-GC_DECLARE_PROC(benchmark_put_zeros, "benchmark_put_zeros");
-
-
-static void
-benchmark_copy(const gc_job_direct_args_t *input _UNUSED,
-              gc_job_direct_args_t *output,
-              const gc_job_ea_args_t *eaa)
-{
-  if (eaa->nargs != 2
-      || eaa->arg[0].direction != GCJD_DMA_PUT
-      || eaa->arg[1].direction != GCJD_DMA_GET){
-    output->arg[0].s32 = -1;
-    return;
-  }
-
-  output->arg[0].s32 = 0;
-  unsigned n = eaa->arg[0].put_size;
-  if (eaa->arg[1].get_size < n)
-    n = eaa->arg[1].get_size;
-  
-  memcpy(eaa->arg[0].ls_addr, eaa->arg[1].ls_addr, n);
-}
-
-GC_DECLARE_PROC(benchmark_copy, "benchmark_copy");
diff --git a/gcell/src/apps/test_all.cc b/gcell/src/apps/test_all.cc
deleted file mode 100644 (file)
index 798549b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <cppunit/TextTestRunner.h>
-
-#include <qa_gcell_runtime.h>
-#include <qa_gcell_wrapper.h>
-
-int 
-main(int argc, char **argv)
-{
-  
-  CppUnit::TextTestRunner      runner;
-
-  runner.addTest(qa_gcell_runtime::suite());
-  runner.addTest(qa_gcell_wrapper::suite());
-  
-  bool was_successful = runner.run("", false);
-
-  return was_successful ? 0 : 1;
-}
diff --git a/gcell/src/ibm/Makefile.am b/gcell/src/ibm/Makefile.am
deleted file mode 100644 (file)
index 8013e6a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-EXTRA_DIST = \
-       ./README \
-       ./sync/ppu_source/atomic_add.h \
-       ./sync/ppu_source/atomic_add_return.h \
-       ./sync/ppu_source/atomic_dec_and_test.h \
-       ./sync/ppu_source/atomic_dec.h \
-       ./sync/ppu_source/atomic_dec_if_positive.h \
-       ./sync/ppu_source/atomic_dec_return.h \
-       ./sync/ppu_source/atomic.h \
-       ./sync/ppu_source/atomic_inc.h \
-       ./sync/ppu_source/atomic_inc_return.h \
-       ./sync/ppu_source/atomic_read.h \
-       ./sync/ppu_source/atomic_set.h \
-       ./sync/ppu_source/atomic_sub_and_test.h \
-       ./sync/ppu_source/atomic_sub.h \
-       ./sync/ppu_source/atomic_sub_return.h \
-       ./sync/ppu_source/complete_all.h \
-       ./sync/ppu_source/complete.h \
-       ./sync/ppu_source/completion.h \
-       ./sync/ppu_source/cond_broadcast.h \
-       ./sync/ppu_source/cond.h \
-       ./sync/ppu_source/cond_init.h \
-       ./sync/ppu_source/cond_signal.h \
-       ./sync/ppu_source/cond_wait.h \
-       ./sync/ppu_source/init_completion.h \
-       ./sync/ppu_source/libsync.h \
-       ./sync/ppu_source/mutex.h \
-       ./sync/ppu_source/mutex_init.h \
-       ./sync/ppu_source/mutex_lock.h \
-       ./sync/ppu_source/mutex_trylock.h \
-       ./sync/ppu_source/mutex_unlock.h \
-       ./sync/ppu_source/pdt_libsync_config.xml \
-       ./sync/ppu_source/pdt_libsync.xml \
-       ./sync/ppu_source/sync_utils.h \
-       ./sync/ppu_source/trace_libsync.h \
-       ./sync/ppu_source/wait_for_completion.h \
-       ./sync/spu_source/atomic_add.h \
-       ./sync/spu_source/atomic_add_return.h \
-       ./sync/spu_source/atomic_dec_and_test.h \
-       ./sync/spu_source/atomic_dec.h \
-       ./sync/spu_source/atomic_dec_if_positive.h \
-       ./sync/spu_source/atomic_dec_return.h \
-       ./sync/spu_source/atomic.h \
-       ./sync/spu_source/atomic_inc.h \
-       ./sync/spu_source/atomic_inc_return.h \
-       ./sync/spu_source/atomic_read.h \
-       ./sync/spu_source/atomic_set.h \
-       ./sync/spu_source/atomic_sub_and_test.h \
-       ./sync/spu_source/atomic_sub.h \
-       ./sync/spu_source/atomic_sub_return.h \
-       ./sync/spu_source/complete_all.h \
-       ./sync/spu_source/complete.h \
-       ./sync/spu_source/completion.h \
-       ./sync/spu_source/cond_broadcast.h \
-       ./sync/spu_source/cond.h \
-       ./sync/spu_source/cond_init.h \
-       ./sync/spu_source/cond_signal.h \
-       ./sync/spu_source/cond_wait.h \
-       ./sync/spu_source/init_completion.h \
-       ./sync/spu_source/libsync.h \
-       ./sync/spu_source/mutex.h \
-       ./sync/spu_source/mutex_init.h \
-       ./sync/spu_source/mutex_lock.h \
-       ./sync/spu_source/mutex_trylock.h \
-       ./sync/spu_source/mutex_unlock.h \
-       ./sync/spu_source/read_lock.h \
-       ./sync/spu_source/read_trylock.h \
-       ./sync/spu_source/read_unlock.h \
-       ./sync/spu_source/rwlock_init.h \
-       ./sync/spu_source/sync_irq.h \
-       ./sync/spu_source/sync_utils.h \
-       ./sync/spu_source/trace_libsync.h \
-       ./sync/spu_source/wait_for_completion.h \
-       ./sync/spu_source/write_lock.h \
-       ./sync/spu_source/write_trylock.h \
-       ./sync/spu_source/write_unlock.h
diff --git a/gcell/src/ibm/README b/gcell/src/ibm/README
deleted file mode 100644 (file)
index 9420fcc..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-This directory and below contains code from IBM licensed under the
-"Modified BSD license."  It was extracted unmodified from the IBM Cell
-SDK 3.0 library source tarball, lib_source.tar, typically found in
-/opt/cell/sdk/src/lib_source.tar.
-
-We've done this because this code doesn't come unpacked in the native
-(cell) installation of the SDK 3.0, and thus we can't just add a
--I/path/to/this/stuff in our Makefiles.  If this changes, we'll delete
-this code from here, and fix our Makefiles.  In the meanwhile, this
-reduces the probability of build problems.
diff --git a/gcell/src/ibm/sync/ppu_source/atomic.h b/gcell/src/ibm/sync/ppu_source/atomic.h
deleted file mode 100644 (file)
index 105f7bf..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-/*
- * atomic.h - PPE atomic SHM counter operations.
- *
- * Interfaces patterned after, and hopefully compatible
- * with PowerPC64-Linux atomic counter operations.  Uses
- * 32b values for various counters.
- */
-#ifndef _PPU_ATOMIC_H_
-#define _PPU_ATOMIC_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-
-typedef unsigned int atomic_t __attribute__ ((aligned (128))); 
-
-
-/* atomic_ea_t is a 64bit effective address  that points to 
- * an atomic_t variable 
- */
-typedef unsigned long long atomic_ea_t;
-
-/**
- * ASSUMPTIONS:
- * On the PPE, the size of a reservation granule is 128 bytes
- * (a cache-line), so when a programmer puts a reservation on an
- * address, that whole cacheline is reserved. Therefore both
- * the PPE and SPE can participate in an atomic operation as long as
- * lwarx and getllar operate on the same cacheline. 
- */ 
-
-
-/*
- * atomically loads and replaces the value v with val. 
- * Returns the old value at v
- */ 
-static __inline int _atomic_replace(atomic_ea_t v, int val)
-{
-  int old;
-  void *p;
-
-  SYNC_ULL_TO_PTR(v, p);
-
-  do {
-    old = (int)__lwarx(p);
-  } while (__stwcx(p, (unsigned int)val) == 0);
-
-  return old;
-}
-
-
-/*
- * atomically loads the value at v, adds val, replaces the
- * value at v with the sum. Returns the old value at v
- */ 
-static __inline int _atomic_modify(atomic_ea_t v, int val)
-{
-  int oldval, newval;
-  void *p;
-
-  SYNC_ULL_TO_PTR(v, p);
-
-  do {
-    oldval = (int)__lwarx(p);
-    newval = oldval + val;
-  } while (__stwcx(p, (unsigned int)newval) == 0);
-
-  return oldval;
-}
-
-
-#endif /* _PPU_ATOMIC_H_ */
-
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_add.h b/gcell/src/ibm/sync/ppu_source/atomic_add.h
deleted file mode 100644 (file)
index dd7a5b2..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_ADD_H_
-#define _PPU_ATOMIC_ADD_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_add - atomically add to a counter.
- * @v: handle to effective address of counter.
- * @a: value to be added.
- * 
- * Atomically add a value to a counter in system memory. 
- * The only restriction is that @v must be word aligned.
- */
-static __inline void _atomic_add(int a, atomic_ea_t v)
-{
-  _atomic_modify (v, a);
-}
-
-
-
-#endif /* _PPU_ATOMIC_ADD_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_add_return.h b/gcell/src/ibm/sync/ppu_source/atomic_add_return.h
deleted file mode 100644 (file)
index 0fe1275..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_ADD_RETURN_H_
-#define _PPU_ATOMIC_ADD_RETURN_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_add_return - atomically add to a counter and return previous value.
- * @v: handle to effective address of counter.
- * @a: value to be added.
- *
- * Atomically add a value to a counter in system memory.
- * The only restriction is that @v must be word aligned.
- *
- * This routine implements the "fetch and add" primitive
- * that is described in "Book I PowerPC User Instruction
- * Set Architecture" 
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_add_return(int a, atomic_ea_t v)
-{
-  return _atomic_modify (v, a);
-}
-
-
-#endif /* _PPU_ATOMIC_ADD_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_dec.h b/gcell/src/ibm/sync/ppu_source/atomic_dec.h
deleted file mode 100644 (file)
index 4f82f04..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_DEC_H_
-#define _PPU_ATOMIC_DEC_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_dec - atomically decrement a counter.
- * @v: handle to effective address of location to be modified.
- *
- * Atomically decrement a counter in system memory. The only
- * restriction is that @v must be word aligned.
- */
-static __inline void _atomic_dec(atomic_ea_t v)
-{
-  _atomic_modify (v, -1);
-}
-
-
-#endif /* _PPU_ATOMIC_DEC_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_dec_and_test.h b/gcell/src/ibm/sync/ppu_source/atomic_dec_and_test.h
deleted file mode 100644 (file)
index 5093d40..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_DEC_AND_TEST_H_
-#define _PPU_ATOMIC_DEC_AND_TEST_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_dec_and_test - atomically decrement and test if previous==0.
- * @v: handle to effective address of counter.
- *
- * Atomically decrement a counter in system memory and test 
- * if previous==0.  The only restriction is that @v must be 
- * word aligned.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_dec_and_test(atomic_ea_t v)
-{
-  return (_atomic_modify(v, -1) == 0) ? 1 : 0;
-}
-
-
-#endif /* _PPU_ATOMIC_DEC_AND_TEST_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_dec_if_positive.h b/gcell/src/ibm/sync/ppu_source/atomic_dec_if_positive.h
deleted file mode 100644 (file)
index c4d113b..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_DEC_IF_POSITIVE_H_
-#define _PPU_ATOMIC_DEC_IF_POSITIVE_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "atomic.h"
-
-/*
- * atomic_dec_if_positive - atomically decrement if counter is positive.
- *
- *  v: handle to effective address of counter.
- * 
- * Atomically decrement a counter if its value is positive.
- * The only restriction is that v must be word aligned.
- *
- *
- * Returns the old value of the counter, minus 1.
- */
-static __inline int _atomic_dec_if_positive(atomic_ea_t v)
-{
-  int ret;
-  int tmp;
-  void *p;
-
-  SYNC_ULL_TO_PTR(v, p);
-
-  do {
-    tmp = (int)__lwarx(p);
-    ret = tmp - 1;
-    tmp = (tmp > 0) ? ret : tmp; 
-  } while (__stwcx(p, (unsigned)tmp) == 0);
-
-  return ret;
-}
-
-#endif /* _PPU_ATOMIC_DEC_IF_POSITIVE_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_dec_return.h b/gcell/src/ibm/sync/ppu_source/atomic_dec_return.h
deleted file mode 100644 (file)
index cd87893..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_DEC_RETURN_H_
-#define _PPU_ATOMIC_DEC_RETURN_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_dec_return - atomically decrement a counter and return previous value.
- * @v: handle to effective address of counter.
- *
- * Atomically decrement a counter in system memory and return its
- * previous value. The only restriction is that @v must be word 
- * aligned.
- *
- * This routine implements the "fetch and decrement"
- * primitive that is described in "Book I PowerPC User
- * Instruction Set Architecture".
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_dec_return(atomic_ea_t v)
-{
-  return _atomic_modify (v, -1);
-}
-
-
-
-#endif /* _PPU_ATOMIC_DEC_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_inc.h b/gcell/src/ibm/sync/ppu_source/atomic_inc.h
deleted file mode 100644 (file)
index 714aecb..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_INC_H_
-#define _PPU_ATOMIC_INC_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_inc - atomically increment a counter in system memory.
- * @v: handle to effective address of counter.
- *
- * Atomically increment a counter in system memory.
- * The only restriction is that @v must be word aligned.
- */
-static __inline void _atomic_inc(atomic_ea_t v)
-{
-  _atomic_modify (v, 1); 
-}
-
-#endif /* _PPU_ATOMIC_INC_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_inc_return.h b/gcell/src/ibm/sync/ppu_source/atomic_inc_return.h
deleted file mode 100644 (file)
index 95178f5..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_INC_RETURN_H_
-#define _PPU_ATOMIC_INC_RETURN_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-
-/**
- * atomic_inc_return - atomically increment a counter and return previous.
- * @v: handle to effective address of counter.
- *
- * Atomically increment a counter in system memory.
- * The only restriction is that @v must be word aligned.
- *
- * This routine implements the "fetch and increment"
- * primitive that is described in "Book I PowerPC User
- * Instruction Set Architecture" 
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_inc_return(atomic_ea_t v)
-{
-  return _atomic_modify (v, 1);
-}
-
-#endif /* _PPU_ATOMIC_INC_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_read.h b/gcell/src/ibm/sync/ppu_source/atomic_read.h
deleted file mode 100644 (file)
index 258fd51..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_READ_H_
-#define _PPU_ATOMIC_READ_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/*
- * On PowerPC architecture, if v is a word_aligned address, then
- * a load of that address is guaranteed to be atomic.  An atomic
- * read operation is simply a load.
- */ 
-static __inline int _atomic_read(atomic_ea_t v)
-{
-  volatile int *p;
-
-  SYNC_ULL_TO_PTR(v, p);
-
-  return (*p);
-}
-
-
-#endif /* _PPU_ATOMIC_READ_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_set.h b/gcell/src/ibm/sync/ppu_source/atomic_set.h
deleted file mode 100644 (file)
index e624af4..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_SET_H_
-#define _PPU_ATOMIC_SET_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_set - atomically set a counter in system memory.
- * @v: this is a 64bit address that points to an atomic_t 
- * 
- * Atomically set a counter to a given value. The only 
- * restriction is that @v must be word aligned.
- *
- * This routine implements the "fetch and store" 
- * primitive that is described in "Book I PowerPC User 
- * Instruction Set Architecture"
- *
- * Returns the previous value from system memory.
- */
-static __inline void _atomic_set(atomic_ea_t v, int val)
-{
-  _atomic_replace (v, val);
-}
-
-
-#endif /* _PPU_ATOMIC_SET_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_sub.h b/gcell/src/ibm/sync/ppu_source/atomic_sub.h
deleted file mode 100644 (file)
index b8d3597..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_SUB_H_
-#define _PPU_ATOMIC_SUB_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_sub - atomically subtract from a counter.
- * @v: handle to effective address of counter.
- * @a: value to be subtracted.
- *
- * Atomically subtract a value from a counter in system memory.
- * The only restriction is that @v must be word aligned.
- */
-static __inline void _atomic_sub(int a, atomic_ea_t v)
-{
-  _atomic_modify (v, -a);
-}
-
-
-#endif /* _PPU_ATOMIC_SUB_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_sub_and_test.h b/gcell/src/ibm/sync/ppu_source/atomic_sub_and_test.h
deleted file mode 100644 (file)
index 37ba588..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_SUB_AND_TEST_H_
-#define _PPU_ATOMIC_SUB_AND_TEST_H_
-
-#include "sync_utils.h"
-#include "atomic.h"
-
-/**
- * atomic_sub_and_test - atomically subtract and test if previous==0.
- * @v: handle to effective address of counter.
- * @a: value to be subtracted.
- *
- * Atomically subtract a value from a counter in system memory
- * and test if previous==0.  The only restriction is that @v 
- * must be word aligned.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_sub_and_test(int a, atomic_ea_t v)
-{
-  return (_atomic_modify(v, -a) == 0) ? 1 : 0;
-}
-
-#endif /* _PPU_ATOMIC_SUB_AND_TEST_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/atomic_sub_return.h b/gcell/src/ibm/sync/ppu_source/atomic_sub_return.h
deleted file mode 100644 (file)
index 084bfa6..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_ATOMIC_SUB_RETURN_H_
-#define _PPU_ATOMIC_SUB_RETURN_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-
-/**
- * atomic_sub_return - atomically subtract from a counter & return previous.
- * @v: handle to effective address of counter.
- * @a: value to be subtracted.
- *
- * Atomically subtract a value from a counter in system memory.
- * The only restriction is that @v must be word aligned.
- *
- * Returns the previous value from system memory.
- */
-
-
-static __inline int _atomic_sub_return(int a, atomic_ea_t v)
-{
-  return _atomic_modify (v, -a);
-}
-
-#endif /* _PPU_ATOMIC_SUB_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/complete.h b/gcell/src/ibm/sync/ppu_source/complete.h
deleted file mode 100644 (file)
index 8633463..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COMPLETE_H_
-#define _PPU_COMPLETE_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "completion.h"
-
-
-static __inline void _complete (completion_ea_t comp)
-{
-  unsigned int old;
-  void *p;
-
-  SYNC_ULL_TO_PTR(comp, p);
-
-  do {
-    old = __lwarx(p);
-  } while (__stwcx(p, (unsigned int)1) == 0);
-}
-
-#endif /* _PPU_COMPLETE_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/complete_all.h b/gcell/src/ibm/sync/ppu_source/complete_all.h
deleted file mode 100644 (file)
index c12eb7f..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COMPLETE_ALL_H_
-#define _PPU_COMPLETE_ALL_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "completion.h"
-
-/**
- * complete_all - indicate that a completion is true.
- * @completion: handle to effective address of completion variable.
- *
- * Indicate that all are completed is true by storing 
- * MAX_THREADS_WAITING to the completionition variable.
- */
-
-static __inline void _complete_all(completion_ea_t comp)
-{
-  unsigned int old;
-  unsigned int val = MAX_THREADS_WAITING;
-
-  void *p;
-
-  SYNC_ULL_TO_PTR(comp, p);
-
-  do {
-    old = __lwarx(p);
-  } while (__stwcx(p, val) == 0);
-}
-
-#endif /* _PPU_COMPLETE_ALL_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/completion.h b/gcell/src/ibm/sync/ppu_source/completion.h
deleted file mode 100644 (file)
index b74bdaa..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-
-#ifndef _PPU_COMPLETION_H_
-#define _PPU_COMPLETION_H_
-
-
-#define MAX_THREADS_WAITING   32000 
-
-typedef unsigned long long completion_ea_t;
-
-#endif /* _PPU_COMPLETION_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/cond.h b/gcell/src/ibm/sync/ppu_source/cond.h
deleted file mode 100644 (file)
index 9a38f71..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COND_VAR_H_
-#define _PPU_COND_VAR_H_
-
-#include <mutex.h>
-#include <sync_utils.h>
-
-
-typedef struct
-{
-  short num_threads_signal;       /* the number of threads that are going to be waken up.
-                                 There are 3 values possible for this parameter, 0, 1, 
-                                 or num_threads_waiting*/
-  short num_threads_waiting;      /* the number of threads that are waiting to be awaken */ 
-} condition_variable_t __attribute__ ((aligned (16)));  
-
-typedef unsigned long long cond_ea_t;         /* a system memory 64 bit address that points to
-                                 * a valid condition_variable_t */
-
-typedef union {
-    unsigned long long ull;  
-    unsigned int ui[2];
-} val64;
-
-
-#endif /* _PPU_COND_VAR_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/cond_broadcast.h b/gcell/src/ibm/sync/ppu_source/cond_broadcast.h
deleted file mode 100644 (file)
index b93bf7b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COND_BROADCAST_H_
-#define _PPU_COND_BROADCAST_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "cond.h"
-
-/**
- * cond_broadcast - indicate that a condition is true.
- * @cond: handle to effective address of condition variable.
- */
-static __inline void _cond_broadcast (cond_ea_t cond)
-{
-  unsigned int val;
-  void *p;
-
-  SYNC_ULL_TO_PTR(cond, p);
-  
-  do {
-    val = __lwarx(p);
-
-    /* Copy the waiting count (low halfword) to
-     * the signaled count (high halfword)
-     */
-    val = (val & 0xFFFF) | ((val+1) << 16);
-    
-  } while (__stwcx(p, val) == 0);
-}
-
-#endif /* _PPU_COND_BROADCAST_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/cond_init.h b/gcell/src/ibm/sync/ppu_source/cond_init.h
deleted file mode 100644 (file)
index 0dfbd63..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COND_INIT_H_
-#define _PPU_COND_INIT_H_
-
-#include "sync_utils.h"
-#include "cond.h"
-
-/**
- * cond_init - initialize condition variable.
- * @cond: handle to effective address of condition variable.
- *
- * Only one thread initializes a condition variable. Usually, the 
- * PPE thread initializes a condidtion variable 
- *
- * Description: Initialize a cond variable to false.
- */
-static __inline void _cond_init (cond_ea_t  cond)
-{
-  volatile unsigned int *p;
-
-  SYNC_ULL_TO_PTR(cond, p);
-
-  *p = 0;
-}
-
-
-#endif /* _PPU_COND_INIT_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/cond_signal.h b/gcell/src/ibm/sync/ppu_source/cond_signal.h
deleted file mode 100644 (file)
index dd48748..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COND_SIGNAL_H_
-#define _PPU_COND_SIGNAL_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "cond.h"
-
-/*
- * _cond_signal: signaling any of the waiting threads to wake up.
- */ 
-static __inline void _cond_signal (cond_ea_t cond)
-{
-  unsigned int val, waiting, signaled;
-  void *p;
-
-  SYNC_ULL_TO_PTR(cond, p);
-  
-  do {
-    val = __lwarx(p);
-
-    waiting = val & 0xFFFF;
-    signaled = val >> 16;
-    
-    /* If no other party is waiting. Don't send a signal.
-     * Otherwise, increment the signaled halfword.
-     */
-    if (waiting == signaled) break;
-    val = ((val+1) << 16) | waiting;
-
-  } while (__stwcx(p, val) == 0);
-}
-
-
-#endif /* _PPU_COND_SIGNAL_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/cond_wait.h b/gcell/src/ibm/sync/ppu_source/cond_wait.h
deleted file mode 100644 (file)
index ed5fbec..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_COND_WAIT_H_
-#define _PPU_COND_WAIT_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "mutex_lock.h"
-#include "mutex_unlock.h"
-#include "cond.h"
-
-static __inline void _cond_wait (cond_ea_t cond, mutex_ea_t  mutex)
-{
-  int delta, cur_delta;
-  unsigned int val, cond_val, signaled_cnt;
-  void *p;
-
-
-  SYNC_ULL_TO_PTR(cond, p);
-
-  /* Atomically signal we have entered the condition wait by incrementing
-   * the waiting count.
-   */
-  do {
-    val = __lwarx(p);
-    val = (val & ~0xFFFF) | ((val+1) & 0xFFFF);
-  } while (__stwcx(p, val) == 0);
-
-
-  /* Release the lock
-   */
-  _mutex_unlock (mutex);
-
-  /* Determine the signal count needed for this 
-   * participant to be signaled.
-   */
-
-  signaled_cnt = val >> 16;
-  delta = (int)(val & 0xFFFF) - (int)signaled_cnt;
-  if (delta < 0) delta = -delta;
-
-  /* Wait until the signaled count reaches the count
-   * previously determined.
-   */
-  do {
-    cond_val = __lwarx(p);
-
-    cur_delta = (int)(cond_val >> 16) - signaled_cnt;
-    if (cur_delta < 0) cur_delta = -cur_delta;
-   
-  } while (cur_delta < delta);
-
-  /* Relock the mutex 
-   */
-  _mutex_lock (mutex);
-}
-
-#endif /* _PPU_COND_WAIT_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/init_completion.h b/gcell/src/ibm/sync/ppu_source/init_completion.h
deleted file mode 100644 (file)
index 8e70811..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_INIT_COMPLETION_H_
-#define _PPU_INIT_COMPLETION_H_
-
-#include "sync_utils.h"
-#include "completion.h"
-
-/**
- * completion_init - initialize completion variable.
- * @completion: handle to effective address of completion variable.
- *
- * Description: Initialize a completion variable to 0.
- */
-static __inline void _init_completion(completion_ea_t comp)
-{
-  volatile unsigned int *p;
-
-  SYNC_ULL_TO_PTR(comp, p);
-
-  *p = 0;
-}
-
-
-#endif /* _PPU_INIT_COMPLETION_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/libsync.h b/gcell/src/ibm/sync/ppu_source/libsync.h
deleted file mode 100644 (file)
index bd2e043..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_LIBSYNC_H_
-#define _PPU_LIBSYNC_H_
-
-#include "sync_utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef unsigned long long atomic_ea_t;
-
-extern void atomic_set(atomic_ea_t v, int val);
-extern void atomic_add(int a, atomic_ea_t v);
-extern void atomic_sub(int a, atomic_ea_t v);
-extern void atomic_inc(atomic_ea_t v);
-extern void atomic_dec(atomic_ea_t v);
-
-extern int atomic_read(atomic_ea_t v);
-extern int atomic_add_return(int a, atomic_ea_t v);
-extern int atomic_sub_return(int a, atomic_ea_t v);
-extern int atomic_inc_return(atomic_ea_t v);
-extern int atomic_dec_return(atomic_ea_t v);
-extern int atomic_sub_and_test(int a, atomic_ea_t v);
-extern int atomic_dec_and_test(atomic_ea_t v);
-extern int atomic_dec_if_positive(atomic_ea_t v);
-
-typedef unsigned long long mutex_ea_t;
-void mutex_init(mutex_ea_t lock);
-
-void mutex_lock(mutex_ea_t lock);
-int mutex_trylock(mutex_ea_t ea);
-void mutex_unlock(mutex_ea_t lock);
-
-typedef struct
-{
-  int num_threads_signal;       /* the number of threads that are going to be waken up.
-                                 There are 3 values possible for this parameter, 0, 1, 
-                                 or num_threads_waiting*/
-  int num_threads_waiting;      /* the number of threads that are waiting to be awaken */ 
-} condition_variable_t __attribute__ ((aligned (16)));  
-
-typedef unsigned long long cond_ea_t;         /* a system memory 64 bit address that points to
-                                 * a valid condition_variable_t */
-
-typedef union {
-    unsigned long long ull;  
-    unsigned int ui[2];
-} val64;
-
-
-void cond_init (cond_ea_t  cond);
-void cond_signal (cond_ea_t cond);
-void cond_broadcast (cond_ea_t cond);
-void cond_wait (cond_ea_t cond, mutex_ea_t  mutex);
-
-
-#define MAX_THREADS_WAITING   32000 
-
-typedef unsigned long long completion_ea_t;
-
-extern void init_completion(completion_ea_t comp);
-extern void wait_for_completion(completion_ea_t comp);
-/*
-extern void wait_for_completion_irq(completion_ea_t comp);
-extern void wait_for_completion_irqsave(completion_ea_t comp);
-*/
-extern void complete_all(completion_ea_t comp);
-extern void complete (completion_ea_t comp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PPU_LIBSYNC_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/mutex.h b/gcell/src/ibm/sync/ppu_source/mutex.h
deleted file mode 100644 (file)
index 364bb22..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_MUTEX_H_
-#define _PPU_MUTEX_H_           1
-
-typedef unsigned long long mutex_ea_t;
-
-#endif /* _PPU_MUTEX_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/mutex_init.h b/gcell/src/ibm/sync/ppu_source/mutex_init.h
deleted file mode 100644 (file)
index 105dc2c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_MUTEX_INIT_H_
-#define _PPU_MUTEX_INIT_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include "trace_libsync.h"
-
-/***************************************************************************/
-/**
- * mutex_init - initialize the mutex by setting the value 
- * to 0.
- * @lock: handle to effective address of lock variable.
- *
- * Description: Initialize a mutex.
- */
-static __inline void _mutex_init(mutex_ea_t lock)
-{
-  volatile unsigned int *p;
-
-  SYNC_ULL_TO_PTR(lock, p);
-
-  *p = 0;
-
-  TRACE_MUTEX_INIT(lock);
-}
-
-#endif /* _PPU_MUTEX_INIT_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/mutex_lock.h b/gcell/src/ibm/sync/ppu_source/mutex_lock.h
deleted file mode 100644 (file)
index 75240a1..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_MUTEX_LOCK_H_
-#define _PPU_MUTEX_LOCK_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "mutex.h"
-#include "trace_libsync.h"
-
-/* function:   _mutex_lock
- *
- * Aquire a lock at a location in system memory by waiting for the
- * value to become zero, then atomically storing 1. 
- */
-static __inline void _mutex_lock (mutex_ea_t lock)
-{
-  unsigned int done = 0;
-  void *p;
-#ifdef LIBSYNC_TRACE
-  unsigned int miss = 0;
-#endif /* LIBSYNC_TRACE */
-
-  TRACE_MUTEX_LOCK_ENTRY(interval);
-
-  SYNC_ULL_TO_PTR(lock, p);
-
-  do {
-    if (__lwarx(p) == 0) done = __stwcx(p, (unsigned int) 1);
-#ifdef LIBSYNC_TRACE
-    /* if we missed the lock, note it.. */
-    if (done == 0) miss = 1;
-#endif
-  } while (done == 0);
-  __isync();
-
-  TRACE_MUTEX_LOCK_EXIT(interval, lock, miss);
-}
-
-#endif /* _PPU_MUTEX_LOCK_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/mutex_trylock.h b/gcell/src/ibm/sync/ppu_source/mutex_trylock.h
deleted file mode 100644 (file)
index 445196c..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_MUTEX_TRYLOCK_H_
-#define _PPU_MUTEX_TRYLOCK_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "mutex.h"
-#include "trace_libsync.h"
-
-/**
- * mutex_trylock - acquire a lock, or return immediately.
- * @lock: handle to effective address of lock variable.
- *
- * Description: Acquire a lock, or return immediately 
- * without polling for availability.
- *
- * Context: The application should not call this interface 
- * from a tight loop!!  Use spin_lock() instead.
- *
- * Attempt to immediately aquire a lock at a location in system memory,
- * and return 1 if the lock was aquired or 0 otherwise.
- */
-static __inline int _mutex_trylock (mutex_ea_t lock)
-{
-  int val;
-  int ret = 0;
-  void *p;
-
-  SYNC_ULL_TO_PTR(lock, p);
-
-  do {
-    val = (int)__lwarx(p);
-    if (val) break;
-  } while ((ret = __stwcx(p, (unsigned int)1)) == 0);
-  __isync();
-
-  TRACE_MUTEX_TRYLOCK(lock,ret);
-
-  return (ret);
-}
-
-#endif /* _PPU_MUTEX_TRYLOCK_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/mutex_unlock.h b/gcell/src/ibm/sync/ppu_source/mutex_unlock.h
deleted file mode 100644 (file)
index e5255be..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_MUTEX_UNLOCK_H_
-#define _PPU_MUTEX_UNLOCK_H_
-
-#include "mutex.h"
-#include "atomic.h"
-#include "trace_libsync.h"
-
-/* function:   _mutex_unlock
- *
- * Release a lock held at address 'lock' in system memory.
- * For the PU, this routine is the same _unlock, and is 
- * provided here as a simple convenience for programmers 
- * (to match the interfaces that are supported on the SPU).
- * All I need to do is a store since store is an atomic operation by itself 
- */
-static __inline void _mutex_unlock (mutex_ea_t lock)
-{
-  _atomic_replace ((atomic_ea_t)lock, 0);
-
-  TRACE_MUTEX_UNLOCK(lock); 
-}
-
-
-#endif /* _PPU_MUTEX_UNLOCK_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/pdt_libsync.xml b/gcell/src/ibm/sync/ppu_source/pdt_libsync.xml
deleted file mode 100644 (file)
index d9ea2ce..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-<pdtGroup name="LIBSYNC" id="0x03" version="3.0">
-       <!-- PPE events -->
-       <subGroup  name="PPE_MUTEX" id="0xFE03">
-               <recordType name="PPE_MUTEX_INIT" description="PPE: mutex lock init" id="0x0003" type="event">
-                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
-                       <physicalField name="lock"  description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>   
-               <recordType name="PPE_MUTEX_LOCK" description="PPE: acquire a mutex lock" id="0x0103"  type="interval">
-                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
-                       <physicalField name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField name="miss"   description="Missed" type="int" toString="0x%x" visible="true"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>
-               <recordType name="PPE_MUTEX_TRYLOCK" description="PPE: try to acquire a lock" id="0x0203"  type="event">
-                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
-                       <physicalField name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField  name="ret" description="Try lock return code" type="int" toString="0x%x" visible="true"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>   
-               <recordType name="PPE_MUTEX_UNLOCK" description="PPE: unlock a mutex lock" id="0x0303"  type="event">
-                       <include href="/usr/share/pdt/config/pdt_ppe_event_header.xml"/>
-                       <physicalField  name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>
-       </subGroup>
-       <!-- SPE events -->
-       <subGroup  name="SPE_MUTEX" id="0xFD03">
-               <recordType name="SPE_MUTEX_INIT" description="SPE: mutex lock init" id="0x0403"  type="event">
-                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
-                       <physicalField  name="lock"  description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>   
-               <recordType name="SPE_MUTEX_LOCK" description="SPE: acquire a mutex lock" id="0x0503"  type="interval">
-                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
-                       <physicalField name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField name="miss"   description="Missed" type="int" toString="0x%x" visible="true"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>
-               <recordType name="SPE_MUTEX_TRYLOCK" description="SPE: try to acquire a mutex lock" id="0x0603"  type="event">
-                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
-                       <physicalField  name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField  name="ret_val" description="Try lock return code" type="int" toString="0x%x" visible="true"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>   
-               <recordType name="SPE_MUTEX_UNLOCK" description="SPE: unlock a mutex lock" id="0x0703"  type="event">
-                       <include href="/usr/share/pdt/config/pdt_spe_event_header.xml"/>
-                       <physicalField  name="lock" description="Lock address" type="long" toString="0x%x" visible="true"/>
-                       <physicalField name="empty3"   description="empty slot 3" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty4"   description="empty slot 4" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty5"   description="empty slot 5" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty6"   description="empty slot 6" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty7"   description="empty slot 7" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty8"   description="empty slot 8" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty9"   description="empty slot 9" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty10"   description="empty slot 10" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty11"   description="empty slot 11" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty12"   description="empty slot 12" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty13"   description="empty slot 13" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty14"   description="empty slot 14" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty15"   description="empty slot 15" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty16"   description="empty slot 16" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty17"   description="empty slot 17" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty18"   description="empty slot 18" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty19"   description="empty slot 19" type="int" toString="0x%x" visible="false"/>
-                       <physicalField name="empty20"   description="empty slot 20" type="int" toString="0x%x" visible="false"/>
-               </recordType>   
-       </subGroup>
-</pdtGroup>
diff --git a/gcell/src/ibm/sync/ppu_source/pdt_libsync_config.xml b/gcell/src/ibm/sync/ppu_source/pdt_libsync_config.xml
deleted file mode 100644 (file)
index a0b848d..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<pdt_configuration application_name="libsync" output_dir="." version="3.0">
-       <groups>
-               <group name="GENERAL" description="General event types" id="0x00">
-                       <view yStart="0.0" yEnd="0.2" color="0x0000FF"/>
-                       <include href="/usr/share/pdt/config/pdt_general.xml"/>
-               </group>
-               <group name="LIBSPE2" description="CBE libspe 2.0 event types" id="0x01">
-                       <view yStart="0.2" yEnd="0.4" color="0x00FFFF"/>
-                       <include href="/usr/share/pdt/config/pdt_libspe2.xml"/>
-               </group>
-               <group name="MFCIO" description="SPE MFCIO event types" id="0x02">
-                       <view yStart="0.4" yEnd="0.6" color="0x00FF80"/>
-                       <include href="/usr/share/pdt/config/pdt_mfcio.xml"/>
-               </group>
-               <group name="LIBSYNC" description="General event types" id="0x03">
-                       <view yStart="0.6" yEnd="0.8" color="0xFFFF00"/>                        
-                       <include href="/usr/share/pdt/config/pdt_libsync.xml"/>
-               </group>
-       </groups>
-<configuration name="CBE">
-<host name="none"/>
-<groupsControl>
-       <group name="GENERAL" active="true">            
-               <profile active="false"/>
-               <!--  The GENERAL group of events are always active-->
-       </group> 
-       <group name="LIBSPE2" active="true">
-       </group>
-       <group name="LIBSYNC" active="true">                    
-               <sub_group name="PPE_MUTEX" active="true">
-                       <event name="PPE_MUTEX_INIT" active="true"/>
-                       <event name="PPE_MUTEX_LOCK" active="true"/>
-                       <event name="PPE_MUTEX_TRYLOCK" active="true"/>
-                       <event name="PPE_MUTEX_UNLOCK" active="true"/>
-               </sub_group>
-       </group>
-</groupsControl>
-</configuration>
-<!-- -->
-<!-- SPEs configuration - this section is read with the CBE configuration -->
-<!-- -->
-<configuration name="SPE">
-<host name="CBE"/>
-<groupsControl>
-       <group name="GENERAL" active="true">                    
-               <profile active="false"/>
-               <!--  The GENERAL group of events are always active-->
-       </group>
-       <group name="MFCIO" active="true">
-       </group>
-       <group name="LIBSYNC" active="true">                    
-               <sub_group name="SPE_MUTEX" active="true">
-                       <event name="SPE_MUTEX_INIT" active="true"/>
-                       <event name="SPE_MUTEX_LOCK" active="true"/>
-                       <event name="SPE_MUTEX_TRYLOCK" active="true"/>
-                       <event name="SPE_MUTEX_UNLOCK" active="true"/>
-               </sub_group>
-       </group>                        
-</groupsControl>
-</configuration>
-</pdt_configuration>
diff --git a/gcell/src/ibm/sync/ppu_source/sync_utils.h b/gcell/src/ibm/sync/ppu_source/sync_utils.h
deleted file mode 100644 (file)
index c7120a3..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _PPU_SYNC_UTILS_H_
-#define _PPU_SYNC_UTILS_H_      1
-
-/* SYNC_ULL_TO_PTR - convert a 64-bit unsigned long long to a void 
- *                   pointer.
- */
-#ifdef __powerpc64__
-
-#define SYNC_ULL_TO_PTR(_ull, _ptr) {          \
-  union {                                      \
-    void *ptr;                                 \
-    unsigned long long ull;                    \
-  } _x;                                                \
-                                               \
-  _x.ull = _ull;                               \
-  _ptr = _x.ptr;                               \
-}
-
-#else
-
-#define SYNC_ULL_TO_PTR(_ull, _ptr) {          \
-  union {                                      \
-    void *ptr[2];                              \
-    unsigned long long ull;                    \
-  } _x;                                                \
-                                               \
-  _x.ull = _ull;                               \
-  _ptr = _x.ptr[1];                            \
-}
-
-#endif
-
-#endif /* _PPU_SYNC_UTILS_H_ */
diff --git a/gcell/src/ibm/sync/ppu_source/trace_libsync.h b/gcell/src/ibm/sync/ppu_source/trace_libsync.h
deleted file mode 100644 (file)
index 6d6f036..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2007                                               */
-/* International Business Machines Corporation                     */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef __LIBSYNC_PPU_TRACEHOOKS_H__
-#define __LIBSYNC_PPU_TRACEHOOKS_H__
-
-#ifdef LIBSYNC_TRACE
-
-#include <trace_events.h>
-
-/*
- *  last parameter in the trace_even and trace_interval_entry call is
- *   the stack level to report the PC in the trace record. so 0 means
- *   the PC of the current frame, 1 means the PC of the caller, etc.
- *   there's a dilemma here - these macros are included in the inline
- *   _mutex calls which get called from the (created during build)
- *   mutex functions in the mutex .c files. in that case, the level
- *   should be 1 - we don't want the PC of where in the mutex function
- *   the trace call is happening, we want the PC of whomever is calling
- *   the mutex function.
- *
- *   but.. an app can call the inline functions - it can #include the
- *   appropriate libsync mutex .h files, and call the inlined _mutex
- *   function in their code. in that case, the appropriate level for the
- *   trace calls would be 0 - the user would want to know where in their
- *   code the call to the _mutex function is.
- *
- *   so, we'll assume _LEVEL of 0 which is what the inline funtions need.
- *   when we build the files for libsync, we'll do a -D_LEVEL=1 
- */
-#ifndef _LEVEL
-#define _LEVEL 0
-#endif
-
-
-#define TRACE_EVENT_MUTEX_INIT 0x0003
-
-#define TRACE_MUTEX_INIT(lock) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(uint64_t)lock; \
-  trace_event(TRACE_EVENT_MUTEX_INIT, 1, &payload, "Event=%d, lock=0x%x",_LEVEL); \
-}
-
-#define TRACE_EVENT_MUTEX_LOCK 0x0103
-
-#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL) \
-trace_interval_p _INTERVAL = trace_interval_entry(TRACE_EVENT_MUTEX_LOCK, _LEVEL)
-
-#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(uint64_t)lock; \
-  payload.word[2]=(uint32_t)miss; \
-  trace_interval_exit(_INTERVAL, 2,  &payload, "Event=%d, lock=0x%x, miss=0x%x"); \
-}
-
-#define TRACE_EVENT_MUTEX_TRYLOCK 0x0203
-
-#define TRACE_MUTEX_TRYLOCK(lock,ret) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(uint64_t)lock; \
-  payload.word[2]=(uint32_t)ret; \
-  trace_event(TRACE_EVENT_MUTEX_TRYLOCK, 2, &payload, "Event=%d, lock=0x%x, ret=0x%x", _LEVEL); \
-}
-
-#define TRACE_EVENT_MUTEX_UNLOCK 0x0303
-
-#define TRACE_MUTEX_UNLOCK(lock) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(uint64_t)lock; \
-  trace_event(TRACE_EVENT_MUTEX_UNLOCK, 1, &payload, "Event=%d, lock=0x%x", _LEVEL); \
-}
-
-#else /* LIBSYNC_TRACE */
-
-#define TRACE_MUTEX_INIT(lock)
-#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL)
-#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss)
-#define TRACE_MUTEX_TRYLOCK(lock,ret_val)
-#define TRACE_MUTEX_UNLOCK(lock)
-
-#endif /* LIBSYNC_TRACE */
-
-#endif  /* __LIBSYNC_PPU_TRACEHOOKS_H__ */
diff --git a/gcell/src/ibm/sync/ppu_source/wait_for_completion.h b/gcell/src/ibm/sync/ppu_source/wait_for_completion.h
deleted file mode 100644 (file)
index f2b0427..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-
-#ifndef _PPU_WAIT_FOR_COMPLETION_H_
-#define _PPU_WAIT_FOR_COMPLETION_H_
-
-#include <ppu_intrinsics.h>
-#include "sync_utils.h"
-#include "completion.h"
-
-
-/**
- * completion_wait - wait until a completion is broadcast.
- * @comp: handle to effective address of completion variable.
- *
- * Description: Wait until another processor or device signals
- * that a completionition is 'true'.  The only restriction here is 
- * that @comp must be a word aligned address.
- *
- * Beware: This function hot polls waiting for completion.
- */
-static __inline void _wait_for_completion(completion_ea_t comp)
-{
-  int val;
-  void *p;
-
-  SYNC_ULL_TO_PTR(comp, p);
-
-  do {
-    val = (int)__lwarx(p);
-    if (val != 1) val = (int)__stwcx(p, (unsigned int)0);
-  } while (val == 0);
-  __isync();
-}
-
-
-#endif /* _PPU_WAIT_FOR_COMPLETION_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic.h b/gcell/src/ibm/sync/spu_source/atomic.h
deleted file mode 100644 (file)
index 951c26e..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-/*
- * atomic.h - SPU atomic SHM counter operations.
- *
- * Interfaces patterned after, and hopefully compatible
- * with PowerPC64-Linux atomic counter operations.  Uses
- * 32b values for various counters.
- */
-#ifndef _SPU_ATOMIC_H_
-#define _SPU_ATOMIC_H_
-
-#include <sync_utils.h>
-#include <spu_mfcio.h>
-
-
-/* atomic_eaddr_t is a 64bit effective address 
- * that points to an atomic_t variable */
-typedef unsigned long long atomic_ea_t;
-
-#define DECL_ATOMIC_VARS()                              \
-    char _tmp[256];                                    \
-    char *tmp = (char *) ALIGN(_tmp, 128);             \
-    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
-    u32 size = 128, tagid = 0;                          \
-    s32 ret_val;                                       \
-    u32 offset;                                         \
-    addr64 ea64
-
-/* __atomic_op                                              
-*    Internal routine to acquire lock line reservation
-*    then conditionally modify the counter variable 
-*    pointed to by 'v'.  The 'replace' flag indicates 
-*    whether or not this is to be an arithmetic R-M-W
-*    or a simple replace operation.
-*/
-#define ATOMIC_OP(__v, __val, __replace, __final_val)           \
-{                                                               \
-    char __tmp[256];                                            \
-    char *_tmp = (char *) ALIGN(__tmp, 128);                   \
-    volatile s32 *_buf = (volatile s32 *) &_tmp[0];             \
-    u32 _size = 128, _tagid = 0;                                \
-    s32 _status, _ret_val;                                      \
-    u32 _offset;                                                \
-    addr64 _ea64;                                               \
-                                                                \
-    _ea64.ull = ALIGN128_EA(__v);                               \
-    _offset = OFFSET128_EA_U32(__v);                            \
-    do {                                                        \
-       MFC_DMA(_buf, _ea64, _size, _tagid, MFC_GETLLAR_CMD);   \
-        spu_readch (MFC_RdAtomicStat);                          \
-                                                                \
-       _ret_val = _buf[_offset];                                \
-       _buf[_offset] = (__replace) ? __val : _ret_val + __val;    \
-       MFC_DMA(_buf, _ea64, _size, _tagid, MFC_PUTLLC_CMD);    \
-       _status = spu_readch(MFC_RdAtomicStat);                  \
-    } while (_status != 0);                                     \
-                                                                \
-    __final_val = _ret_val;                                     \
-}                                                               
-
-#endif /* _SPU_ATOMIC_H_ */
-
diff --git a/gcell/src/ibm/sync/spu_source/atomic_add.h b/gcell/src/ibm/sync/spu_source/atomic_add.h
deleted file mode 100644 (file)
index 7606ae0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_ADD_H_
-#define _SPU_ATOMIC_ADD_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_add - atomically add to a counter.
- * @v: handle to effective address of counter.
- * @a: value to be added.
- * 
- * Atomically add a value to a counter in system memory. 
- * The only restriction is that @v must be word aligned.
- */
-static __inline void _atomic_add(int a, atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP (v, a, 0, ret_val);
-}
-
-
-#endif /* _SPU_ATOMIC_ADD_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_add_return.h b/gcell/src/ibm/sync/spu_source/atomic_add_return.h
deleted file mode 100644 (file)
index 35f07ad..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_ADD_RETURN_H_
-#define _SPU_ATOMIC_ADD_RETURN_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-/**
- * atomic_add_return - atomically add to a counter and return previous value.
- * @v: handle to effective address of counter.
- * @a: value to be added.
- *
- * Atomically add a value to a counter in system memory.
- * The only restriction is that @v must be word aligned.
- *
- * This routine implements the "fetch and add" primitive
- * that is described in "Book I PowerPC User Instruction
- * Set Architecture", but uses MFC lock line reservation
- * operations instead of lwarx/stwcx.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_add_return(int a, atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP(v, a, 0, ret_val);
-    return ret_val;
-}
-
-
-#endif /* _SPU_ATOMIC_ADD_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_dec.h b/gcell/src/ibm/sync/spu_source/atomic_dec.h
deleted file mode 100644 (file)
index 30ca7c5..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_DEC_H_
-#define _SPU_ATOMIC_DEC_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_dec - atomically decrement a counter.
- * @v: handle to effective address of location to be modified.
- *
- * Atomically decrement a counter in system memory. The only
- * restriction is that @v must be word aligned.
- */
-static __inline void _atomic_dec(atomic_ea_t v)
-{    
-    int ret_val;
-    ATOMIC_OP (v, -1, 0, ret_val);
-}
-
-
-#endif /* _SPU_ATOMIC_DEC_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_dec_and_test.h b/gcell/src/ibm/sync/spu_source/atomic_dec_and_test.h
deleted file mode 100644 (file)
index b3c8298..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_DEC_AND_TEST_H_
-#define _SPU_ATOMIC_DEC_AND_TEST_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_dec_and_test - atomically decrement and test if previous==0.
- * @v: handle to effective address of counter.
- *
- * Atomically decrement a counter in system memory and test 
- * if previous==0.  The only restriction is that @v must be 
- * word aligned.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_dec_and_test(atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP(v, -1, 0, ret_val);
-    return (ret_val == 0) ? 1 : 0;
-}
-
-#endif /* _SPU_ATOMIC_DEC_AND_TEST_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_dec_if_positive.h b/gcell/src/ibm/sync/spu_source/atomic_dec_if_positive.h
deleted file mode 100644 (file)
index 2a01ec3..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_DEC_IF_POSITIVE_H_
-#define _SPU_ATOMIC_DEC_IF_POSITIVE_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_dec_if_positive - atomically decrement if counter is positive.
- * @v: handle to effective address of counter.
- * 
- * Atomically decrement a counter if its value is positive.
- * The only restriction is that @v must be word aligned.
- *
-*
- * Returns the old value of the counter, minus 1.
- */
-static __inline int _atomic_dec_if_positive(atomic_ea_t v)
-{
-    DECL_ATOMIC_VARS();
-    s32 status;
-
-    ea64.ull = ALIGN128_EA(v);
-    offset = OFFSET128_EA_U32(v);
-    do {
-       MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-       spu_readch(MFC_RdAtomicStat);
-
-       ret_val = buf[offset] - 1;
-       if (likely(ret_val >= 0)) {
-           buf[offset] = ret_val;
-           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
-           status = spu_readch(MFC_RdAtomicStat);
-       } else {
-           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
-           spu_readch(MFC_RdAtomicStat);
-           status = 0;
-           break;
-       }
-    } while (status != 0);
-
-    return ret_val;
-}
-
-
-
-#endif /* _SPU_ATOMIC_DEC_IF_POSITIVE_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_dec_return.h b/gcell/src/ibm/sync/spu_source/atomic_dec_return.h
deleted file mode 100644 (file)
index 45effb6..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_DEC_RETURN_H_
-#define _SPU_ATOMIC_DEC_RETURN_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_dec_return - atomically decrement a counter and return previous value.
- * @v: handle to effective address of counter.
- *
- * Atomically decrement a counter in system memory and return its
- * previous value. The only restriction is that @v must be word 
- * aligned.
- *
- * This routine implements the "fetch and decrement"
- * primitive that is described in "Book I PowerPC User
- * Instruction Set Architecture", but uses MFC lock line
- * reservation operations instead of lwarx/stwcx.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_dec_return(atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP(v, -1, 0, ret_val);
-    return ret_val;
-}
-
-
-#endif /* _SPU_ATOMIC_DEC_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_inc.h b/gcell/src/ibm/sync/spu_source/atomic_inc.h
deleted file mode 100644 (file)
index 6800efe..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_INC_H_
-#define _SPU_ATOMIC_INC_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_inc - atomically increment a counter in system memory.
- * @v: handle to effective address of counter.
- *
- * Atomically increment a counter in system memory.
- * The only restriction is that @v must be word aligned.
- */
-static __inline void _atomic_inc(atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP (v, 1, 0, ret_val);
-}
-
-
-#endif /* _SPU_ATOMIC_INC_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_inc_return.h b/gcell/src/ibm/sync/spu_source/atomic_inc_return.h
deleted file mode 100644 (file)
index 89361a0..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_INC_RETURN_H_
-#define _SPU_ATOMIC_INC_RETURN_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-
-/**
- * atomic_inc_return - atomically increment a counter and return previous.
- * @v: handle to effective address of counter.
- *
- * Atomically increment a counter in system memory.
- * The only restriction is that @v must be word aligned.
- *
- * This routine implements the "fetch and increment"
- * primitive that is described in "Book I PowerPC User
- * Instruction Set Architecture", but uses MFC lock line
- * reservation operations instead of lwarx/stwcx.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_inc_return(atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP(v, 1, 0, ret_val);
-    return ret_val;
-}
-
-
-#endif /* _SPU_ATOMIC_INC_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_read.h b/gcell/src/ibm/sync/spu_source/atomic_read.h
deleted file mode 100644 (file)
index 711a0ad..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_READ_H_
-#define _SPU_ATOMIC_READ_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_read - read an atomic counter.
- * @v: handle to effective address of counter.
- *
- * Read the current value of an atomic counter.
- */
-static __inline int _atomic_read(atomic_ea_t v)
-{
-    DECL_ATOMIC_VARS();
-
-    /* reserve a tag for use */
-    tagid = mfc_tag_reserve();
-
-    u32 oldtmask, tagmask = 1 << (tagid & 31);
-
-    ea64.ull = ALIGN128_EA(v);
-    offset = OFFSET128_EA_U32(v);
-
-    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
-    oldtmask = spu_readch(MFC_RdTagMask);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-    spu_writech(MFC_WrTagMask, oldtmask);
-
-    mfc_tag_release (tagid);
-    ret_val =  buf[offset];
-    return ret_val;
-}
-
-
-#endif /* _SPU_ATOMIC_READ_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_set.h b/gcell/src/ibm/sync/spu_source/atomic_set.h
deleted file mode 100644 (file)
index 261d28a..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_SET_H_
-#define _SPU_ATOMIC_SET_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_set - atomically set a counter in system memory.
- * @v: handle to effective address of counter.
- * 
- * Atomically set a counter to a given value. The only 
- * restriction is that @v must be word aligned.
- *
- * This routine implements the "fetch and store" 
- * primitive that is described in "Book I PowerPC User 
- * Instruction Set Architecture", but uses MFC lock line
- * reservation operations instead of lwarx/stwcx. 
- *
- * Returns the previous value from system memory.
- */
-static __inline void _atomic_set(atomic_ea_t v, int val)
-{
-    int ret_val;
-    ATOMIC_OP(v, val, 1, ret_val);
-}
-
-
-#endif /* _SPU_ATOMIC_SET_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_sub.h b/gcell/src/ibm/sync/spu_source/atomic_sub.h
deleted file mode 100644 (file)
index f366e1d..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_SUB_H_
-#define _SPU_ATOMIC_SUB_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_sub - atomically subtract from a counter.
- * @v: handle to effective address of counter.
- * @a: value to be subtracted.
- *
- * Atomically subtract a value from a counter in system memory.
- * The only restriction is that @v must be word aligned.
- */
-static __inline void _atomic_sub(int a, atomic_ea_t v)
-{
-    int ret_val;
-
-    ATOMIC_OP (v, -a, 0, ret_val);
-}
-
-
-
-#endif /* _SPU_ATOMIC_SUB_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_sub_and_test.h b/gcell/src/ibm/sync/spu_source/atomic_sub_and_test.h
deleted file mode 100644 (file)
index fe5824a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_SUB_AND_TEST_H_
-#define _SPU_ATOMIC_SUB_AND_TEST_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-/**
- * atomic_sub_and_test - atomically subtract and test if previous==0.
- * @v: handle to effective address of counter.
- * @a: value to be subtracted.
- *
- * Atomically subtract a value from a counter in system memory
- * and test if previous==0.  The only restriction is that @v 
- * must be word aligned.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_sub_and_test(int a, atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP(v, -a, 0, ret_val);
-    return (ret_val == 0) ? 1 : 0;
-}
-
-
-#endif /* _SPU_ATOMIC_SUB_AND_TEST_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/atomic_sub_return.h b/gcell/src/ibm/sync/spu_source/atomic_sub_return.h
deleted file mode 100644 (file)
index 5dbed5b..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_ATOMIC_SUB_RETURN_H_
-#define _SPU_ATOMIC_SUB_RETURN_H_
-
-#include <sync_utils.h>
-#include <atomic.h>
-
-
-/**
- * atomic_sub_return - atomically subtract from a counter & return previous.
- * @v: handle to effective address of counter.
- * @a: value to be subtracted.
- *
- * Atomically subtract a value from a counter in system memory.
- * The only restriction is that @v must be word aligned.
- *
- * Returns the previous value from system memory.
- */
-static __inline int _atomic_sub_return(int a, atomic_ea_t v)
-{
-    int ret_val;
-    ATOMIC_OP(v, -a, 0, ret_val);
-    return ret_val;
-    //return __atomic_op(v, -a, 0);
-}
-
-
-
-
-#endif /* _SPU_ATOMIC_SUB_RETURN_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/complete.h b/gcell/src/ibm/sync/spu_source/complete.h
deleted file mode 100644 (file)
index 6a78086..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COMPLETE_H_
-#define _SPU_COMPLETE_H_
-
-#include "sync_utils.h"
-#include <spu_mfcio.h>
-#include "completion.h"
-
-static __inline void _complete(completion_ea_t completion)
-{
-    DECL_COMPLETION_VARS();
-
-    ea64.ull = ALIGN128_EA(completion);
-    offset = OFFSET128_EA_U32(completion);
-    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-    spu_readch(MFC_RdAtomicStat);
-
-    /* set the completionition variable to exactly one so
-     * only one thread can be awaken */
-    buf[offset] = 1;
-    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
-    spu_readch(MFC_RdAtomicStat);
-}
-
-
-
-
-#endif /* _SPU_COMPLETE_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/complete_all.h b/gcell/src/ibm/sync/spu_source/complete_all.h
deleted file mode 100644 (file)
index 5f9c3dc..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COMPLETE_ALL_H_
-#define _SPU_COMPLETE_ALL_H_
-
-#include "sync_utils.h"
-#include <spu_mfcio.h>
-#include "completion.h"
-
-/**
- * completion_broadcast - indicate that a completion is true.
- * @completion: handle to effective address of completion variable.
- *
- * Indicate that a completionition is true by storing '1' to the
- * completionition variable.
- */
-static __inline void _complete_all(completion_ea_t completion)
-{
-    DECL_COMPLETION_VARS();
-
-    ea64.ull = ALIGN128_EA(completion);
-    offset = OFFSET128_EA_U32(completion);
-    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-    spu_readch(MFC_RdAtomicStat);
-
-    /* set the completionition variable to the count. So that
-     * all the threads  */
-    buf[offset] = MAX_THREADS_WAITING;
-    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
-    spu_readch(MFC_RdAtomicStat);
-}
-
-
-
-
-#endif /* _SPU_COMPLETE_ALL_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/completion.h b/gcell/src/ibm/sync/spu_source/completion.h
deleted file mode 100644 (file)
index 4a302d2..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-/*
- * cond.h - simple condition wait & broadcast operations.
- *
- * Interrupt aware versions of the routines are supported.
- * Applications should call either '_irq' or '_irqsave'
- * forms of the functions when interrupts are enabled.
- */
-
-#ifndef __SPU_COMPLETION_H__
-#define __SPU_COMPLETION_H__
-
-#include "sync_utils.h"
-
-#define MAX_THREADS_WAITING   32000 
-typedef unsigned long long completion_ea_t;
-
-
-#define DECL_COMPLETION_VARS()                                \
-    char _tmp[256];                                     \
-    char *tmp = (char *) ALIGN(_tmp, 128);              \
-    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
-    u32 size = 128, tagid = 0;                          \
-    u32 offset;                                         \
-    addr64 ea64
-
-
-
-#endif /* __SPU_COMPLETION_H__ */
diff --git a/gcell/src/ibm/sync/spu_source/cond.h b/gcell/src/ibm/sync/spu_source/cond.h
deleted file mode 100644 (file)
index ceb3285..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COND_VAR_H_
-#define _SPU_COND_VAR_H_
-
-#include "sync_utils.h"
-typedef struct
-{
-  int num_threads_signal;       /* the number of threads that are going to be waken up.
-                                 There are 3 values possible for this parameter, 0, 1, 
-                                 or num_threads_waiting*/
-  int num_threads_waiting;      /* the number of threads that are waiting to be awaken */ 
-} condition_variable_t __attribute__ ((aligned (128)));  
-
-typedef eaddr_t cond_ea_t;         /* a system memory 64 bit address that points to
-                                 * a valid condition_variable_t */
-
-
-
-
-#define DECL_COND_VARS()                                \
-    char _tmp[256];                                     \
-    char *tmp = (char *) ALIGN(_tmp, 128);              \
-    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
-    u32 size = 128, tagid = 0;                          \
-    s32 status, ret_val;                                \
-    u32 offset;                                         \
-    addr64 ea64;                                        \
-    condition_variable_t cond_var
-
-#endif /* _SPU_COND_VAR_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/cond_broadcast.h b/gcell/src/ibm/sync/spu_source/cond_broadcast.h
deleted file mode 100644 (file)
index 15a1da3..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COND_BROADCAST_H_
-#define _SPU_COND_BROADCAST_H_
-
-#include "sync_utils.h"
-#include "cond.h"
-#include <spu_mfcio.h>
-
-/**
- * cond_broadcast - indicate that a condition is true.
- * @cond: handle to effective address of condition variable.
- */
-static __inline void _cond_broadcast(cond_ea_t cond)
-{
-    char _tmp[256];                                     
-    char *tmp = (char *) ALIGN(_tmp, 128);              
-    volatile unsigned short *buf = (volatile unsigned short *) &tmp[0];       
-    unsigned int size = 128, tagid = 0;                          
-    u32 offset;                                         
-    addr64 ea64;          
-
-    ea64.ull = ALIGN128_EA(cond);
-    offset = OFFSET128_EA_U16(cond);
-    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-    spu_readch(MFC_RdAtomicStat);
-
-    /* set the condition variable to the count. So that
-     * all the threads  */
-    buf[offset] = buf[offset + 1];
-    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
-    spu_readch(MFC_RdAtomicStat);
-}
-
-#endif /* _SPU_COND_BROADCAST_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/cond_init.h b/gcell/src/ibm/sync/spu_source/cond_init.h
deleted file mode 100644 (file)
index 7202e53..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COND_INIT_H_
-#define _SPU_COND_INIT_H_
-
-#include "sync_utils.h"
-#include "cond.h"
-#include <spu_mfcio.h>
-
-
-/**
- * cond_init - initialize condition variable.
- * @cond: handle to effective address of condition variable.
- *
- *
- * Conditional Variable - is a synchronization device that allows 
- * SPE and PPE threads to suspend execution and relinquish the 
- * processors until some predicate on shared data is satisfied. 
- * The basic operations on conditions are: signal the condition
- * (when the predicate becomes true), and wait for the condition,
- * suspending the thread execution until anoter thread signals the
- * condition
- *
- * A condition variable must always be associated with a mutex, to
- * avoid the race condition where a thread prepares to wait on a 
- * condition variable and another thread signals the condition just
- * before the first thread actually waits on it.
- *
- * cond_init initializes the condition variable cond. 
- *
- * cond_signal restarts one of the threads that are waiting on the
- * condition variable cond. If no threads are waiting on cond, nothing
- * happens. If several threads are waiting on cond, exactly one
- * is restarted, but it is not specified which
- *
- * cond_broadcast restarts all the threads that are waiting on the 
- * condition variable cond. Nothing happens if no threads are waiting
- * on cond
- *
- * cond_wait atomically unlocks the mutex and waits for the condition
- * variable cond to be signaled. The mutex must be lock locked by 
- * the calling thread on the entrance to cond_wait. Before returning
- * to the calling thread, cond_wait re-acquires mutex. 
- *
- * Only one thread initializes a condition variable. Usually, the 
- * PPE thread initializes a condidtion variable, however, a cond_init
- * function is provided here for completeness
- *
- * Description: Initialize a cond variable to false.
- */
-static __inline void _cond_init(cond_ea_t cond )
-{
-    char _tmp[256];                                     
-    char *tmp = (char *) ALIGN(_tmp, 128);              
-    volatile unsigned short *buf = (volatile unsigned short *) &tmp[0];       
-    unsigned int size = 128, tagid;                          
-    unsigned int offset;           
-    addr64 ea64;
-    unsigned int oldtmask;
-    unsigned int tagmask;    
-
-    tagid = mfc_tag_reserve(); 
-
-    tagmask = 1 << (tagid & 31);
-
-    ea64.ull = ALIGN128_EA(cond);
-    offset = OFFSET128_EA_U16(cond);
-
-    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
-    oldtmask = spu_readch(MFC_RdTagMask);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-
-    /* this is still just one word. since buf is of type
-     * short, we fit both counts into one word. */
-    buf[offset] = 0;
-    buf[offset+1] = 0;
-    MFC_DMA(buf, ea64, size, (tagid & 31), MFC_PUT_CMD);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-    spu_writech(MFC_WrTagMask, oldtmask);
-    mfc_tag_release (tagid);
-}
-
-
-
-#endif /* _SPU_COND_INIT_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/cond_signal.h b/gcell/src/ibm/sync/spu_source/cond_signal.h
deleted file mode 100644 (file)
index a035d28..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COND_SIGNAL_H_
-#define _SPU_COND_SIGNAL_H_
-#include <stdio.h>
-#include "sync_utils.h"
-#include "cond.h"
-#include "atomic.h"
-#include <spu_mfcio.h>
-
-/*
- * _cond_signal: signalling any of the waiting threads to wake up.
- */ 
-static __inline void _cond_signal(cond_ea_t cond)
-{
-    char _tmp[256];                                     
-    char *tmp = (char *) ALIGN(_tmp, 128);              
-    volatile unsigned short *buf = (volatile unsigned short *) &tmp[0];       
-    unsigned int size = 128, tagid = 0;                          
-    u32 offset;                                         
-    addr64 ea64;                                      
-    int status;
-
-    ea64.ull = ALIGN128_EA(cond);
-    offset = OFFSET128_EA_U16(cond);
-
-    do {
-      MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-      (void)spu_readch(MFC_RdAtomicStat);
-
-      /* Check for waiting threads.
-       */
-      if (buf[offset] != buf[offset+1]) {
-       /* Increment the signaled count to release the next waiting
-        * thread.
-        */
-       buf[offset]++;
-
-       MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
-       status = spu_readch(MFC_RdAtomicStat);
-      } else {
-       /* Nobody is waiting, do nothing.
-        */
-       status = 0;
-      }
-    } while (status);
-}
-
-
-#endif /* _SPU_COND_SIGNAL_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/cond_wait.h b/gcell/src/ibm/sync/spu_source/cond_wait.h
deleted file mode 100644 (file)
index cf4b880..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_COND_WAIT_H_
-#define _SPU_COND_WAIT_H_
-#include <stdio.h>
-#include "sync_irq.h"
-#include "sync_utils.h"
-#include "mutex_lock.h"
-#include "mutex_unlock.h"
-#include "cond.h"
-#include <spu_mfcio.h>
-
-static __inline void _cond_wait (cond_ea_t cond, mutex_ea_t  mutex)
-{
-    char _tmp[256];                                     
-    char *tmp = (char *) ALIGN(_tmp, 128);              
-    volatile signed short *buf = (volatile signed short *) &tmp[0];       
-    unsigned int size = 128, tagid = 0;                          
-    int status;                                
-    unsigned int offset;                                         
-    addr64 ea64;  
-    signed short delta, cur_delta, signaled_cnt;
-
-    ea64.ull = ALIGN128_EA(cond);
-    offset = OFFSET128_EA_U16(cond);
-
-    /* increment the waiting halfword of the condition variable.
-     */
-    do {
-      MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-      (void)spu_readch(MFC_RdAtomicStat);
-
-      buf[offset+1]++;
-      
-      MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
-      status = spu_readch(MFC_RdAtomicStat); 
-    } while (status);
-
-    _mutex_unlock(mutex);
-
-    /* keep track of the change in count needed to be signaled. This 
-     * is delta.
-     */
-    signaled_cnt = buf[offset];
-    delta = buf[offset+1] - signaled_cnt;
-    if (delta < 0) delta = -delta;
-
-    while (1) {
-      MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-      (void)spu_readch(MFC_RdAtomicStat);
-
-      cur_delta = buf[offset] - signaled_cnt;
-      if (cur_delta < 0) cur_delta = -cur_delta;
-
-
-      if (cur_delta >= delta) {
-       /* the counts indicate that this thread has been signaled.
-        */
-       break;
-      } 
-    } 
-    _mutex_lock (mutex);
-}
-
-#endif /* _SPU_COND_WAIT_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/init_completion.h b/gcell/src/ibm/sync/spu_source/init_completion.h
deleted file mode 100644 (file)
index bf93e72..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_INIT_COMPLETION_H_
-#define _SPU_INIT_COMPLETION_H_
-
-#include "sync_utils.h"
-#include <spu_mfcio.h>
-#include "completion.h"
-
-/**
- * completion_init - initialize completion variable.
- * @completion: handle to effective address of completion variable.
- *
- * Description: Initialize a completion variable to false.
- */
-static __inline void _init_completion(completion_ea_t completion)
-{
-    DECL_COMPLETION_VARS();
-    u32 oldtmask, tagmask;
-   
-    tagid = mfc_tag_reserve();
-    tagmask = 1 << (tagid & 31);
-
-    ea64.ull = ALIGN128_EA(completion);
-    offset = OFFSET128_EA_U32(completion);
-
-    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
-    oldtmask = spu_readch(MFC_RdTagMask);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-
-    buf[offset] = 0;
-    MFC_DMA(buf, ea64, size, tagid & 31, MFC_PUT_CMD);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-    spu_writech(MFC_WrTagMask, oldtmask);
-    mfc_tag_release(tagid);
-}
-
-
-
-#endif /* _SPU_INIT_COMPLETION_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/libsync.h b/gcell/src/ibm/sync/spu_source/libsync.h
deleted file mode 100644 (file)
index 48cc722..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_LIB_SYNC_H_
-#define _SPU_LIB_SYNC_H_
-#include "sync_utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef unsigned long long atomic_ea_t;
-
-extern void atomic_set(atomic_ea_t v, int val);
-extern void atomic_add(int a, atomic_ea_t v);
-extern void atomic_sub(int a, atomic_ea_t v);
-extern void atomic_inc(atomic_ea_t v);
-extern void atomic_dec(atomic_ea_t v);
-
-extern int atomic_read(atomic_ea_t v);
-extern int atomic_add_return(int a, atomic_ea_t v);
-extern int atomic_sub_return(int a, atomic_ea_t v);
-extern int atomic_inc_return(atomic_ea_t v);
-extern int atomic_dec_return(atomic_ea_t v);
-extern int atomic_sub_and_test(int a, atomic_ea_t v);
-extern int atomic_dec_and_test(atomic_ea_t v);
-extern int atomic_dec_if_positive(atomic_ea_t v);
-
-typedef unsigned long long mutex_ea_t;
-
-extern void mutex_init(mutex_ea_t lock);
-extern void mutex_lock(mutex_ea_t lock);
-extern int mutex_trylock(mutex_ea_t ea);
-extern void mutex_unlock(mutex_ea_t lock);
-
-
-typedef struct
-{
-  int num_threads_signal;       /* the number of threads that are going to be waken up.
-                                * There are 3 values possible for this parameter, 0, 1, 
-                                 * or num_threads_waiting
-                                */
-  int num_threads_waiting;      /* the number of threads that are waiting to be awaken 
-                                */ 
-} condition_variable_t __attribute__ ((aligned (128)));  
-
-typedef eaddr_t cond_ea_t;     /* a system memory 64 bit address that points to
-                                * a valid condition_variable_t 
-                                */
-
-
-extern void cond_init (cond_ea_t  cond);
-extern void cond_signal (cond_ea_t cond);
-extern void cond_broadcast (cond_ea_t cond);
-extern void cond_wait (cond_ea_t cond, mutex_ea_t  mutex);
-
-typedef unsigned long long completion_ea_t;
-
-extern void init_completion(completion_ea_t completion);
-extern void wait_for_completion(completion_ea_t completion);
-extern void complete(completion_ea_t completion);
-extern void complete_all(completion_ea_t completion);
-
-#ifdef __SPU__
-  /* Function only implemented for the SPU
-   */
-  extern void read_lock(eaddr_t ea);
-  extern void read_unlock(eaddr_t ea);
-  extern int  read_trylock(eaddr_t ea);
-  extern void write_lock(eaddr_t ea);
-  extern void write_unlock(eaddr_t ea);
-  extern int  write_trylock(eaddr_t ea);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SPU_LIB_SYNC_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/mutex.h b/gcell/src/ibm/sync/spu_source/mutex.h
deleted file mode 100644 (file)
index 37f2b4d..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_MUTEX_H_
-#define _SPU_MUTEX_H_           1
-
-#include "sync_utils.h"
-#include "sync_irq.h"
-#include <spu_mfcio.h>
-
-typedef eaddr_t mutex_ea_t;
-
-#define DECL_MUTEX_VARS()                               \
-    char _tmp[256];                                     \
-    char *tmp = (char *) ALIGN(_tmp, 128);              \
-    volatile s32 *buf = (volatile s32 *) &tmp[0];       \
-    u32 size = 128, tagid = 0;                          \
-    u32 offset;                                         \
-    addr64 ea64
-
-/* RAW_TEST_AND_SET
- *    Macro implementing the test and set primitive.
- *
- *    RAW_TEST_AND_SET(==, 1)  used by spin_try_lock()
- *    RAW_TEST_AND_SET(>=, 1)  used by read_try_lock()
- *    RAW_TEST_AND_SET(==, -1) used by write_try_lock()
- */
-#define RAW_TEST_AND_SET(_RELOP_, _val)                                \
-    ea64.ull = ALIGN128_EA(ea);                                        \
-    offset = OFFSET128_EA_U32(ea);                             \
-    do {                                                       \
-        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);      \
-        spu_readch(MFC_RdAtomicStat);                          \
-        SET_HIT;                                               \
-        if (likely(buf[offset] _RELOP_ 0)) {                   \
-            buf[offset] += _val;                               \
-           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);    \
-            status = spu_readch(MFC_RdAtomicStat);             \
-            ret_val = 1;                                       \
-        } else {                                               \
-           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);    \
-            spu_readch(MFC_RdAtomicStat);                      \
-            status = ret_val = 0;                              \
-            break;                                             \
-        }                                                      \
-    } while (status != 0)
-
-/* RAW_SPINLOCK
- *    Macro implementing the spinlock primitive.
- *
- *    RAW_SPINLOCK(==, 1)      used by spin_lock()
- *    RAW_SPINLOCK(>=, 1)      used by read_lock()
- *    RAW_SPINLOCK(==, -1)     used by write_lock()
- */
-
-
-#define RAW_SPINLOCK(_RELOP_, _val)                            \
-    ea64.ull = ALIGN128_EA(ea);                                        \
-    offset = OFFSET128_EA_U32(ea);                             \
-    do {                                                       \
-        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);      \
-        spu_readch(MFC_RdAtomicStat);                          \
-        SET_HIT;                                               \
-        status = 1;                                            \
-        if (likely(buf[offset] _RELOP_ 0)) {                   \
-            buf[offset] += _val;                               \
-           MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);    \
-            status = spu_readch(MFC_RdAtomicStat);             \
-        }                                                      \
-    } while (status != 0);
-
-
-static inline void _lock_init(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    u32 oldtmask, tagmask;
-  
-    tagid = mfc_tag_reserve(); 
-   
-    tagmask = 1 << (tagid & 31);
-
-    /* __lock_init
-     *    Internal routine to initialize a spinlock or
-     *    reader/writer lock.
-     */
-    ea64.ull = ALIGN128_EA(ea);
-    offset = OFFSET128_EA_U32(ea);
-    MFC_DMA(buf, ea64, size, tagid & 31, MFC_GET_CMD);
-    oldtmask = spu_readch(MFC_RdTagMask);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-
-    buf[offset] = 0;
-    MFC_DMA(buf, ea64, size, tagid & 31, MFC_PUT_CMD);
-    spu_writech(MFC_WrTagMask, tagmask);
-    spu_writech(MFC_WrTagUpdate, MFC_TAG_UPDATE_ANY);
-    spu_readch(MFC_RdTagStat);
-    spu_writech(MFC_WrTagMask, oldtmask);
-    mfc_tag_release(tagid);
-}
-
-static inline void _spin_lock(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status;
-
-    /* _spin_lock
-     *    Internal routine to acquire spinlock.
-     */
-/* non trace - no hit/miss indicator */
-#define SET_HIT
-    RAW_SPINLOCK(==, 1);
-}
-
-#ifdef LIBSYNC_TRACE
-static inline s32 _spin_lock_trace(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status = 0;
-/* trace - need hit/miss indicator */
-#undef SET_HIT
-#define SET_HIT        if (status == 0) hit = buf[offset]
-    s32 hit;
-
-    hit = 0;
-    /* _spin_lock_trace for trace
-     *    Internal routine to acquire spinlock.
-     */
-    RAW_SPINLOCK(==, 1);
-
-    return hit;
-
-#undef SET_HIT
-#define SET_HIT
-}
-
-#endif /* LIBSYNC_TRACE */
-
-
-#endif /* SPU_MUTEX_H */
diff --git a/gcell/src/ibm/sync/spu_source/mutex_init.h b/gcell/src/ibm/sync/spu_source/mutex_init.h
deleted file mode 100644 (file)
index 9bddb14..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_MUTEX_INIT_H_
-#define _SPU_MUTEX_INIT_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include "trace_libsync.h"
-
-/***************************************************************************/
-/**
- * mutex_init - initialize the mutex by setting the value 
- * to 0.
- * @lock: handle to effective address of lock variable.
- *
- * Description: Initialize a mutex.
- */
-static __inline void _mutex_init(mutex_ea_t lock)
-{
-   _lock_init(lock);
-
-   TRACE_MUTEX_INIT(lock);
-}
-
-
-#endif /* _SPU_MUTEX_INIT_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/mutex_lock.h b/gcell/src/ibm/sync/spu_source/mutex_lock.h
deleted file mode 100644 (file)
index 63bdbc3..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_MUTEX_LOCK_H_
-#define _SPU_MUTEX_LOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include "trace_libsync.h"
-
-static __inline void _mutex_lock(mutex_ea_t ea)
-{
-
-#ifdef LIBSYNC_TRACE
-   s32 miss = 0;
-
-   TRACE_MUTEX_LOCK_ENTRY(interval);
-   miss = _spin_lock_trace(ea);
-   TRACE_MUTEX_LOCK_EXIT(interval, ea, miss);
-
-#else /* LIBSYNC_TRACE */
-
-   _spin_lock(ea);
-
-#endif /* LIBSYNC_TRACE */
-
-}
-
-#endif /* _SPU_MUTEX_LOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/mutex_trylock.h b/gcell/src/ibm/sync/spu_source/mutex_trylock.h
deleted file mode 100644 (file)
index 3c8df46..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_MUTEX_TRYLOCK_H_
-#define _SPU_MUTEX_TRYLOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include "trace_libsync.h"
-
-/**
- * mutex_trylock - acquire a lock, or return immediately.
- * @ea: handle to effective address of lock variable.
- *
- * Description: Acquire a lock, or return immediately 
- * without polling for availability.
- *
- * Context: The application should not call this interface 
- * from a tight loop!!  Use spin_lock() instead.
- */
-static __inline int _mutex_trylock(mutex_ea_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status, ret_val;
-
-    RAW_TEST_AND_SET(==, 1);
-
-    TRACE_MUTEX_TRYLOCK(ea, ret_val);
-
-    return ret_val;
-}
-
-#endif /* _SPU_MUTEX_TRYLOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/mutex_unlock.h b/gcell/src/ibm/sync/spu_source/mutex_unlock.h
deleted file mode 100644 (file)
index 87d6bba..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_MUTEX_UNLOCK_H_
-#define _SPU_MUTEX_UNLOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include "atomic.h"
-#include "trace_libsync.h"
-
-static __inline void _mutex_unlock(mutex_ea_t ea)
-{
-    int ret_val;
-
-    ATOMIC_OP((atomic_ea_t)ea, 0, 1, ret_val);
-
-    TRACE_MUTEX_UNLOCK(ea);
-}
-
-
-#endif /* _SPU_MUTEX_UNLOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/read_lock.h b/gcell/src/ibm/sync/spu_source/read_lock.h
deleted file mode 100644 (file)
index 0e1d971..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_READ_LOCK_H_
-#define _SPU_READ_LOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-
-/**
- * read_lock - acquire reader lock, or spin until available.
- * @ea: handle to effective address of lock variable.
- *
- * Description: Acquire a non-exclusive reader lock, or spin 
- * until available.  The only restriction here is that @ea
- * must be word aligned.
- *
- * Context: This routine should not be called if SPU 
- * asynchronous interrupts are enabled.
- */
-static __inline void _read_lock(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status;
-
-    RAW_SPINLOCK(>=, 1);
-}
-
-#endif /* _SPU_READ_LOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/read_trylock.h b/gcell/src/ibm/sync/spu_source/read_trylock.h
deleted file mode 100644 (file)
index d032783..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_READ_TRYLOCK_H_
-#define _SPU_READ_TRYLOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-
-/**
- * read_trylock - acquire a reader lock, or return immediately.
- * @ea: handle to effective address of lock variable.
- *
- * Acquire a non-exclusive reader lock, or return
- * immediately.  The only restriction here is that
- * @ea must be word aligned.
- *
- * Returns 1 on success, or 0 on failure.
- *
- * Context: The application should not call this interface 
- * from a tight loop!!  Use read_lock() instead.
- */
-static __inline int _read_trylock(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status, ret_val;
-
-    RAW_TEST_AND_SET(>=, 1);
-
-    return ret_val;
-}
-
-
-#endif /* _SPU_READ_TRYLOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/read_unlock.h b/gcell/src/ibm/sync/spu_source/read_unlock.h
deleted file mode 100644 (file)
index f011550..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_READ_UNLOCK_H_
-#define _SPU_READ_UNLOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include <spu_mfcio.h>
-
-
-/**
- * read_unlock - release reader lock.
- * @ea: handle to effective address of lock variable.
- * 
- * Description: Release a reader lock.  The only restriction 
- * here is that @ea must be word aligned.
- *
- * Context: This routine should be used when interrupts
- * do not need to be re-enabled --either because interrupts
- * are not being used, or because the application will take
- * steps to re-enable them later.
- */
-static __inline void _read_unlock(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status;
-
-    /* _read_unlock
-     *
-     *    Reader locks must use PUTLLC when releasing, instead of
-     *    the more traditional PUTLLUC because of the non-exclusive
-     *    nature of the lock.  The reason for this is that other
-     *    readers may have incremented the counter, and we don't
-     *    want to corrupt it by blindly issuing PUTLLUC!!
-     */
-    ea64.ull = ALIGN128_EA(ea);
-    offset = OFFSET128_EA_U32(ea);
-    do {
-        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-        spu_readch(MFC_RdAtomicStat);
-
-        buf[offset] -= 1;
-        MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
-        status = spu_readch(MFC_RdAtomicStat);
-    } while (status != 0);
-
-}
-
-
-#endif /* _SPU_READ_UNLOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/rwlock_init.h b/gcell/src/ibm/sync/spu_source/rwlock_init.h
deleted file mode 100644 (file)
index 6b05533..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_RWLOCK_INIT_H_
-#define _SPU_RWLOCK_INIT_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-
-/**
- * rwlock_init - initialize a reader/writer lock.
- * @ea: handle to effective address of lock variable.
- *
- * Description: Initialize a reader/writer lock.
- */
-static __inline void _rwlock_init(eaddr_t rwlock)
-{
-    _lock_init(rwlock);
-}
-
-
-
-#endif /* _SPU_RWLOCK_INIT_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/sync_irq.h b/gcell/src/ibm/sync/spu_source/sync_irq.h
deleted file mode 100644 (file)
index feae65e..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-/*
- * irq.h - SPU interrupt management facilities.
- * 
- * These utilities help an "interrupt aware" library to manage
- * state of SPU interrupts.  
- */
-
-#ifndef __SPU_IRQ_H__
-#define __SPU_IRQ_H__
-
-#include <spu_intrinsics.h>
-#include "sync_utils.h"
-
-static inline u32 irq_mask(u32 newmask)
-{
-    u32 old, tmp = 0;
-
-    /* irq_mask
-     *    Set the interrupt mask to the newmask value,
-     *    and return its previous setting.  Will
-     *    detect and discard potential phantom
-     *    events.
-     */
-
-    old = spu_readch(SPU_RdEventMask);
-    spu_writech(SPU_WrEventMask, tmp);
-    if (spu_readchcnt(SPU_RdEventStat)) {
-        tmp = spu_readch(SPU_RdEventStat);
-        spu_writech(SPU_WrEventAck, tmp);
-    }
-    spu_writech(SPU_WrEventMask, newmask);
-
-    return old;
-}
-
-#endif /* __SPU_IRQ_H__ */
diff --git a/gcell/src/ibm/sync/spu_source/sync_utils.h b/gcell/src/ibm/sync/spu_source/sync_utils.h
deleted file mode 100644 (file)
index 516b41f..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-/*
- * sync_utils.h - SPU sync-library internal utilities.
- *
- * These utilities are used internally by the SPU sync library.
- */
-#ifndef __SPU_SYNC_UTILS_H__
-#define __SPU_SYNC_UTILS_H__
-
-#include <spu_intrinsics.h>
-
-typedef unsigned int u32;
-typedef signed int s32;
-typedef unsigned long long u64;
-typedef unsigned long long eaddr_t;
-
-
-typedef union {
-    u64 ull;  
-    u32 ui[2];
-} addr64;
-
-#ifndef likely
-#define likely(_c)     \
-    __builtin_expect((_c), 1)
-#define unlikely(_c)    \
-    __builtin_expect((_c), 0)
-#endif
-
-#define ALLOCA(_nbytes, _size)    \
-    alloca((_nbytes) + (_size)-1)
-
-#define ALIGN(_ptr, _size)       \
-    ((((u32) _ptr) + (_size)-1) & ~((_size)-1))
-
-#define ALIGN128_EA(_ull)      \
-    ((_ull) & ~(127ULL))
-/*
-#define OFFSET128_EA(_ull, _type) \
-    (((_ull) & 127ULL) / sizeof(_type))
-    */
-
-#define OFFSET128_EA_U32(_ull) \
-    (((_ull) & 127ULL) >> 2)
-
-#define OFFSET128_EA_U16(_ull) \
-    (((_ull) & 127ULL) >> 1)
-
-#define MFC_DMA(_ls, _ea, _sz, _tg, _cmd) \
-    spu_mfcdma64(_ls, _ea.ui[0], _ea.ui[1], _sz, _tg, _cmd)
-
-#define MFC_SYNC() {                           \
-    u32 _tagid = 0;                            \
-    spu_writech(mfc_tag_id, _tagid);           \
-    spu_writech(mfc_cmd_queue, MFC_SYNC_CMD);  \
-}
-
-#define MFC_EIEIO() {                          \
-    u32 _tagid = 0;                            \
-    spu_writech(mfc_tag_id, _tagid);           \
-    spu_writech(mfc_cmd_queue, MFC_EIEIO_CMD); \
-}
-
-#endif /* __SPU_SYNC_UTILS_H__ */
diff --git a/gcell/src/ibm/sync/spu_source/trace_libsync.h b/gcell/src/ibm/sync/spu_source/trace_libsync.h
deleted file mode 100644 (file)
index 47887c9..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2007                                               */
-/* International Business Machines Corporation                     */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef __LIBSYNC_SPU_TRACEHOOKS_H__
-#define __LIBSYNC_SPU_TRACEHOOKS_H__
-
-#ifdef LIBSYNC_TRACE
-
-#include <trace_events.h>
-
-/*
- *  last parameter in the trace_even and trace_interval_entry call is
- *   the stack level to report the PC in the trace record. so 0 means
- *   the PC of the current frame, 1 means the PC of the caller, etc.
- *   there's a dilemma here - these macros are included in the inline
- *   _mutex calls which get called from the (created during build)
- *   mutex functions in the mutex .c files. in that case, the level
- *   should be 1 - we don't want the PC of where in the mutex function
- *   the trace call is happening, we want the PC of whomever is calling
- *   the mutex function.
- *
- *   but.. an app can call the inline functions - it can #include the
- *   appropriate libsync mutex .h files, and call the inlined _mutex
- *   function in their code. in that case, the appropriate level for the
- *   trace calls would be 0 - the user would want to know where in their
- *   code the call to the _mutex function is.
- *
- *   so, we'll assume _LEVEL of 0 which is what the inline funtions need.
- *   when we build the files for libsync, we'll do a -D_LEVEL=1 
- */
-#ifndef _LEVEL
-#define _LEVEL 0
-#endif
-
-
-#define TRACE_EVENT_MUTEX_INIT 0x0403
-
-#define TRACE_MUTEX_INIT(lock) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(unsigned long)lock; \
-  trace_event(TRACE_EVENT_MUTEX_INIT, 1, &payload, "Event=%d, lock=0x%x", _LEVEL); \
-}
-
-#define TRACE_EVENT_MUTEX_LOCK 0x0503
-
-#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL) \
-trace_interval_p _INTERVAL = trace_interval_entry(TRACE_EVENT_MUTEX_LOCK, _LEVEL)
-
-#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(unsigned long)lock; \
-  payload.word[2]=(unsigned int)miss; \
-  trace_interval_exit(_INTERVAL, 2,  &payload, "Event=%d, lock=0x%x, miss=0x%x"); \
-}
-
-#define TRACE_EVENT_MUTEX_TRYLOCK 0x0603
-
-#define TRACE_MUTEX_TRYLOCK(lock,ret_val) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(unsigned long)lock; \
-  payload.word[2]=(unsigned int)ret_val; \
-  trace_event(TRACE_EVENT_MUTEX_TRYLOCK, 2, &payload, "Event=%d, lock=0x%x, ret_val=0x%x", _LEVEL); \
-}
-
-#define TRACE_EVENT_MUTEX_UNLOCK 0x0703
-
-#define TRACE_MUTEX_UNLOCK(lock) { \
-  trace_payload_t payload; \
-  payload.dword[0]=(unsigned long)lock; \
-  trace_event(TRACE_EVENT_MUTEX_UNLOCK, 1, &payload, "Event=%d, lock=0x%x", _LEVEL); \
-}
-
-#else /* LIBSYNC_TRACE */
-
-#define TRACE_MUTEX_INIT(lock) 
-#define TRACE_MUTEX_LOCK_ENTRY(_INTERVAL) 
-#define TRACE_MUTEX_LOCK_EXIT(_INTERVAL,lock,miss)
-#define TRACE_MUTEX_TRYLOCK(lock,ret_val)
-#define TRACE_MUTEX_UNLOCK(lock) 
-
-#endif /* LIBSYNC_TRACE */
-
-#endif  /* __LIBSYNC_SPU_TRACEHOOKS_H__ */
diff --git a/gcell/src/ibm/sync/spu_source/wait_for_completion.h b/gcell/src/ibm/sync/spu_source/wait_for_completion.h
deleted file mode 100644 (file)
index ea7bdbe..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_WAIT_FOR_COMPLETION_H_
-#define _SPU_WAIT_FOR_COMPLETION_H_
-
-#include "sync_utils.h"
-#include <spu_mfcio.h>
-#include "sync_irq.h"
-#include "completion.h"
-
-/* _wait_for_completion 
- *    Internal routine to wait for completion to
- *    become true (!0).  When completion is false,
- *    uses lock line reservation lost event to 
- *    sleep until the variable has been changed.
- */
-static __inline void _wait_for_completion(completion_ea_t completion)
-{
-    DECL_COMPLETION_VARS();
-    s32 status;
-
-    status = 1;
-
-    ea64.ull = ALIGN128_EA(completion);
-    offset = OFFSET128_EA_U32(completion);
-    do {
-        MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-        spu_readch(MFC_RdAtomicStat);
-        /* if the completion variable has been set elsewhere
-         * (a signal or broadcast function has been called 
-         * then we get out of the loop, and reset the variable */
-        if (likely(buf[offset] != 0)) {
-            /* decrement the variable */
-            buf[offset]--;
-            MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLC_CMD);
-            spu_readch(MFC_RdAtomicStat);
-            status = 0;
-        }
-    } while (status != 0);
-}
-
-
-
-#endif /* _SPU_WAIT_FOR_COMPLETION_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/write_lock.h b/gcell/src/ibm/sync/spu_source/write_lock.h
deleted file mode 100644 (file)
index 7af5175..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_WRITE_LOCK_H_
-#define _SPU_WRITE_LOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-
-/**
- * write_lock - acquire writer lock, or spin until available.
- * @ea: handle to effective address of lock variable.
- *
- * Description: Acquire an exclusive writer lock, 
- * or spin until available.  The only restriction 
- * here is that @ea must be word aligned.
- *
- * Context: This routine should not be called if SPU 
- * asynchronous interrupts are enabled.
- */
-static __inline void _write_lock(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status;
-
-    RAW_SPINLOCK(==, -1);
-}
-
-
-#endif /* _SPU_WRITE_LOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/write_trylock.h b/gcell/src/ibm/sync/spu_source/write_trylock.h
deleted file mode 100644 (file)
index b3799b3..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_WRITE_TRYLOCK_H_
-#define _SPU_WRITE_TRYLOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-
-/**
- * write_trylock - acquire a writer lock, or return immediately.
- * @ea: handle to effective address of lock variable.
- *
- * Try to acquire an exclusive writer lock, or return
- * immediately.  The only restriction here is that @ea
- * must be word aligned.
- *
- * Returns 1 on success, or 0 on failure.
- *
- * Caution:
- * The application should not call this interface from a tight
- * loop!!  Use write_lock() instead.
- */
-static __inline int _write_trylock(eaddr_t ea)
-{
-    DECL_MUTEX_VARS();
-    s32 status, ret_val;
-
-    RAW_TEST_AND_SET(==, -1);
-
-    return ret_val;
-}
-
-
-#endif /* _SPU_WRITE_TRYLOCK_H_ */
diff --git a/gcell/src/ibm/sync/spu_source/write_unlock.h b/gcell/src/ibm/sync/spu_source/write_unlock.h
deleted file mode 100644 (file)
index 25b24e1..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _SPU_WRITE_UNLOCK_H_
-#define _SPU_WRITE_UNLOCK_H_
-
-#include "sync_utils.h"
-#include "mutex.h"
-#include <spu_mfcio.h>
-
-/**
- * write_unlock - release writer lock.
- * @rwlock: handle to effective address of lock variable.
- *
- * Release a single writer lock.
- */
-static __inline void _write_unlock(eaddr_t rwlock)
-{
-    DECL_MUTEX_VARS();
-
-    ea64.ull = ALIGN128_EA(rwlock);
-    offset = OFFSET128_EA_U32(rwlock);
-    MFC_DMA(buf, ea64, size, tagid, MFC_GETLLAR_CMD);
-    spu_readch(MFC_RdAtomicStat);
-
-    buf[offset] = 0;
-    MFC_DMA(buf, ea64, size, tagid, MFC_PUTLLUC_CMD);
-    spu_readch(MFC_RdAtomicStat);
-}
-
-
-#endif /* _SPU_WRITE_UNLOCK_H_ */
diff --git a/gcell/src/include/Makefile.am b/gcell/src/include/Makefile.am
deleted file mode 100644 (file)
index 1e65282..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-SUBDIRS = spu
-
-gcellinclude_HEADERS = \
-       compiler.h \
-       gc_atomic.h \
-       gc_cdefs.h \
-       gc_declare_proc.h \
-       gc_jd_queue_data.h \
-       gc_jd_queue.h \
-       gc_jd_stack.h \
-       gc_job_desc.h \
-       gc_job_desc_private.h \
-       gc_logging.h \
-       gc_mbox.h \
-       gc_spu_args.h \
-       gc_types.h \
-       memory_barrier.h
diff --git a/gcell/src/include/compiler.h b/gcell/src/include/compiler.h
deleted file mode 100644 (file)
index 5f1c99c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_COMPILER_H
-#define INCLUDED_COMPILER_H
-
-/*!
- * \brief Compiler specific hackery.  These are for GCC.
- */
-
-#define _AL8   __attribute__((aligned (8)))
-#define _AL16  __attribute__((aligned (16)))
-#define _AL128 __attribute__((aligned (128)))
-
-#define _UNUSED __attribute__((unused))
-
-#ifndef likely
-#define likely(x)       __builtin_expect(!!(x), 1)
-#define unlikely(x)     __builtin_expect(!!(x), 0)
-#endif
-
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
-#endif
-
-
-#endif /* INCLUDED_COMPILER_H */
diff --git a/gcell/src/include/gc_atomic.h b/gcell/src/include/gc_atomic.h
deleted file mode 100644 (file)
index 01737cd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_ATOMIC_H
-#define INCLUDED_GC_ATOMIC_H
-
-#include <stdint.h>
-
-typedef uint32_t       gc_atomic_t;
-
-
-#endif /* INCLUDED_GC_ATOMIC_H */
diff --git a/gcell/src/include/gc_cdefs.h b/gcell/src/include/gc_cdefs.h
deleted file mode 100644 (file)
index 93084ba..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_CDEFS_H
-#define INCLUDED_GC_CDEFS_H
-
-/* C++ needs to know that types and declarations are C, not C++.  */
-#ifdef __cplusplus
-# define __GC_BEGIN_DECLS      extern "C" {
-# define __GC_END_DECLS        }
-#else
-# define __GC_BEGIN_DECLS
-# define __GC_END_DECLS
-#endif
-
-#endif /* INCLUDED_GC_CDEFS_H */
diff --git a/gcell/src/include/gc_declare_proc.h b/gcell/src/include/gc_declare_proc.h
deleted file mode 100644 (file)
index 37af5ba..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_DECLARE_PROC_H
-#define INCLUDED_GC_DECLARE_PROC_H
-
-#include <stdint.h>
-#include <gc_job_desc.h>
-
-/*
- * This is C, not C++ code...
- *
- * ...and is used by both PPE and SPE code
- */
-__GC_BEGIN_DECLS
-
-#define GC_PROC_DEF_SECTION ".gcell.proc_def"
-
-typedef struct gc_proc_def {
-#if defined(__SPU__)
-  gc_spu_proc_t        proc;
-#else
-  uint32_t     proc;
-#endif
-  char         name[28];
-} _AL16 gc_proc_def_t;
-
-
-#if defined(__SPU__)
-/*!
- * \brief Tell gcell about a SPU procedure
- *
- * \param _proc_   pointer to function (gc_spu_proc_t)
- * \param _name_   the name of the procedure ("quoted string")
- *
- * This macro registers the given procedure with the gcell runtime.
- * From the PPE, use gc_job_manager::lookup_proc to map \p _name_ to a gc_proc_id_t
- */
-#define GC_DECLARE_PROC(_proc_, _name_) \
-static struct gc_proc_def \
-  _GCPD_ ## _proc_ __attribute__((section(GC_PROC_DEF_SECTION), used)) = \
-  { _proc_, _name_ }
-#endif
-
-__GC_END_DECLS
-
-#endif /* INCLUDED_GC_DECLARE_PROC_H */
diff --git a/gcell/src/include/gc_jd_queue.h b/gcell/src/include/gc_jd_queue.h
deleted file mode 100644 (file)
index f5f8a1a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JD_QUEUE_H
-#define INCLUDED_GC_JD_QUEUE_H
-
-#include "gc_jd_queue_data.h"
-
-__GC_BEGIN_DECLS
-
-/*!
- * \brief Initialize the queue to empty.
- */
-void 
-gc_jd_queue_init(gc_jd_queue_t *q);
-  
-
-/*!
- * \brief Add \p item to the tail of \p q.
- */
-void 
-gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item);
-
-
-/*!
- * \brief Remove and return item at head of queue, or 0 if queue is empty
- */
-gc_job_desc_t *
-gc_jd_queue_dequeue(gc_jd_queue_t *q);
-
-__GC_END_DECLS
-
-
-#endif /* INCLUDED_GC_JD_QUEUE_H */
diff --git a/gcell/src/include/gc_jd_queue_data.h b/gcell/src/include/gc_jd_queue_data.h
deleted file mode 100644 (file)
index 3fd7270..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JD_QUEUE_DATA_H
-#define INCLUDED_GC_JD_QUEUE_DATA_H
-
-#include "gc_types.h"
-#include "gc_job_desc.h"
-
-__GC_BEGIN_DECLS
-
-/*!
- * \brief (Lock free someday...) queue for job descriptors
- *
- * This is the main data structure shared between PPEs and SPEs.
- * It is used to enqueue work for SPEs.  SPEs or PPEs may enqueue
- * work.  SPE's dequeue from here.
- *
- * FIXME make it lock free ;)  For now, use a spin lock.
- *
- * (Fills a single cache line)
- */
-typedef struct gc_jd_queue
-{
-  gc_eaddr_t   head  _AL16;
-  gc_eaddr_t   tail  _AL16;
-  uint32_t     mutex _AL16;            // libsync mutex (spin lock)
-} _AL128 gc_jd_queue_t;
-
-__GC_END_DECLS
-
-#endif /* INCLUDED_GC_JD_QUEUE_DATA_H */
-
-
diff --git a/gcell/src/include/gc_jd_stack.h b/gcell/src/include/gc_jd_stack.h
deleted file mode 100644 (file)
index 72e9435..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JD_STACK_H
-#define INCLUDED_GC_JD_STACK_H
-
-#include "gc_types.h"
-#include "gc_job_desc.h"
-
-__GC_BEGIN_DECLS
-
-/*!
- * \brief Lock free stack for job descriptors (used for free list)
- *
- * This is aligned to a cache line, and fills the cache line,
- * to avoid inadvertently losing reservations created with
- * the load-and-reserve instructions.
- */
-
-typedef struct gc_jd_stack
-{
-  gc_eaddr_t   top;
-
-  // pad out to a full cache line
-  uint8_t      _pad[128 - sizeof(gc_eaddr_t)];
-} _AL128 gc_jd_stack_t;
-
-
-/*!
- * \brief Initialize the stack to empty.
- */
-void 
-gc_jd_stack_init(gc_jd_stack_t *stack);
-  
-
-/*!
- * \brief Add \p item to the top of \p stack.
- */
-void 
-gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item);
-
-
-/*!
- * \brief pop and return top item on stack, or 0 if stack is empty
- */
-gc_job_desc_t *
-gc_jd_stack_pop(gc_jd_stack_t *stack);
-
-__GC_END_DECLS
-
-
-#endif /* INCLUDED_GC_JD_STACK_H */
diff --git a/gcell/src/include/gc_job_desc.h b/gcell/src/include/gc_job_desc.h
deleted file mode 100644 (file)
index b791506..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JOB_DESC_H
-#define INCLUDED_GC_JOB_DESC_H
-
-/*!
- * This file contains the structures that are used to describe how to
- * call "jobs" that execute on the SPEs.  A "job" is a task, or piece of
- * work that you want to run on an SPE.
- *
- * There is code running in the SPE that knows how to interpret
- * these job descriptions. Thus, in most cases, the overhead
- * of invoking these is very low.
- *
- * The whole "job idea" is SPE centric.  At first pass,
- * the PPE will be constructing jobs and enqueing them.
- * However, there is nothing in the implementation that
- * prohibits SPEs from creating their own jobs in the
- * future.  Also, there is nothing prohibiting SPE-to-SPE
- * DMA's.
- *
- * SPE's dequeue and "pull" jobs to themselves, do the work, then
- * notify the entity that submitted the job.
- */
-
-#include "gc_types.h"
-#include "gc_job_desc_private.h"
-
-/*
- * This is C, not C++ code...
- *
- * ...and is used by both PPE and SPE code
- */
-__GC_BEGIN_DECLS
-
-
-//! opaque ID that specifies which code to invoke on the SPE
-typedef uint32_t gc_proc_id_t;
-#define GCP_UNKNOWN_PROC ((gc_proc_id_t) -1)
-
-
-//! final job status
-typedef enum {
-  JS_OK,
-  JS_SHUTTING_DOWN,        // job mananger is shutting down
-  JS_TOO_MANY_CLIENTS,     // too many client threads
-  JS_UNKNOWN_PROC,         // didn't recognize the procedure ID
-  JS_BAD_DIRECTION,        // EA arg has invalid direction
-  JS_BAD_EAH,              // not all EA args have the same high 32 address bits
-  JS_BAD_N_DIRECT,         // too many direct args
-  JS_BAD_N_EA,             // too many EA args
-  JS_ARGS_TOO_LONG,        // total length of EA args exceeds limit
-  JS_BAD_JUJU,             // misc problem: you're having a bad day
-  JS_BAD_JOB_DESC,         // gc_job_desc was not allocated using mgr->alloc_job_desc()
-
-} gc_job_status_t;
-
-#define MAX_ARGS_DIRECT  8  // maximum number of args passed using "direct" method
-#define MAX_ARGS_EA     8  // maximum number of args passed via EA memory (dma)
-
-/*
- * We support two classes of arguments,
- *   "direct", which are contained in the gc_job_desc_args and
- *   "EA", which are copied in/out according to info in gc_job_desc_args
- */
-
-/*!
- * \brief Tag type of "direct" argument
- */
-typedef enum {
-  GCT_S32,
-  GCT_U32,
-  GCT_S64,
-  GCT_U64,
-  GCT_FLOAT,
-  GCT_DOUBLE,
-  GCT_FLT_CMPLX,
-  GCT_DBL_CMPLX,
-  GCT_EADDR,
-
-} gc_tag_t;
-
-
-/*!
- * \brief union for passing "direct" argument
- */
-typedef union gc_arg_union
-{
-  int32_t       s32;
-  uint32_t      u32;
-  int64_t       s64;
-  uint64_t      u64;
-  float                 f;
-  double        d;
-  //float complex  cf; //  64-bits (C99)
-  //double complex cd;  // 128-bits (C99)
-  gc_eaddr_t    ea;    //  64-bits
-} _AL8 gc_arg_union_t;
-
-
-/*!
- * \brief "direct" input or output arguments
- */
-typedef struct gc_job_direct_args
-{
-  uint32_t       nargs;                        // # of "direct" args
-  gc_tag_t       tag[MAX_ARGS_DIRECT] _AL16;   // type of direct arg[i]
-  gc_arg_union_t  arg[MAX_ARGS_DIRECT] _AL16;   // direct argument values
-
-} _AL16 gc_job_direct_args_t;
-
-
-// specifies direction for args passed in EA memory
-
-#define GCJD_DMA_GET           0x01            // in to SPE
-#define        GCJD_DMA_PUT            0x02            // out from SPE
-
-/*!
- * \brief Description of args passed in EA memory.
- * These are DMA'd between EA and LS as specified.
- */
-typedef struct gc_job_ea_arg {
-  //! EA address of buffer
-  gc_eaddr_t     ea_addr;      
-
-  //! GC_JD_DMA_* get arg or put arg
-  uint32_t      direction;
-
-  //! number of bytes to get
-  uint32_t      get_size;         
-
-  //! number of bytes to put
-  uint32_t      put_size;
-
-#if defined(__SPU__)
-  //! local store address (filled in by SPU runtime)
-  void         *ls_addr;
-  uint32_t      _pad[2];
-#else
-  uint32_t       _pad[3];
-#endif
-
-} _AL16 gc_job_ea_arg_t;
-
-
-typedef struct gc_job_ea_args {
-  uint32_t             nargs;
-  gc_job_ea_arg_t      arg[MAX_ARGS_EA];
-
-} _AL16 gc_job_ea_args_t;
-
-
-/*!
- * \brief "job description" that is DMA'd to/from the SPE.
- */
-typedef struct gc_job_desc
-{
-  gc_job_desc_private_t sys;     // internals
-  gc_job_status_t      status;   // what happened (output)
-  gc_proc_id_t          proc_id;  // specifies which procedure to run
-  gc_job_direct_args_t input;    // direct args to SPE
-  gc_job_direct_args_t output;   // direct args from SPE
-  gc_job_ea_args_t     eaa;      // args passed via EA memory
-
-} _AL128 gc_job_desc_t;
-
-
-/*!
- * type of procedure invoked on spu
- */
-typedef void (*gc_spu_proc_t)(const gc_job_direct_args_t *input,
-                             gc_job_direct_args_t *output,
-                             const gc_job_ea_args_t *eaa);
-
-#if !defined(__SPU__)
-
-static inline gc_job_desc_t *
-ea_to_jdp(gc_eaddr_t ea)
-{
-  return (gc_job_desc_t *) ea_to_ptr(ea);
-}
-
-static inline gc_eaddr_t
-jdp_to_ea(gc_job_desc_t *item)
-{
-  return ptr_to_ea(item);
-}
-
-#endif
-
-
-__GC_END_DECLS
-
-#endif /* INCLUDED_GC_JOB_DESC_H */
diff --git a/gcell/src/include/gc_job_desc_private.h b/gcell/src/include/gc_job_desc_private.h
deleted file mode 100644 (file)
index 1f76d86..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JOB_DESC_PRIVATE_H
-#define INCLUDED_GC_JOB_DESC_PRIVATE_H
-
-// #include <libsync.h>
-
-/*!
- * \brief Implementation details we'd like to hide from the user.
- */
-typedef struct gc_job_desc_private
-{
-  gc_eaddr_t   next;               // used to implement job queue and free list
-  uint16_t     job_id;
-  uint16_t     client_id;
-  uint32_t     direction_union;    // union of all gc_job_ea_arg.direction fields
-} gc_job_desc_private_t;
-
-#endif /* INCLUDED_GC_JOB_PRIVATE_H */
-
diff --git a/gcell/src/include/gc_logging.h b/gcell/src/include/gc_logging.h
deleted file mode 100644 (file)
index b98c283..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_LOGGING_H
-#define INCLUDED_GC_LOGGING_H
-
-#include <gc_types.h>
-#include <string.h>
-
-__GC_BEGIN_DECLS
-
-typedef struct gc_log {
-  gc_eaddr_t           base;           // gc_log_entry_t * (16 byte aligned)
-  uint32_t     nentries;       // number of entries (power-of-2)
-} gc_log_t;
-
-typedef struct gc_log_entry {
-  uint32_t     seqno;          // monotonic sequence number
-  uint32_t     timestamp;      // decrementer value (wraps every 53s on PS3)
-  uint16_t     subsystem;      // 0 to 255 reserved for system, user gets 256 and up
-  uint16_t     event;
-  uint32_t     info[5];
-} _AL16 gc_log_entry_t;
-
-#define        GCL_SS_SYS      0       // lowest system reserved subsystem
-#define        GCL_SS_USER   256       // lowest user reserved subsystem
-
-
-/*
- * The resulting log files can be displayed using using:
- *
- *  $ od -t x4 -w32 spu_log.00 | less
- */
-
-
-#if defined(__SPU__)
-
-/*!
- * System fills in seqno and timestamp.  User is responsible for the rest.
- */
-
-void _gc_log_write(gc_log_entry_t entry);
-
-#ifdef ENABLE_GC_LOGGING
-#define gc_log_write(entry) _gc_log_write(entry)
-#else
-#define gc_log_write(entry) do { } while (0)
-#endif
-
-inline static void
-gc_log_write0(int subsystem, int event)
-{
-  gc_log_entry_t e;
-  e.subsystem = subsystem;
-  e.event = event;
-  e.info[0] = 0;
-  e.info[1] = 0;
-  e.info[2] = 0;
-  e.info[3] = 0;
-  e.info[4] = 0;
-  gc_log_write(e);
-}
-
-inline static void
-gc_log_write1(int subsystem, int event,
-             uint32_t info0)
-{
-  gc_log_entry_t e;
-  e.subsystem = subsystem;
-  e.event = event;
-  e.info[0] = info0;
-  e.info[1] = 0;
-  e.info[2] = 0;
-  e.info[3] = 0;
-  e.info[4] = 0;
-  gc_log_write(e);
-}
-
-inline static void
-gc_log_write2(int subsystem, int event,
-             uint32_t info0, uint32_t info1)
-{
-  gc_log_entry_t e;
-  e.subsystem = subsystem;
-  e.event = event;
-  e.info[0] = info0;
-  e.info[1] = info1;
-  e.info[2] = 0;
-  e.info[3] = 0;
-  e.info[4] = 0;
-  gc_log_write(e);
-}
-
-inline static void
-gc_log_write3(int subsystem, int event,
-             uint32_t info0, uint32_t info1, uint32_t info2)
-{
-  gc_log_entry_t e;
-  e.subsystem = subsystem;
-  e.event = event;
-  e.info[0] = info0;
-  e.info[1] = info1;
-  e.info[2] = info2;
-  e.info[3] = 0;
-  e.info[4] = 0;
-  gc_log_write(e);
-}
-
-inline static void
-gc_log_write4(int subsystem, int event,
-             uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3)
-{
-  gc_log_entry_t e;
-  e.subsystem = subsystem;
-  e.event = event;
-  e.info[0] = info0;
-  e.info[1] = info1;
-  e.info[2] = info2;
-  e.info[3] = info3;
-  e.info[4] = 0;
-  gc_log_write(e);
-}
-
-inline static void
-gc_log_write5(int subsystem, int event,
-             uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3, uint32_t info4)
-{
-  gc_log_entry_t e;
-  e.subsystem = subsystem;
-  e.event = event;
-  e.info[0] = info0;
-  e.info[1] = info1;
-  e.info[2] = info2;
-  e.info[3] = info3;
-  e.info[4] = info4;
-  gc_log_write(e);
-}
-
-/*!
- * One time initialization called by system runtime
- */
-void
-_gc_log_init(gc_log_t log_info);
-
-#endif
-
-__GC_END_DECLS
-
-#endif /* INCLUDED_GC_LOGGING_H */
diff --git a/gcell/src/include/gc_mbox.h b/gcell/src/include/gc_mbox.h
deleted file mode 100644 (file)
index 32b23c6..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_MBOX_H
-#define INCLUDED_GC_MBOX_H
-
-/*
- * The PPE and SPE exchange a few 32-bit messages via mailboxes.
- * All have a 4 bit opcode in the high bits.
- *
- *      3                   2                   1
- *    1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *   |  op   |                        arg                            |
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-#define MK_MBOX_MSG(cmd, args) ((((cmd) & 0xf) << 28) | ((args) & 0x0fffffff))
-#define MBOX_MSG_OP(msg)  (((msg) >> 28) & 0xf)
-#define        MBOX_MSG_ARG(msg) ((msg) & 0x0fffffff)
-
-// PPE to SPE (sent via SPE Read Inbound Mailbox)
-
-#define OP_EXIT                        0x0     // exit now
-#define        OP_GET_SPU_BUFSIZE      0x1 
-
-// SPE to PPE (sent via SPE Write Outbound Interrupt Mailbox)
-
-#define OP_JOBS_DONE           0x2     // arg is 0 or 1, indicating which
-                                       //   gc_completion_info_t contains the info
-#define        OP_SPU_BUFSIZE          0x3     // arg is max number of bytes
-
-
-#endif /* INCLUDED_GC_MBOX_H */
diff --git a/gcell/src/include/gc_spu_args.h b/gcell/src/include/gc_spu_args.h
deleted file mode 100644 (file)
index f5a2122..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_SPU_ARGS_H
-#define INCLUDED_GC_SPU_ARGS_H
-
-#include <gc_types.h>
-#include <gc_logging.h>
-
-// args passed to SPE at initialization time
-
-typedef struct gc_spu_args {
-  gc_eaddr_t   queue;          // address of job queue (gc_jd_queue_t *)
-  gc_eaddr_t   comp_info[2];   // completion info (gc_comp_info_t *)
-  uint32_t     spu_idx;        // which spu we are: [0,nspus-1]
-  uint32_t     nspus;          // number of spus we're using
-  uint32_t     proc_def_ls_addr;  // LS addr of proc_def table
-  uint32_t     nproc_defs;        // number of proc_defs in table
-  gc_log_t     log;               // logging info
-} _AL16 gc_spu_args_t;
-
-
-#define        GC_CI_NJOBS     62      // makes gc_comp_info 1 cache line long
-
-/*!
- * \brief Used to return info to PPE on which jobs are completed.
- *
- * When each SPE is initalized, it is passed EA pointers to two of
- * these structures.  The SPE uses these to communicate which jobs
- * that it has worked on are complete.  The SPE notifies the PPE by
- * sending an OP_JOBS_DONE message (see gc_mbox.h) with an argument of
- * 0 or 1, indicating which of the two comp_info's to examine.  The
- * SPE sets the in_use flag to 1 before DMA'ing to the PPE.  When the
- * PPE is done with the structure, it must clear the in_use field to
- * let the SPE know it can begin using it again.
- */
-typedef struct gc_comp_info {
-  uint16_t     in_use;         // set by SPE, cleared by PPE when it's finished
-  uint16_t     ncomplete;      // number of valid job_id's
-  uint16_t     job_id[GC_CI_NJOBS];    // job_id's of completed jobs
-} _AL128 gc_comp_info_t;
-
-#endif /* INCLUDED_GC_SPU_ARGS_H */
diff --git a/gcell/src/include/gc_types.h b/gcell/src/include/gc_types.h
deleted file mode 100644 (file)
index 9a4d054..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_TYPES_H
-#define INCLUDED_GC_TYPES_H
-
-#include <stdint.h>
-#include <gc_cdefs.h>
-#include "compiler.h"
-
-__GC_BEGIN_DECLS
-
-#ifndef __cplusplus
-typedef int bool;
-#define true  1
-#define false 0
-#endif
-
-/*!
- * \brief 64-bit integer type representing an effective address (EA)
- *
- * This type is always 64-bits, regardless of whether we're
- * running in 32 or 64-bit mode.
- */
-typedef uint64_t       gc_eaddr_t;
-
-#if !defined(__SPU__)
-static inline void *
-ea_to_ptr(gc_eaddr_t ea)
-{
-  // in 32-bit mode we're tossing the top 32-bits.
-  return (void *) (uintptr_t) ea;
-}
-
-static inline gc_eaddr_t
-ptr_to_ea(void *p)
-{
-  // two steps to avoid compiler warning in 32-bit mode.
-  return (gc_eaddr_t) (uintptr_t) p;
-}
-#endif
-
-__GC_END_DECLS
-
-#endif /* INCLUDED_GC_TYPES_H */
diff --git a/gcell/src/include/memory_barrier.h b/gcell/src/include/memory_barrier.h
deleted file mode 100644 (file)
index b373ffd..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_MEMORY_BARRIER_H
-#define INCLUDED_MEMORY_BARRIER_H
-
-/*
- * powerpc memory barriers
- *
- * The sync instruction guarantees that all memory accesses initiated
- * by this processor have been performed (with respect to all other
- * mechanisms that access memory).  The eieio instruction is a barrier
- * providing an ordering (separately) for (a) cacheable stores and (b)
- * loads and stores to non-cacheable memory (e.g. I/O devices).
- *
- * smp_mb() prevents loads and stores being reordered across this point.
- * smp_rmb() prevents loads being reordered across this point.
- * smp_wmb() prevents stores being reordered across this point.
- *
- * We have to use the sync instructions for smp_mb(), since lwsync
- * doesn't order loads with respect to previous stores.  Lwsync is
- * fine for smp_rmb(), though.  For smp_wmb(), we use eieio since it
- * is only used to order updates to system memory.
- *
- * For details, see "PowerPC Virtual Environment Architecture, Book
- * II".  Especially Chapter 1, "Storage Model" and Chapter 3, "Storage
- * Control Instructions." (site:ibm.com)
- */
-
-#include <ppu_intrinsics.h>
-
-static inline void smp_mb(void)
-{
-  __sync();
-}
-
-static inline void smp_rmb(void)
-{
-  __lwsync();
-}
-
-static inline void smp_wmb(void)
-{
-  __eieio();
-}
-
-
-#endif /* INCLUDED_MEMORY_BARRIER_H */
diff --git a/gcell/src/include/spu/Makefile.am b/gcell/src/include/spu/Makefile.am
deleted file mode 100644 (file)
index 81a8bfd..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-gcellspuinclude_HEADERS = \
-       gc_delay.h \
-       gc_jd_queue.h \
-       gc_random.h
diff --git a/gcell/src/include/spu/gc_delay.h b/gcell/src/include/spu/gc_delay.h
deleted file mode 100644 (file)
index 78f16fb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_DELAY_H
-#define INCLUDED_GC_DELAY_H
-
-void gc_udelay(unsigned int usecs);
-void gc_cdelay(unsigned int cpu_cycles);
-
-#endif /* INCLUDED_GC_DELAY_H */
diff --git a/gcell/src/include/spu/gc_jd_queue.h b/gcell/src/include/spu/gc_jd_queue.h
deleted file mode 100644 (file)
index b65b15f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_SPU_GC_JD_QUEUE_H
-#define INCLUDED_SPU_GC_JD_QUEUE_H
-
-#include "gc_jd_queue_data.h"
-
-/*
- * Declarations for SPU side of job queue interface
- */
-
-__GC_BEGIN_DECLS
-
-/*!
- * \brief Remove and return item at head of queue.
- *
- * \param[in]  q is EA address of queue structure.
- * \param[out] item_ea is EA address of item at head of queue.
- * \param[in]  jd_tag is the tag to use to get the LS copy of the item.
- * \param[out] item is local store copy of item at head of queue.
- * \returns false if the queue is empty, otherwise returns true
- *   and sets \p item_ea and DMA's job descriptor into \p item
- *
- * If return is false, we're holding a lock-line reservation that
- * covers the queue.
- */
-bool
-gc_jd_queue_dequeue(gc_eaddr_t q, gc_eaddr_t *item_ea,
-                   int jd_tag, gc_job_desc_t *item);
-
-__GC_END_DECLS
-
-
-#endif /* INCLUDED_SPU_GC_JD_QUEUE_H */
diff --git a/gcell/src/include/spu/gc_random.h b/gcell/src/include/spu/gc_random.h
deleted file mode 100644 (file)
index ccb5647..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_RANDOM_H
-#define INCLUDED_GC_RANDOM_H
-
-/*!
- * \brief Return a uniformly distributed value in the range [0, 1.0)
- * (Linear congruential generator. YMMV. Caveat emptor.)
- */
-
-float gc_uniform_deviate(void);
-void gc_set_seed(int seed);
-
-#endif /* INCLUDED_GC_RANDOM_H */
diff --git a/gcell/src/lib/Makefile.am b/gcell/src/lib/Makefile.am
deleted file mode 100644 (file)
index e7b3493..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-SUBDIRS = spu runtime general wrapper .
-
-# generate libgcell.la from the convenience libraries in subdirs
-
-lib_LTLIBRARIES = libgcell.la libgcell-qa.la
-
-libgcell_la_SOURCES = 
-libgcell_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
-
-libgcell_qa_la_SOURCES = 
-libgcell_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
-
-libgcell_la_LIBADD = \
-       runtime/libruntime.la \
-       wrapper/libwrapper.la \
-       -lspe2 \
-       $(OMNITHREAD_LA)
-
-libgcell_qa_la_LIBADD = \
-       runtime/libruntime-qa.la \
-       wrapper/libwrapper-qa.la \
-       $(CPPUNIT_LIBS)
-
-
-
-
-
-
diff --git a/gcell/src/lib/general/Makefile.am b/gcell/src/lib/general/Makefile.am
deleted file mode 100644 (file)
index bd5a4de..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-
diff --git a/gcell/src/lib/general/spu/fft_1d.h b/gcell/src/lib/general/spu/fft_1d.h
deleted file mode 100644 (file)
index 355b84b..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _FFT_1D_H_
-#define _FFT_1D_H_     1
-
-#include <spu_intrinsics.h>
-
-/* BIT_SWAP - swaps up to 16 bits of the integer _i according to the 
- *            pattern specified by _pat.
- */
-#define BIT_SWAP(_i, _pat)       spu_extract(spu_gather(spu_shuffle(spu_maskb(_i), _pat, _pat)), 0)
-
-
-#ifndef MAX_FFT_1D_SIZE
-#define MAX_FFT_1D_SIZE        8192
-#endif
-
-#ifndef INV_SQRT_2
-#define INV_SQRT_2     0.7071067811865
-#endif
-
-
-/* The following macro, FFT_1D_BUTTERFLY, performs a 4 way SIMD basic butterfly 
- * operation. The inputs are in parallel arrays (seperate real and imaginary
- * vectors). 
- * 
- *          p --------------------------> P = p + q*Wi
- *                        \      /
- *                         \    /
- *                          \  /
- *                           \/
- *                           /\
- *                          /  \
- *                         /    \
- *               ____     /      \
- *          q --| Wi |-----------------> Q = p - q*Wi
- *               ----
- */
-
-#define FFT_1D_BUTTERFLY(_P_re, _P_im, _Q_re, _Q_im, _p_re, _p_im, _q_re, _q_im, _W_re, _W_im) {       \
-  vector float _qw_re, _qw_im;                                                                         \
-                                                                                                       \
-  _qw_re = spu_msub(_q_re, _W_re, spu_mul(_q_im, _W_im));                                              \
-  _qw_im = spu_madd(_q_re, _W_im, spu_mul(_q_im, _W_re));                                              \
-  _P_re  = spu_add(_p_re, _qw_re);                                                                     \
-  _P_im  = spu_add(_p_im, _qw_im);                                                                     \
-  _Q_re  = spu_sub(_p_re, _qw_re);                                                                     \
-  _Q_im  = spu_sub(_p_im, _qw_im);                                                                     \
-}
-
-
-/* FFT_1D_BUTTERFLY_HI is equivalent to FFT_1D_BUTTERFLY with twiddle factors (W_im, -W_re)
- */
-#define FFT_1D_BUTTERFLY_HI(_P_re, _P_im, _Q_re, _Q_im, _p_re, _p_im, _q_re, _q_im, _W_re, _W_im) {    \
-  vector float _qw_re, _qw_im;                                                                         \
-                                                                                                       \
-  _qw_re = spu_madd(_q_re, _W_im, spu_mul(_q_im, _W_re));                                              \
-  _qw_im = spu_msub(_q_im, _W_im, spu_mul(_q_re, _W_re));                                              \
-  _P_re  = spu_add(_p_re, _qw_re);                                                                     \
-  _P_im  = spu_add(_p_im, _qw_im);                                                                     \
-  _Q_re  = spu_sub(_p_re, _qw_re);                                                                     \
-  _Q_im  = spu_sub(_p_im, _qw_im);                                                                     \
-}
-
-#endif /* _FFT_1D_H_ */
diff --git a/gcell/src/lib/general/spu/fft_1d_r2.c b/gcell/src/lib/general/spu/fft_1d_r2.c
deleted file mode 100644 (file)
index a0660b3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <libfft.h>
-#include <fft_1d_r2.h>
-#include <assert.h>
-
-/*
- * invoke the inline version
- */
-void 
-fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size)
-{
-  assert((1 << log2_size) <= MAX_FFT_1D_SIZE);
-
-  _fft_1d_r2(out, in, W, log2_size);
-}
diff --git a/gcell/src/lib/general/spu/fft_1d_r2.h b/gcell/src/lib/general/spu/fft_1d_r2.h
deleted file mode 100644 (file)
index a51cbc3..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-#ifndef _FFT_1D_R2_H_
-#define _FFT_1D_R2_H_  1
-
-#include "fft_1d.h"
-
-/* fft_1d_r2
- * ---------
- * Performs a single precision, complex Fast Fourier Transform using 
- * the DFT (Discrete Fourier Transform) with radix-2 decimation in time. 
- * The input <in> is an array of complex numbers of length (1<<log2_size)
- * entries. The result is returned in the array of complex numbers specified
- * by <out>. Note: This routine can support an in-place transformation
- * by specifying <in> and <out> to be the same array.
- *
- * This implementation utilizes the Cooley-Tukey algorithm consisting 
- * of <log2_size> stages. The basic operation is the butterfly.
- *
- *          p --------------------------> P = p + q*Wi
- *                        \      /
- *                         \    /
- *                          \  /
- *                           \/
- *                           /\
- *                          /  \
- *                         /    \
- *               ____     /      \
- *          q --| Wi |-----------------> Q = p - q*Wi
- *               ----
- *
- * This routine also requires pre-computed twiddle values, W. W is an
- * array of single precision complex numbers of length 1<<(log2_size-2) 
- * and is computed as follows:
- *
- *     for (i=0; i<n/4; i++)
- *         W[i].real =  cos(i * 2*PI/n);
- *         W[i].imag = -sin(i * 2*PI/n);
- *      }
- *
- * This array actually only contains the first half of the twiddle
- * factors. Due for symmetry, the second half of the twiddle factors
- * are implied and equal:
- *
- *     for (i=0; i<n/4; i++)
- *         W[i+n/4].real =  W[i].imag =  sin(i * 2*PI/n);
- *         W[i+n/4].imag = -W[i].real = -cos(i * 2*PI/n);
- *      }
- *
- * Further symmetry allows one to generate the twiddle factor table 
- * using half the number of trig computations as follows:
- *
- *      W[0].real = 1.0;
- *      W[0].imag = 0.0;
- *     for (i=1; i<n/4; i++)
- *         W[i].real =  cos(i * 2*PI/n);
- *         W[n/4 - i].imag = -W[i].real;
- *      }
- *
- * The complex numbers are packed into quadwords as follows:
- *
- *    quadword                       complex
- *  array element                   array elements
- *             -----------------------------------------------------
- *       i    |  real 2*i   |  imag 2*i  | real 2*i+1  | imag 2*i+1 | 
- *             -----------------------------------------------------
- *
- */
-
-
-static __inline void _fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size)
-{
-  int i, j, k;
-  int stage, offset;
-  int i_rev;
-  int n, n_2, n_4, n_8, n_16, n_3_16;
-  int w_stride, w_2stride, w_3stride, w_4stride;
-  int stride, stride_2, stride_4, stride_3_4;
-  vector float *W0, *W1, *W2, *W3;
-  vector float *re0, *re1, *re2, *re3;
-  vector float *im0, *im1, *im2, *im3;
-  vector float *in0, *in1, *in2, *in3, *in4, *in5, *in6, *in7;
-  vector float *out0, *out1, *out2, *out3;
-  vector float tmp0, tmp1;
-  vector float w0_re, w0_im, w1_re, w1_im;
-  vector float w0, w1, w2, w3;
-  vector float src_lo0, src_lo1, src_lo2, src_lo3;
-  vector float src_hi0, src_hi1, src_hi2, src_hi3;
-  vector float dst_lo0, dst_lo1, dst_lo2, dst_lo3;
-  vector float dst_hi0, dst_hi1, dst_hi2, dst_hi3;
-  vector float out_re_lo0, out_re_lo1, out_re_lo2, out_re_lo3;
-  vector float out_im_lo0, out_im_lo1, out_im_lo2, out_im_lo3;
-  vector float out_re_hi0, out_re_hi1, out_re_hi2, out_re_hi3;
-  vector float out_im_hi0, out_im_hi1, out_im_hi2, out_im_hi3;
-  vector float re_lo0,  re_lo1,  re_lo2,  re_lo3;
-  vector float im_lo0,  im_lo1,  im_lo2,  im_lo3;
-  vector float re_hi0,  re_hi1,  re_hi2,  re_hi3;
-  vector float im_hi0,  im_hi1,  im_hi2,  im_hi3;
-  vector float pq_lo0,  pq_lo1,  pq_lo2,  pq_lo3;
-  vector float pq_hi0,  pq_hi1,  pq_hi2,  pq_hi3;
-  vector float re[MAX_FFT_1D_SIZE/4], im[MAX_FFT_1D_SIZE/4];   /* real & imaginary working arrays */
-  vector float ppmm = (vector float) { 1.0f,  1.0f, -1.0f, -1.0f};
-  vector float pmmp = (vector float) { 1.0f, -1.0f, -1.0f,  1.0f};
-  vector unsigned char reverse;
-  vector unsigned char shuf_lo = (vector unsigned char) {
-                                            0,  1, 2, 3,  4, 5, 6, 7,
-                                            16,17,18,19, 20,21,22,23};
-  vector unsigned char shuf_hi = (vector unsigned char) {
-                                            8,  9,10,11, 12,13,14,15,
-                                            24,25,26,27, 28,29,30,31};
-  vector unsigned char shuf_0202 = (vector unsigned char) {
-                                              0, 1, 2, 3,  8, 9,10,11,
-                                              0, 1, 2, 3,  8, 9,10,11};
-  vector unsigned char shuf_1313 = (vector unsigned char) {
-                                              4, 5, 6, 7, 12,13,14,15,
-                                              4, 5, 6, 7, 12,13,14,15};
-  vector unsigned char shuf_0303 = (vector unsigned char) { 
-                                              0, 1, 2, 3, 12,13,14,15,
-                                              0, 1, 2, 3, 12,13,14,15};
-  vector unsigned char shuf_1212 = (vector unsigned char) {
-                                              4, 5, 6, 7,  8, 9,10,11,
-                                              4, 5, 6, 7,  8, 9,10,11};
-  vector unsigned char shuf_0415 = (vector unsigned char) {
-                                              0, 1, 2, 3, 16,17,18,19,
-                                              4, 5, 6, 7, 20,21,22,23};
-  vector unsigned char shuf_2637 = (vector unsigned char) {
-                                              8, 9,10,11, 24,25,26,27,
-                                              12,13,14,15,28,29,30,31};
-  vector unsigned char shuf_0246 = (vector unsigned char) {
-                                              0, 1, 2, 3,  8, 9,10,11,
-                                              16,17,18,19,24,25,26,27};
-  vector unsigned char shuf_1357 = (vector unsigned char) {
-                                              4, 5, 6, 7, 12,13,14,15,
-                                              20,21,22,23,28,29,30,31};
-  
-  n = 1 << log2_size;
-  n_2  = n >> 1;
-  n_4  = n >> 2;
-  n_8  = n >> 3;
-  n_16 = n >> 4;
-
-  n_3_16 = n_8 + n_16;
-
-  /* Compute a byte reverse shuffle pattern to be used to produce
-   * an address bit swap.
-   */
-  reverse = spu_or(spu_slqwbyte(spu_splats((unsigned char)0x80), log2_size),
-                  spu_rlmaskqwbyte(((vec_uchar16){15,14,13,12, 11,10,9,8, 
-                                                   7, 6, 5, 4,  3, 2,1,0}),
-                                   log2_size-16));
-
-  /* Perform the first 3 stages of the FFT. These stages differs from 
-   * other stages in that the inputs are unscrambled and the data is 
-   * reformated into parallel arrays (ie, seperate real and imaginary
-   * arrays). The term "unscramble" means the bit address reverse the 
-   * data array. In addition, the first three stages have simple twiddle
-   * weighting factors.
-   *           stage 1: (1, 0)
-   *            stage 2: (1, 0) and (0, -1)
-   *           stage 3: (1, 0), (0.707, -0.707), (0, -1), (-0.707, -0.707)
-   *
-   * The arrays are processed as two halves, simultaneously. The lo (first 
-   * half) and hi (second half). This is done because the scramble 
-   * shares source value between each half of the output arrays.
-   */
-  i = 0;
-  i_rev = 0;
-
-  in0 = in;
-  in1 = in + n_8;
-  in2 = in + n_16;
-  in3 = in + n_3_16;  
-
-  in4 = in  + n_4;
-  in5 = in1 + n_4;
-  in6 = in2 + n_4;
-  in7 = in3 + n_4;
-
-  re0 = re;
-  re1 = re + n_8;
-  im0 = im;
-  im1 = im + n_8;
-
-  w0_re = (vector float) { 1.0f,  INV_SQRT_2,  0.0f, -INV_SQRT_2};
-  w0_im = (vector float) { 0.0f, -INV_SQRT_2, -1.0f, -INV_SQRT_2};
-      
-  do {
-    src_lo0 = in0[i_rev];
-    src_lo1 = in1[i_rev];
-    src_lo2 = in2[i_rev];
-    src_lo3 = in3[i_rev];
-
-    src_hi0 = in4[i_rev];
-    src_hi1 = in5[i_rev];
-    src_hi2 = in6[i_rev];
-    src_hi3 = in7[i_rev];
-
-    /* Perform scramble.
-     */
-    dst_lo0 = spu_shuffle(src_lo0, src_hi0, shuf_lo);
-    dst_hi0 = spu_shuffle(src_lo0, src_hi0, shuf_hi);
-    dst_lo1 = spu_shuffle(src_lo1, src_hi1, shuf_lo);
-    dst_hi1 = spu_shuffle(src_lo1, src_hi1, shuf_hi);
-    dst_lo2 = spu_shuffle(src_lo2, src_hi2, shuf_lo);
-    dst_hi2 = spu_shuffle(src_lo2, src_hi2, shuf_hi);
-    dst_lo3 = spu_shuffle(src_lo3, src_hi3, shuf_lo);
-    dst_hi3 = spu_shuffle(src_lo3, src_hi3, shuf_hi);
-
-    /* Perform the stage 1 butterfly. The multiplier constant, ppmm,
-     * is used to control the sign of the operands since a single
-     * quadword contains both of P and Q valule of the butterfly.
-     */
-    pq_lo0 = spu_madd(ppmm, dst_lo0, spu_rlqwbyte(dst_lo0, 8));
-    pq_hi0 = spu_madd(ppmm, dst_hi0, spu_rlqwbyte(dst_hi0, 8));
-    pq_lo1 = spu_madd(ppmm, dst_lo1, spu_rlqwbyte(dst_lo1, 8));
-    pq_hi1 = spu_madd(ppmm, dst_hi1, spu_rlqwbyte(dst_hi1, 8));
-    pq_lo2 = spu_madd(ppmm, dst_lo2, spu_rlqwbyte(dst_lo2, 8));
-    pq_hi2 = spu_madd(ppmm, dst_hi2, spu_rlqwbyte(dst_hi2, 8));
-    pq_lo3 = spu_madd(ppmm, dst_lo3, spu_rlqwbyte(dst_lo3, 8));
-    pq_hi3 = spu_madd(ppmm, dst_hi3, spu_rlqwbyte(dst_hi3, 8));
-
-    /* Perfrom the stage 2 butterfly. For this stage, the 
-     * inputs pq are still interleaved (p.real, p.imag, q.real, 
-     * q.imag), so we must first re-order the data into 
-     * parallel arrays as well as perform the reorder 
-     * associated with the twiddle W[n/4], which equals
-     * (0, -1). 
-     *
-     * ie. (A, B) * (0, -1) => (B, -A)
-     */
-    re_lo0 = spu_madd(ppmm, 
-                     spu_shuffle(pq_lo1, pq_lo1, shuf_0303),
-                     spu_shuffle(pq_lo0, pq_lo0, shuf_0202));
-    im_lo0 = spu_madd(pmmp, 
-                     spu_shuffle(pq_lo1, pq_lo1, shuf_1212),
-                     spu_shuffle(pq_lo0, pq_lo0, shuf_1313));
-
-    re_lo1 = spu_madd(ppmm, 
-                     spu_shuffle(pq_lo3, pq_lo3, shuf_0303),
-                     spu_shuffle(pq_lo2, pq_lo2, shuf_0202));
-    im_lo1 = spu_madd(pmmp, 
-                     spu_shuffle(pq_lo3, pq_lo3, shuf_1212),
-                     spu_shuffle(pq_lo2, pq_lo2, shuf_1313));
-
-
-    re_hi0 = spu_madd(ppmm, 
-                     spu_shuffle(pq_hi1, pq_hi1, shuf_0303),
-                     spu_shuffle(pq_hi0, pq_hi0, shuf_0202));
-    im_hi0 = spu_madd(pmmp, 
-                      spu_shuffle(pq_hi1, pq_hi1, shuf_1212),
-                      spu_shuffle(pq_hi0, pq_hi0, shuf_1313));
-
-    re_hi1 = spu_madd(ppmm, 
-                     spu_shuffle(pq_hi3, pq_hi3, shuf_0303),
-                     spu_shuffle(pq_hi2, pq_hi2, shuf_0202));
-    im_hi1 = spu_madd(pmmp, 
-                     spu_shuffle(pq_hi3, pq_hi3, shuf_1212),
-                     spu_shuffle(pq_hi2, pq_hi2, shuf_1313));
-
-
-    /* Perform stage 3 butterfly.
-     */
-    FFT_1D_BUTTERFLY(re0[0], im0[0], re0[1], im0[1], re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
-    FFT_1D_BUTTERFLY(re1[0], im1[0], re1[1], im1[1], re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
-
-    re0 += 2;
-    re1 += 2;
-    im0 += 2; 
-    im1 += 2;
-    
-    i += 8;
-    i_rev = BIT_SWAP(i, reverse) / 2;
-  } while (i < n_2);
-
-  /* Process stages 4 to log2_size-2
-   */
-  for (stage=4, stride=4; stage<log2_size-1; stage++, stride += stride) {
-    w_stride  = n_2 >> stage;
-    w_2stride = n   >> stage;
-    w_3stride = w_stride +  w_2stride;
-    w_4stride = w_2stride + w_2stride;
-
-    W0 = W;
-    W1 = W + w_stride;
-    W2 = W + w_2stride;
-    W3 = W + w_3stride;
-
-    stride_2 = stride >> 1;
-    stride_4 = stride >> 2;
-    stride_3_4 = stride_2 + stride_4;
-
-    re0 = re;              im0 = im;
-    re1 = re + stride_2;   im1 = im + stride_2;   
-    re2 = re + stride_4;   im2 = im + stride_4;   
-    re3 = re + stride_3_4; im3 = im + stride_3_4;   
-
-    for (i=0, offset=0; i<stride_4; i++, offset += w_4stride) {
-      /* Compute the twiddle factors
-       */
-      w0 = W0[offset];
-      w1 = W1[offset];
-      w2 = W2[offset];
-      w3 = W3[offset];
-
-      tmp0 = spu_shuffle(w0, w2, shuf_0415);
-      tmp1 = spu_shuffle(w1, w3, shuf_0415);
-
-      w0_re = spu_shuffle(tmp0, tmp1, shuf_0415);
-      w0_im = spu_shuffle(tmp0, tmp1, shuf_2637);
-
-      j = i;
-      k = i + stride;
-      do {
-       re_lo0 = re0[j]; im_lo0 = im0[j];
-       re_lo1 = re1[j]; im_lo1 = im1[j];
-
-       re_hi0 = re2[j]; im_hi0 = im2[j];
-       re_hi1 = re3[j]; im_hi1 = im3[j];
-
-       re_lo2 = re0[k]; im_lo2 = im0[k];
-       re_lo3 = re1[k]; im_lo3 = im1[k];
-
-       re_hi2 = re2[k]; im_hi2 = im2[k];
-       re_hi3 = re3[k]; im_hi3 = im3[k];
-
-       FFT_1D_BUTTERFLY   (re0[j], im0[j], re1[j], im1[j], re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
-       FFT_1D_BUTTERFLY_HI(re2[j], im2[j], re3[j], im3[j], re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
-
-       FFT_1D_BUTTERFLY   (re0[k], im0[k], re1[k], im1[k], re_lo2, im_lo2, re_lo3, im_lo3, w0_re, w0_im);
-       FFT_1D_BUTTERFLY_HI(re2[k], im2[k], re3[k], im3[k], re_hi2, im_hi2, re_hi3, im_hi3, w0_re, w0_im);
-
-       j += 2 * stride;
-       k += 2 * stride;
-      } while (j < n_4);
-    }
-  }
-
-  /* Process stage log2_size-1. This is identical to the stage processing above
-   * except for this stage the inner loop is only executed once so it is removed
-   * entirely.
-   */
-  w_stride  = n_2 >> stage;
-  w_2stride = n   >> stage;
-  w_3stride = w_stride +  w_2stride;
-  w_4stride = w_2stride + w_2stride;
-
-  stride_2 = stride >> 1;
-  stride_4 = stride >> 2;
-
-  stride_3_4 = stride_2 + stride_4;
-
-  re0 = re;              im0 = im;
-  re1 = re + stride_2;   im1 = im + stride_2;   
-  re2 = re + stride_4;   im2 = im + stride_4;   
-  re3 = re + stride_3_4; im3 = im + stride_3_4;   
-
-  for (i=0, offset=0; i<stride_4; i++, offset += w_4stride) {
-    /* Compute the twiddle factors
-     */
-    w0 = W[offset];
-    w1 = W[offset + w_stride];
-    w2 = W[offset + w_2stride];
-    w3 = W[offset + w_3stride];
-
-    tmp0 = spu_shuffle(w0, w2, shuf_0415);
-    tmp1 = spu_shuffle(w1, w3, shuf_0415);
-
-    w0_re = spu_shuffle(tmp0, tmp1, shuf_0415);
-    w0_im = spu_shuffle(tmp0, tmp1, shuf_2637);
-
-    j = i;
-    k = i + stride;
-
-    re_lo0 = re0[j]; im_lo0 = im0[j];
-    re_lo1 = re1[j]; im_lo1 = im1[j];
-
-    re_hi0 = re2[j]; im_hi0 = im2[j];
-    re_hi1 = re3[j]; im_hi1 = im3[j];
-
-    re_lo2 = re0[k]; im_lo2 = im0[k];
-    re_lo3 = re1[k]; im_lo3 = im1[k];
-
-    re_hi2 = re2[k]; im_hi2 = im2[k];
-    re_hi3 = re3[k]; im_hi3 = im3[k];
-      
-    FFT_1D_BUTTERFLY   (re0[j], im0[j], re1[j], im1[j], re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
-    FFT_1D_BUTTERFLY_HI(re2[j], im2[j], re3[j], im3[j], re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
-
-    FFT_1D_BUTTERFLY   (re0[k], im0[k], re1[k], im1[k], re_lo2, im_lo2, re_lo3, im_lo3, w0_re, w0_im);
-    FFT_1D_BUTTERFLY_HI(re2[k], im2[k], re3[k], im3[k], re_hi2, im_hi2, re_hi3, im_hi3, w0_re, w0_im);
-  }
-
-
-  /* Process the final stage (stage log2_size). For this stage, 
-   * reformat the data from parallel arrays back into 
-   * interleaved arrays,storing the result into <in>.
-   *
-   * This loop has been manually unrolled by 2 to improve 
-   * dual issue rates and reduce stalls. This unrolling
-   * forces a minimum FFT size of 32.
-   */
-  re0 = re;
-  re1 = re + n_8;
-  re2 = re + n_16;
-  re3 = re + n_3_16;
-
-  im0 = im;
-  im1 = im + n_8;
-  im2 = im + n_16;
-  im3 = im + n_3_16;
-
-  out0 = out;
-  out1 = out + n_4;
-  out2 = out + n_8;
-  out3 = out1 + n_8;
-
-  i = n_16;
-
-  do {
-    /* Fetch the twiddle factors
-     */
-    w0 = W[0];
-    w1 = W[1];
-    w2 = W[2];
-    w3 = W[3];
-
-    W += 4;
-
-    w0_re = spu_shuffle(w0, w1, shuf_0246);
-    w0_im = spu_shuffle(w0, w1, shuf_1357);
-    w1_re = spu_shuffle(w2, w3, shuf_0246);
-    w1_im = spu_shuffle(w2, w3, shuf_1357);
-
-    /* Fetch the butterfly inputs, reals and imaginaries
-     */
-    re_lo0 = re0[0]; im_lo0 = im0[0];
-    re_lo1 = re1[0]; im_lo1 = im1[0];
-    re_lo2 = re0[1]; im_lo2 = im0[1];
-    re_lo3 = re1[1]; im_lo3 = im1[1];
-
-    re_hi0 = re2[0]; im_hi0 = im2[0];
-    re_hi1 = re3[0]; im_hi1 = im3[0];
-    re_hi2 = re2[1]; im_hi2 = im2[1];
-    re_hi3 = re3[1]; im_hi3 = im3[1];
-
-    re0 += 2; im0 += 2;
-    re1 += 2; im1 += 2;
-    re2 += 2; im2 += 2;
-    re3 += 2; im3 += 2;
-
-    /* Perform the butterflys
-     */
-    FFT_1D_BUTTERFLY   (out_re_lo0, out_im_lo0, out_re_lo1, out_im_lo1, re_lo0, im_lo0, re_lo1, im_lo1, w0_re, w0_im);
-    FFT_1D_BUTTERFLY   (out_re_lo2, out_im_lo2, out_re_lo3, out_im_lo3, re_lo2, im_lo2, re_lo3, im_lo3, w1_re, w1_im);
-
-    FFT_1D_BUTTERFLY_HI(out_re_hi0, out_im_hi0, out_re_hi1, out_im_hi1, re_hi0, im_hi0, re_hi1, im_hi1, w0_re, w0_im);
-    FFT_1D_BUTTERFLY_HI(out_re_hi2, out_im_hi2, out_re_hi3, out_im_hi3, re_hi2, im_hi2, re_hi3, im_hi3, w1_re, w1_im);
-
-    /* Interleave the results and store them into the output buffers (ie,
-     * the original input buffers.
-     */
-    out0[0] = spu_shuffle(out_re_lo0, out_im_lo0, shuf_0415);
-    out0[1] = spu_shuffle(out_re_lo0, out_im_lo0, shuf_2637);
-    out0[2] = spu_shuffle(out_re_lo2, out_im_lo2, shuf_0415);
-    out0[3] = spu_shuffle(out_re_lo2, out_im_lo2, shuf_2637);
-
-    out1[0] = spu_shuffle(out_re_lo1, out_im_lo1, shuf_0415);
-    out1[1] = spu_shuffle(out_re_lo1, out_im_lo1, shuf_2637);
-    out1[2] = spu_shuffle(out_re_lo3, out_im_lo3, shuf_0415);
-    out1[3] = spu_shuffle(out_re_lo3, out_im_lo3, shuf_2637);
-
-    out2[0] = spu_shuffle(out_re_hi0, out_im_hi0, shuf_0415);
-    out2[1] = spu_shuffle(out_re_hi0, out_im_hi0, shuf_2637);
-    out2[2] = spu_shuffle(out_re_hi2, out_im_hi2, shuf_0415);
-    out2[3] = spu_shuffle(out_re_hi2, out_im_hi2, shuf_2637);
-
-    out3[0] = spu_shuffle(out_re_hi1, out_im_hi1, shuf_0415);
-    out3[1] = spu_shuffle(out_re_hi1, out_im_hi1, shuf_2637);
-    out3[2] = spu_shuffle(out_re_hi3, out_im_hi3, shuf_0415);
-    out3[3] = spu_shuffle(out_re_hi3, out_im_hi3, shuf_2637);
-
-    out0 += 4;
-    out1 += 4;
-    out2 += 4;
-    out3 += 4;
-
-    i -= 2;
-  } while (i);
-}
-
-#endif /* _FFT_1D_R2_H_ */
diff --git a/gcell/src/lib/general/spu/gc_spu_macs.h b/gcell/src/lib/general/spu/gc_spu_macs.h
deleted file mode 100644 (file)
index 8e3e3f2..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/* -*- asm -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_SPU_MACS_H
-#define INCLUDED_GC_SPU_MACS_H
-
-/*
- * This file contains a set of macros that are generally useful when
- * coding in SPU assembler
- *
- * Note that the multi-instruction macros in here may overwrite
- * registers 77, 78, and 79 without warning.
- */
-
-/*
- * defines for all registers
- */
-#define r0     $0
-#define r1     $1
-#define r2     $2
-#define r3     $3
-#define r4     $4
-#define r5     $5
-#define r6     $6
-#define r7     $7
-#define r8     $8
-#define r9     $9
-#define r10    $10
-#define r11    $11
-#define r12    $12
-#define r13    $13
-#define r14    $14
-#define r15    $15
-#define r16    $16
-#define r17    $17
-#define r18    $18
-#define r19    $19
-#define r20    $20
-#define r21    $21
-#define r22    $22
-#define r23    $23
-#define r24    $24
-#define r25    $25
-#define r26    $26
-#define r27    $27
-#define r28    $28
-#define r29    $29
-#define r30    $30
-#define r31    $31
-#define r32    $32
-#define r33    $33
-#define r34    $34
-#define r35    $35
-#define r36    $36
-#define r37    $37
-#define r38    $38
-#define r39    $39
-#define r40    $40
-#define r41    $41
-#define r42    $42
-#define r43    $43
-#define r44    $44
-#define r45    $45
-#define r46    $46
-#define r47    $47
-#define r48    $48
-#define r49    $49
-#define r50    $50
-#define r51    $51
-#define r52    $52
-#define r53    $53
-#define r54    $54
-#define r55    $55
-#define r56    $56
-#define r57    $57
-#define r58    $58
-#define r59    $59
-#define r60    $60
-#define r61    $61
-#define r62    $62
-#define r63    $63
-#define r64    $64
-#define r65    $65
-#define r66    $66
-#define r67    $67
-#define r68    $68
-#define r69    $69
-#define r70    $70
-#define r71    $71
-#define r72    $72
-#define r73    $73
-#define r74    $74
-#define r75    $75
-#define r76    $76
-#define r77    $77
-#define r78    $78
-#define r79    $79
-#define r80    $80
-#define r81    $81
-#define r82    $82
-#define r83    $83
-#define r84    $84
-#define r85    $85
-#define r86    $86
-#define r87    $87
-#define r88    $88
-#define r89    $89
-#define r90    $90
-#define r91    $91
-#define r92    $92
-#define r93    $93
-#define r94    $94
-#define r95    $95
-#define r96    $96
-#define r97    $97
-#define r98    $98
-#define r99    $99
-#define r100   $100
-#define r101   $101
-#define r102   $102
-#define r103   $103
-#define r104   $104
-#define r105   $105
-#define r106   $106
-#define r107   $107
-#define r108   $108
-#define r109   $109
-#define r110   $110
-#define r111   $111
-#define r112   $112
-#define r113   $113
-#define r114   $114
-#define r115   $115
-#define r116   $116
-#define r117   $117
-#define r118   $118
-#define r119   $119
-#define r120   $120
-#define r121   $121
-#define r122   $122
-#define r123   $123
-#define r124   $124
-#define r125   $125
-#define r126   $126
-#define r127   $127
-
-
-#define        lr      r0      // link register
-#define        sp      r1      // stack pointer
-                        // r2 is environment pointer for langs that need it (ALGOL)
-
-#define        retval  r3      // return values are passed in regs starting at r3
-
-#define        arg1    r3      // args are passed in regs starting at r3
-#define        arg2    r4
-#define        arg3    r5
-#define        arg4    r6
-#define        arg5    r7
-#define        arg6    r8
-#define        arg7    r9
-#define        arg8    r10
-#define        arg9    r11
-#define        arg10   r12
-
-//  r3 -  r74 are volatile (caller saves)
-// r74 -  r79 are volatile (scratch regs possibly destroyed by fct prolog/epilog)
-// r80 - r127 are non-volatile (caller-saves)
-
-// scratch registers reserved for use by the macros in this file.
-
-#define _gc_t0 r79
-#define        _gc_t1  r78
-#define        _gc_t2  r77
-
-/*
- * ----------------------------------------------------------------
- *                         pseudo ops
- * ----------------------------------------------------------------
- */
-#define PROC_ENTRY(name)               \
-        .text;                         \
-       .p2align 4;                     \
-       .global name;                   \
-       .type   name, @function;        \
-name:
-
-/*
- * ----------------------------------------------------------------
- *                 aliases for common operations
- * ----------------------------------------------------------------
- */
-
-// Move register (even pipe, 2 cycles)
-#define MR(rt, ra)                     or      rt, ra, ra;
-
-// Move register (odd pipe, 4 cycles)
-#define        LMR(rt, ra)                     rotqbyi rt, ra, 0;
-
-// return
-#define        RETURN()                        bi      lr;
-
-// hint for a return
-#define        HINT_RETURN(ret_label)          hbr     ret_label, lr;
-
-// return if zero
-#define BRZ_RETURN(rt)                 biz     rt, lr;
-
-// return if not zero
-#define BRNZ_RETURN(rt)                        binz    rt, lr;
-
-// return if halfword zero
-#define        BRHZ_RETURN(rt)                 bihz    rt, lr;
-
-// return if halfword not zero
-#define BRHNZ_RETURN(rt)               bihnz   rt, lr;
-
-
-/*
- * ----------------------------------------------------------------
- * modulo like things for constant moduli that are powers of 2
- * ----------------------------------------------------------------
- */
-
-// rt = ra & (pow2 - 1)
-#define MODULO(rt, ra, pow2) \
-       andi    rt, ra, (pow2)-1;
-
-// rt = pow2 - (ra & (pow2 - 1))
-#define MODULO_NEG(rt, ra, pow2) \
-       andi    rt, ra, (pow2)-1;               \
-       sfi     rt, rt, (pow2);
-
-// rt = ra & -(pow2)
-#define        ROUND_DOWN(rt, ra, pow2) \
-       andi    rt, ra, -(pow2);
-
-// rt = (ra + (pow2 - 1)) & -(pow2)
-#define ROUND_UP(rt, ra, pow2) \
-       ai      rt, ra, (pow2)-1;               \
-       andi    rt, rt, -(pow2);
-
-/*
- * ----------------------------------------------------------------
- * Splat - replicate a particular slot into all slots
- * Altivec analogs...
- * ----------------------------------------------------------------
- */
-
-// replicate byte from slot s [0,15]
-#define VSPLTB(rt, ra, s) \
-       ilh     _gc_t0, (s)*0x0101;             \
-       shufb   rt, ra, ra, _gc_t0;
-
-// replicate halfword from slot s [0,7]
-#define        VSPLTH(rt, ra, s) \
-       ilh     _gc_t0, 2*(s)*0x0101 + 0x0001;  \
-       shufb   rt, ra, ra, _gc_t0;
-
-// replicate word from slot s [0,3]
-#define VSPLTW(rt, ra, s) \
-       iluh    _gc_t0, 4*(s)*0x0101 + 0x0001;  \
-       iohl    _gc_t0, 4*(s)*0x0101 + 0x0203;  \
-       shufb   rt, ra, ra, _gc_t0;
-       
-// replicate double from slot s [0,1]
-#define        VSPLTD(rt, ra, s) \
-       /* sp is always 16-byte aligned */ \
-       cdd     _gc_t0, 8(sp);          /* 0x10111213 14151617 00010203 04050607 */ \
-       rotqbyi rt, ra, ra, (s) << 3;   /* rotate double into preferred slot     */ \
-       shufb   rt, rt, rt, _gc_t0;
-
-/*
- * ----------------------------------------------------------------
- * lots of min/max variations...
- *
- * On a slot by slot basis, compute the min or max
- *
- * U - unsigned, else signed
- * B,H,{} - byte, halfword, word
- * F float
- * ----------------------------------------------------------------
- */
-
-#define MIN_SELB(rt, ra, rb, rc)       selb    rt, ra, rb, rc;
-#define MAX_SELB(rt, ra, rb, rc)       selb    rt, rb, ra, rc;
-       
-       // words
-
-#define MIN(rt, ra, rb) \
-       cgt     _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        MAX(rt, ra, rb) \
-       cgt     _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-#define UMIN(rt, ra, rb) \
-       clgt    _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        UMAX(rt, ra, rb) \
-       clgt    _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-       // bytes
-       
-#define MINB(rt, ra, rb) \
-       cgtb    _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        MAXB(rt, ra, rb) \
-       cgtb    _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-#define UMINB(rt, ra, rb) \
-       clgtb   _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        UMAXB(rt, ra, rb) \
-       clgtb   _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-       // halfwords
-       
-#define MINH(rt, ra, rb) \
-       cgth    _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        MAXH(rt, ra, rb) \
-       cgth    _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-#define UMINH(rt, ra, rb) \
-       clgth   _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        UMAXH(rt, ra, rb) \
-       clgth   _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-       // floats
-       
-#define FMIN(rt, ra, rb) \
-       fcgt    _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-#define        FMAX(rt, ra, rb) \
-       fcgt    _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-// Ignoring the sign, select the values with the minimum magnitude
-#define FMINMAG(rt, ra, rb) \
-       fcmgt   _gc_t0, ra, rb; \
-       MIN_SELB(rt, ra, rb, _gc_t0)
-       
-// Ignoring the sign, select the values with the maximum magnitude
-#define        FMAXMAG(rt, ra, rb) \
-       fcmgt   _gc_t0, ra, rb; \
-       MAX_SELB(rt, ra, rb, _gc_t0)
-
-
-#endif /* INCLUDED_GC_SPU_MACS_H */
diff --git a/gcell/src/lib/general/spu/libfft.h b/gcell/src/lib/general/spu/libfft.h
deleted file mode 100644 (file)
index dd387be..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* --------------------------------------------------------------  */
-/* (C)Copyright 2008 Free Software Foundation, Inc.                */
-/* (C)Copyright 2001,2007,                                         */
-/* International Business Machines Corporation,                    */
-/* Sony Computer Entertainment, Incorporated,                      */
-/* Toshiba Corporation,                                            */
-/*                                                                 */
-/* All Rights Reserved.                                            */
-/*                                                                 */
-/* Redistribution and use in source and binary forms, with or      */
-/* without modification, are permitted provided that the           */
-/* following conditions are met:                                   */
-/*                                                                 */
-/* - Redistributions of source code must retain the above copyright*/
-/*   notice, this list of conditions and the following disclaimer. */
-/*                                                                 */
-/* - Redistributions in binary form must reproduce the above       */
-/*   copyright notice, this list of conditions and the following   */
-/*   disclaimer in the documentation and/or other materials        */
-/*   provided with the distribution.                               */
-/*                                                                 */
-/* - Neither the name of IBM Corporation nor the names of its      */
-/*   contributors may be used to endorse or promote products       */
-/*   derived from this software without specific prior written     */
-/*   permission.                                                   */
-/*                                                                 */
-/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
-/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
-/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
-/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
-/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
-/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
-/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
-/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
-/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
-/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
-/* --------------------------------------------------------------  */
-/* PROLOG END TAG zYx                                              */
-
-#ifndef INCLUDED_LIBFFT_H
-#define INCLUDED_LIBFFT_H
-
-// must be defined before inclusion of fft_1d_r2.h
-#define MAX_FFT_1D_SIZE 4096
-
-/* fft_1d_r2
- * ---------
- * Performs a single precision, complex Fast Fourier Transform using 
- * the DFT (Discrete Fourier Transform) with radix-2 decimation in time. 
- * The input <in> is an array of complex numbers of length (1<<log2_size)
- * entries. The result is returned in the array of complex numbers specified
- * by <out>. Note: This routine can support an in-place transformation
- * by specifying <in> and <out> to be the same array.
- *
- * This implementation utilizes the Cooley-Tukey algorithm consisting 
- * of <log2_size> stages. The basic operation is the butterfly.
- *
- *          p --------------------------> P = p + q*Wi
- *                        \      /
- *                         \    /
- *                          \  /
- *                           \/
- *                           /\
- *                          /  \
- *                         /    \
- *               ____     /      \
- *          q --| Wi |-----------------> Q = p - q*Wi
- *               ----
- *
- * This routine also requires pre-computed twiddle values, W. W is an
- * array of single precision complex numbers of length 1<<(log2_size-2) 
- * and is computed as follows:
- *
- *     for (i=0; i<n/4; i++)
- *         W[i].real =  cos(i * 2*PI/n);
- *         W[i].imag = -sin(i * 2*PI/n);
- *      }
- *
- * This array actually only contains the first half of the twiddle
- * factors. Due for symmetry, the second half of the twiddle factors
- * are implied and equal:
- *
- *     for (i=0; i<n/4; i++)
- *         W[i+n/4].real =  W[i].imag =  sin(i * 2*PI/n);
- *         W[i+n/4].imag = -W[i].real = -cos(i * 2*PI/n);
- *      }
- *
- * Further symmetry allows one to generate the twiddle factor table 
- * using half the number of trig computations as follows:
- *
- *      W[0].real = 1.0;
- *      W[0].imag = 0.0;
- *     for (i=1; i<n/4; i++)
- *         W[i].real =  cos(i * 2*PI/n);
- *         W[n/4 - i].imag = -W[i].real;
- *      }
- *
- * The complex numbers are packed into quadwords as follows:
- *
- *    quadword                       complex
- *  array element                   array elements
- *             -----------------------------------------------------
- *       i    |  real 2*i   |  imag 2*i  | real 2*i+1  | imag 2*i+1 | 
- *             -----------------------------------------------------
- *
- */
-
-void fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size);
-
-#endif /* INCLUDED_LIBFFT_H */
diff --git a/gcell/src/lib/general/spu/memset.S b/gcell/src/lib/general/spu/memset.S
deleted file mode 100644 (file)
index 88e2dbe..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- asm -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <gc_spu_macs.h>
-
-       .file "memset.S"
-
-       /*
-        * Computes this, only a lot faster...
-        *
-        *      void *
-        *      memset(void *pv, int c, size_t n)
-        *      {
-        *        unsigned char *p = (unsigned char *) pv;
-        *        size_t i;
-        *        for (i = 0; i < n; i++)
-        *          p[i] = c;
-        *      
-        *        return pv;
-        *      }
-        */
-       
-#define        p_arg   arg1    // we're going to clobber arg1 w/ the return value
-#define        c       arg2    // the constant we're writing
-#define        n       arg3    // how many bytes to write
-
-#define        p       r13     // where we're writing
-#define        t0      r14
-#define t1     r15
-#define        mask    r16
-#define        old     r17
-#define an     r18     // aligned n (n rounded down to mod 16 boundary)
-#define        next_p  r19
-#define        cond1   r20
-#define        cond2   r21                             
-#define m      r22
-#define r      r23
-       
-       PROC_ENTRY(memset)
-       
-       // Hint the return from do_head, in case we go that way.
-       // There's pretty much nothing to can do to hint the branch to it.
-       hbrr    do_head_br, head_complete
-       
-       MR(p, p_arg)    // leaves p, the return value, in the correct reg (r3)
-       BRZ_RETURN(n)
-
-       MODULO(t0, p, 16)       // is p%16 == 0?
-       VSPLTB(c, c, 3)         // splat byte in preferred slot of c into all slots
-       brnz    t0, do_head     // no, handle it
-head_complete:
-
-       /*
-        * preconditions:       
-        *   p%16 == 0, n > 0
-        */
-       hbrr    middle_loop_br, middle_loop
-       
-       ROUND_DOWN(an, n, 16)   // an is "aligned n"
-       MODULO(n, n, 16)        // what's left over in the last quad
-       brz     an, do_tail     // no whole quad words; skip to tail
-       clgti   t0, an, 127     // an >= 128?
-       brz     t0, middle2     // nope, go handle the cases between 0 and 112
-
-       /*
-        * 128 bytes / iteration
-        */
-       .p2align 4
-middle_loop:
-       ai      an, an, -128
-         stqd  c,  0*16(p)
-       ai      next_p, p, 128
-         stqd  c,  1*16(p)
-       cgti    cond1, an, 127
-         stqd  c,  2*16(p)
-
-         stqd  c,  3*16(p)
-         stqd  c,  4*16(p)
-         stqd  c,  5*16(p)
-         stqd  c,  6*16(p)
-       
-       MR(p, next_p)
-         stqd  c,  7*16-128(next_p)
-       or      cond2, n, an
-middle_loop_br:
-         brnz  cond1, middle_loop
-       
-       /*
-        * if an and n are both zero, return now 
-        */
-       BRZ_RETURN(cond2)
-
-       /*
-        * otherwise handle last of full quad words 
-        *
-        *   0 <= an < 128, p%16 == 0
-        */
-middle2:
-       /*
-        * if an == 0, go handle the final non-full quadword
-        */
-       brz     an, do_tail
-       hbrr    middle2_loop_br, middle2_loop
-       
-       .p2align 3
-middle2_loop:  
-       ai      next_p, p, 16
-         stqd  c, 0(p)
-       ai      an, an, -16
-         LMR(p, next_p)
-middle2_loop_br:
-         brnz  an, middle2_loop
-       
-       /* We're done with the full quadwords. */
-       
-       /*
-        * Handle the final partial quadword.
-        * We'll be modifying only the left hand portion of the quad.
-        *
-        * preconditions:
-        *   an == 0, 0 <= n < 16, p%16 == 0
-        */
-do_tail:
-       HINT_RETURN(do_tail_ret)
-       il      mask, -1
-       sfi     t1, n, 16               // t1 = 16 - n
-       lqd     old, 0(p)
-       shlqby  mask, mask, t1
-       selb    t0, old, c, mask
-       stqd    t0, 0(p)
-do_tail_ret:   
-       RETURN()
-
-       /*
-        * ----------------------------------------------------------------
-        * Handle the first partial quadword
-        *
-        * preconditions:
-        *   p%16 != 0
-        *
-         * postconditions:
-         *   p%16 == 0 or n == 0
-         *
-         *        |-- m --|
-         *     +----------------+----------------+
-         *     |  ////////      |                |
-         *     +----------------+----------------+
-         *        |----- r -----|
-         *        p
-         * ----------------------------------------------------------------
-        */
-do_head:
-       lqd     old, 0(p)
-       MODULO_NEG(r, p, 16)
-       il      mask, -1
-       UMIN(m, r, n)
-       shlqby  mask, mask, m   // 1's in the top, m*8 0's in the bottom
-       MR(t1, p)
-       sf      t0, m, r        // t0 = r - m
-       a       p, p, m         // p += m
-       rotqby  mask, mask, t0  // rotate 0's to the right place        
-       sf      n, m, n         // n -= m
-       selb    t0, c, old, mask // merge
-       stqd    t0, 0(t1)
-       BRZ_RETURN(n)
-do_head_br:
-       br      head_complete
diff --git a/gcell/src/lib/general/spu/qa_memset.c b/gcell/src/lib/general/spu/qa_memset.c
deleted file mode 100644 (file)
index 0d35a42..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <gc_declare_proc.h>
-#include <string.h>
-#include <stdio.h>
-#include <spu_intrinsics.h>
-#include <spu_mfcio.h>
-
-
-#define MAX_QA_BYTES  1024
-#define        MAX_OFFSET    32
-#define        ALIGNMENT     16
-#define        K             0xA5
-
-// FIXME should be passed at gcell init time
-//static const int TIMEBASE = 79800000; // ps3
-static const int TIMEBASE = 26666666; // qs21
-
-typedef void* (*memset_fptr)(void *s, int val, size_t n);
-
-void *
-memset_ref(void *sv, int c, size_t n)
-{
-  unsigned char *s = (unsigned char *) sv;
-  size_t i;
-  for (i = 0; i < n; i++)
-    s[i] = c;
-
-  return sv;
-}
-
-static bool
-check_before(unsigned char *buf, size_t len, size_t offset)
-{
-  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
-  bool ok = true;
-  int i;
-
-  for (i = -16; i < 0; i++){
-    unsigned char expected = (&p[i] - buf) & 0xff;
-    if (p[i] != expected){
-      printf("b:memset(%p, 0x%x, %zu) <offset %2zd> [%3d] expected %02x, got %02x\n",
-            p, K, len, offset, i, K, p[i]);
-      ok = false;
-    }
-  }
-  return ok;
-}
-
-static bool
-check_middle(unsigned char *buf, size_t len, size_t offset)
-{
-  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
-  bool ok = true;
-  size_t i;
-
-  for (i = 0; i < len; i++){
-    unsigned char expected = K;
-    if (p[i] != expected){
-      printf("m:memset(%p, 0x%x, %zu) <offset %2zd> [%3zd] expected %02x, got %02x\n",
-            p, K, len, offset, i, expected, p[i]);
-      ok = false;
-    }
-  }
-  return ok;
-}
-
-static bool
-check_after(unsigned char *buf, size_t len, size_t offset)
-{
-  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
-  bool ok = true;
-  size_t i;
-
-  for (i = len; i < len + 16; i++){
-    unsigned char expected = (&p[i] - buf) & 0xff;
-    if (p[i] != expected){
-      printf("a:memset(%p, 0x%x, %zu) <offset %2zd> [%3zd] expected %02x, got %02x\n",
-            p, K, len, offset, i, expected, p[i]);
-      ok = false;
-    }
-  }
-  return ok;
-}
-
-
-static bool
-test_memset_aux(memset_fptr f,
-               unsigned char *buf, size_t buflen, size_t len, size_t offset)
-{
-  size_t i;
-
-  // init buffer to non-zero known state
-  for (i = 0; i < buflen; i++)
-    buf[i] = i;
-  
-  // Our working buffer.  Starts 16 bytes + offset into buf.
-  // We offset by 16 so that we can see if data before is getting damaged.
-  unsigned char *p = buf + sizeof(vector unsigned char) + offset;
-
-  (*f)(p, K, len);
-
-  bool ok = true;
-  ok &= check_before(buf, len, offset);
-  ok &= check_middle(buf, len, offset);
-  ok &= check_after(buf, len, offset);
-
-  return ok;
-}
-
-bool
-test_memset(memset_fptr f)
-{
-  size_t BUFLEN = MAX_QA_BYTES + 2*sizeof(vector unsigned char) + MAX_OFFSET;
-  unsigned char unaligned_buf[BUFLEN + ALIGNMENT -1];
-  unsigned char *aligned_buf =
-    (unsigned char *)((((intptr_t) unaligned_buf) + ALIGNMENT - 1) & -ALIGNMENT);
-
-  // printf("unaligned = %p\n", unaligned_buf);
-  // printf("aligned   = %p\n", aligned_buf);
-
-  size_t len;
-  size_t offset;
-  bool ok = true;
-
-  for (len = 0; len < MAX_QA_BYTES; len++){
-    for (offset = 0; offset <= MAX_OFFSET; offset++){
-      ok &= test_memset_aux(f, aligned_buf, BUFLEN, len, offset);
-    }
-  }
-
-  return ok;
-}
-
-// returns bytes/s
-float
-benchmark_memset(memset_fptr f, bool aligned)
-{
-  static const int SIZE = 32768;
-  unsigned char buf[SIZE];
-  uint32_t     t0, t1;
-  int          nbytes;
-
-  spu_write_decrementer(0xffffffff);
-
-  if (aligned){
-    nbytes = SIZE;
-    t0 = spu_read_decrementer();
-    (*f)(buf, 0x55, nbytes);
-    (*f)(buf, 0x55, nbytes);
-    (*f)(buf, 0x55, nbytes);
-    (*f)(buf, 0x55, nbytes);
-    t1 = spu_read_decrementer();
-  }
-  else {
-    nbytes = SIZE - 2;
-    t0 = spu_read_decrementer();
-    (*f)(buf + 1, 0x55, nbytes);
-    (*f)(buf + 1, 0x55, nbytes);
-    (*f)(buf + 1, 0x55, nbytes);
-    (*f)(buf + 1, 0x55, nbytes);
-    t1 = spu_read_decrementer();
-  }
-
-  //printf("delta ticks: %d\n", t0 - t1);
-  return (float) nbytes * 4 / ((t0 - t1) * 1.0/TIMEBASE);
-}
-
-/*
- * Implement the standard QA stub.
- * No input arguments, 1 bool output.
- */
-static void
-gcs_qa_memset(const gc_job_direct_args_t *input _UNUSED,
-             gc_job_direct_args_t *output,
-             const gc_job_ea_args_t *eaa _UNUSED)
-{
-  bool ok = test_memset(memset);
-  output->arg[0].u32 = ok;
-}
-
-GC_DECLARE_PROC(gcs_qa_memset, "qa_memset");
diff --git a/gcell/src/lib/runtime/Makefile.am b/gcell/src/lib/runtime/Makefile.am
deleted file mode 100644 (file)
index 89d6f1b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Copyright 2007,2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/src/ibm/sync/ppu_source
-
-
-AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(MBLOCK_INCLUDES) $(CPPUNIT_INCLUDES) \
-       $(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) $(WITH_INCLUDES)
-
-
-dist_bin_SCRIPTS = gcell-embedspu-libtool
-
-noinst_LTLIBRARIES = libruntime.la libruntime-qa.la
-
-libruntime_la_SOURCES = \
-       gc_aligned_alloc.cc \
-       gc_job_manager.cc \
-       gc_job_manager_impl.cc \
-       gc_jd_queue.c \
-       gc_jd_stack.c \
-       gc_proc_def_utils.cc
-
-libruntime_qa_la_SOURCES = \
-       qa_gcell_runtime.cc \
-       qa_jd_queue.cc \
-       qa_jd_stack.cc \
-       qa_job_manager.cc
-
-
-gcellinclude_HEADERS = \
-       gc_aligned_alloc.h \
-       gc_job_manager.h
-
-noinst_HEADERS = \
-       gc_client_thread_info.h \
-       gc_job_manager_impl.h \
-       gc_proc_def_utils.h \
-       qa_jd_queue.h \
-       qa_jd_stack.h \
-       qa_job_manager.h \
-       qa_gcell_runtime.h
-
-# generate a libtool.lo that contains an embeded SPU executable
-gcell_runtime_qa.lo: ../spu/gcell_runtime_qa
-       $(GCELL_EMBEDSPU_LIBTOOL) $@ $<
-
-libruntime_qa_la_LIBADD = \
-       gcell_runtime_qa.lo \
-       libruntime.la
-
-CLEANFILES = gcell_runtime_qa.lo
diff --git a/gcell/src/lib/runtime/gc_aligned_alloc.cc b/gcell/src/lib/runtime/gc_aligned_alloc.cc
deleted file mode 100644 (file)
index 6f9a999..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <gc_aligned_alloc.h>
-#include <stdlib.h>
-#include <stdexcept>
-#include <string.h>
-
-// custom deleter of anything that can be freed with "free"
-class free_deleter {
-public:
-  void operator()(void *p) {
-    free(p);
-  }
-};
-
-void *
-gc_aligned_alloc(size_t size, size_t alignment)
-{
-  void *p = 0;
-  if (posix_memalign(&p, alignment, size) != 0){
-    perror("posix_memalign");
-    throw std::runtime_error("memory");
-  }
-  memset(p, 0, size);          // zero the memory
-  return p;
-}
-
-boost::shared_ptr<void>
-gc_aligned_alloc_sptr(size_t size, size_t alignment)
-{
-  return boost::shared_ptr<void>(gc_aligned_alloc(size, alignment),
-                                free_deleter());
-}
diff --git a/gcell/src/lib/runtime/gc_aligned_alloc.h b/gcell/src/lib/runtime/gc_aligned_alloc.h
deleted file mode 100644 (file)
index bdc21c2..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_ALIGNED_ALLOC_H
-#define INCLUDED_GC_ALIGNED_ALLOC_H
-
-#include <boost/shared_ptr.hpp>
-
-/*!
- * \brief Return pointer to chunk of storage of size size bytes.
- * The allocation will be aligned to an \p alignment boundary.
- *
- * \param size is the number of bytes to allocate
- * \param alignment is the minimum storage alignment in bytes; must be a power of 2.
- *
- * Throws if can't allocate memory.  The storage should be freed
- * with "free" when done.  The memory is initialized to zero.
- */
-void *
-gc_aligned_alloc(size_t size, size_t alignment = 128);
-
-/*!
- * \brief Return boost::shared_ptr to chunk of storage of size size bytes.
- * The allocation will be aligned to an \p alignment boundary.
- *
- * \param size is the number of bytes to allocate
- * \param alignment is the minimum storage alignment in bytes; must be a power of 2.
- *
- * Throws if can't allocate memory.  The storage should be freed
- * with "free" when done.  The memory is initialized to zero.
- */
-boost::shared_ptr<void>
-gc_aligned_alloc_sptr(size_t size, size_t alignment = 128);
-
-#endif /* INCLUDED_GC_ALIGNED_ALLOC_H */
diff --git a/gcell/src/lib/runtime/gc_client_thread_info.h b/gcell/src/lib/runtime/gc_client_thread_info.h
deleted file mode 100644 (file)
index fbb35d9..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_CLIENT_THREAD_INFO_H
-#define INCLUDED_GC_CLIENT_THREAD_INFO_H
-
-#include <omnithread.h>
-#include <boost/utility.hpp>
-
-enum gc_ct_state {
-  CT_NOT_WAITING,
-  CT_WAIT_ALL,
-  CT_WAIT_ANY,
-};
-
-/*
- * \brief per client-thread data used by gc_job_manager
- *
- * "Client threads" are any threads that invoke methods on
- * gc_job_manager.  We use pthread_set_specific to store a pointer to
- * one of these for each thread that comes our way.
- */
-class gc_client_thread_info : boost::noncopyable {
-public:
-  gc_client_thread_info() :
-    d_free(1), d_cond(&d_mutex), d_state(CT_NOT_WAITING),
-    d_jobs_done(0), d_njobs_waiting_for(0),
-    d_jobs_waiting_for(0){ }
-
-  ~gc_client_thread_info() {
-    d_free = 1;
-    d_state = CT_NOT_WAITING;
-    d_jobs_done = 0;
-    d_njobs_waiting_for = 0;
-    d_jobs_waiting_for = 0;
-  }
-
-  //! is this cti free? (1->free, 0->in use)
-  uint32_t       d_free;
-
-  //! which client info are we?
-  uint16_t       d_client_id;
-
-  //! hold this mutex to manipulate anything below here
-  omni_mutex     d_mutex;
-
-  //! signaled by event handler to wake client thread up
-  omni_condition  d_cond;
-
-  //! Is this client waiting?
-  gc_ct_state    d_state;
-  
-  //! Jobs that have finished and not yet been waited for (bitvector)
-  unsigned long         *d_jobs_done;
-
-  //! # of jobs we're waiting for
-  unsigned int    d_njobs_waiting_for;
-
-  //! Jobs that client thread is waiting for
-  gc_job_desc   **d_jobs_waiting_for;
-
-};
-
-#endif /* INCLUDED_GC_CLIENT_THREAD_INFO_H */
diff --git a/gcell/src/lib/runtime/gc_jd_queue.c b/gcell/src/lib/runtime/gc_jd_queue.c
deleted file mode 100644 (file)
index b5cdcac..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "gc_jd_queue.h"
-#include "memory_barrier.h"
-#include <mutex_init.h>
-#include <mutex_lock.h>
-#include <mutex_unlock.h>
-
-void 
-gc_jd_queue_init(gc_jd_queue_t *q)
-{
-  _mutex_init(ptr_to_ea(&q->mutex));
-  q->head = 0;
-  q->tail = 0;
-  smp_wmb();
-}
-  
-void
-gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item)
-{
-  item->sys.next = 0;
-  _mutex_lock(ptr_to_ea(&q->mutex));
-  smp_rmb();           // import barrier
-
-  if (q->tail == 0){    // currently empty
-    q->tail = q->head = jdp_to_ea(item);
-  }
-  else {               // not empty, append
-    ea_to_jdp(q->tail)->sys.next = jdp_to_ea(item);
-    q->tail = jdp_to_ea(item);
-  }
-
-  smp_wmb();           // orders stores above before clearing of mutex
-  _mutex_unlock(ptr_to_ea(&q->mutex));
-}
-
-gc_job_desc_t *
-gc_jd_queue_dequeue(gc_jd_queue_t *q)
-{
-  _mutex_lock(ptr_to_ea(&q->mutex));
-  smp_rmb();           // import barrier
-  
-  gc_eaddr_t item_ea = q->head;
-  if (item_ea == 0){   // empty
-    _mutex_unlock(ptr_to_ea(&q->mutex));
-    return 0;
-  }
-
-  q->head = ea_to_jdp(item_ea)->sys.next;
-  if (q->head == 0)    // now emtpy
-    q->tail = 0;
-
-  gc_job_desc_t *item = ea_to_jdp(item_ea);
-  item->sys.next = 0;
-
-  smp_wmb();           // orders stores above before clearing of mutex
-  _mutex_unlock(ptr_to_ea(&q->mutex));
-  return item;
-}
diff --git a/gcell/src/lib/runtime/gc_jd_stack.c b/gcell/src/lib/runtime/gc_jd_stack.c
deleted file mode 100644 (file)
index 0fffc0d..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "gc_jd_stack.h"
-#include "memory_barrier.h"
-
-
-void 
-gc_jd_stack_init(gc_jd_stack_t *stack)
-{
-  stack->top = 0;
-}
-  
-
-#ifdef __powerpc64__  // 64-bit mode
-
-void 
-gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item)
-{
-  gc_eaddr_t   top;
-  gc_eaddr_t   item_ea = ptr_to_ea(item);
-  unsigned int done;
-
-  do {
-    top = __ldarx(&stack->top);
-    item->sys.next = top;
-    smp_wmb();       // order store of item->next before store of stack->top
-    done = __stdcx(&stack->top, item_ea);
-  } while (unlikely(done == 0));
-}
-
-gc_job_desc_t *
-gc_jd_stack_pop(gc_jd_stack_t *stack)
-{
-  gc_eaddr_t   s;
-  gc_eaddr_t   t;
-  unsigned int done;
-
-  do {
-    s  = __ldarx(&stack->top);
-    if (s == 0)                        /* stack's empty */
-      return 0;
-    t = ((gc_job_desc_t *) ea_to_ptr(s))->sys.next;
-    done = __stdcx(&stack->top, t);
-  } while (unlikely(done == 0));
-
-  return ea_to_ptr(s);
-}
-
-#else  // 32-bit mode
-
-/*
- * In 32-bit mode, gc_eaddr's will have the top 32-bits zero.
- * The ldarx/stdcx instructions aren't available in 32-bit mode,
- * thus we use lwarx/stwcx on the low 32-bits of the 64-bit addresses.
- * Since we're big-endian, the low 32-bits are at word offset 1.
- */
-void 
-gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item)
-{
-  gc_eaddr_t   top;
-  unsigned int done;
-
-  do {
-    top = __lwarx((int32_t *)(&stack->top) + 1);
-    item->sys.next = top;
-    smp_wmb();       // order store of item->sys.next before store of stack->top
-    done = __stwcx((int32_t *)(&stack->top) + 1, item);
-  } while (unlikely(done == 0));
-}
-
-gc_job_desc_t *
-gc_jd_stack_pop(gc_jd_stack_t *stack)
-{
-  gc_eaddr_t   s;
-  gc_eaddr_t   t;
-  unsigned int done;
-
-  do {
-    s  = __lwarx((int32_t *)(&stack->top) + 1);
-    if (s == 0)                        /* stack's empty */
-      return 0;
-    t = ((gc_job_desc_t *) ea_to_ptr(s))->sys.next;
-    done = __stwcx((int32_t *)(&stack->top) + 1, (uint32_t) t);
-  } while (unlikely(done == 0));
-
-  return ea_to_ptr(s);
-}
-
-#endif
diff --git a/gcell/src/lib/runtime/gc_job_manager.cc b/gcell/src/lib/runtime/gc_job_manager.cc
deleted file mode 100644 (file)
index ac2e989..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "gc_job_manager.h"
-#include "gc_job_manager_impl.h"
-#include <boost/weak_ptr.hpp>
-#include <stdio.h>
-
-
-static boost::weak_ptr<gc_job_manager> s_singleton;
-
-
-// custom deleter of gc_job_desc allocated via alloc_job_desc_sptr
-class job_desc_deleter {
-  gc_job_manager_sptr  d_mgr;
-public:
-  job_desc_deleter(gc_job_manager_sptr mgr) : d_mgr(mgr) {}
-
-  void operator()(gc_job_desc *jd) {
-    d_mgr->free_job_desc(jd);
-  }
-};
-
-
-
-gc_job_manager_sptr
-gc_make_job_manager(const gc_jm_options *options)
-{
-  return gc_job_manager_sptr(new gc_job_manager_impl(options));
-}
-
-gc_job_manager::gc_job_manager(const gc_jm_options *options)
-{
-  // nop
-}
-
-gc_job_manager::~gc_job_manager()
-{
-  // nop
-}
-
-void
-gc_job_manager::set_debug(int debug)
-{
-  // nop
-}
-
-int
-gc_job_manager::debug()
-{
-  return 0;
-}
-
-void 
-gc_job_manager::set_singleton(gc_job_manager_sptr mgr)
-{
-  s_singleton = mgr;
-}
-
-gc_job_manager_sptr 
-gc_job_manager::singleton()
-{
-  return gc_job_manager_sptr(s_singleton);
-}
-
-gc_job_desc_sptr 
-gc_job_manager::make_jd_sptr(gc_job_manager_sptr mgr, gc_job_desc *jd)
-{
-  return gc_job_desc_sptr(jd, job_desc_deleter(mgr));
-}
-
-gc_job_desc_sptr 
-gc_job_manager::alloc_job_desc(gc_job_manager_sptr mgr)
-{
-  return make_jd_sptr(mgr, mgr->alloc_job_desc());
-}
-
-
-// ------------------------------------------------------------------------
-
-
-// custom deleter
-class spe_program_handle_deleter {
-public:
-  void operator()(spe_program_handle_t *program) {
-    if (program){
-      int r = spe_image_close(program);
-      if (r != 0){
-       perror("spe_image_close");
-      }
-    }
-  }
-};
-
-// nop custom deleter
-class nop_spe_program_handle_deleter {
-public:
-  void operator()(spe_program_handle_t *program) {
-  }
-};
-
-spe_program_handle_sptr 
-gc_program_handle_from_filename(const std::string &filename)
-{
-  return spe_program_handle_sptr(spe_image_open(filename.c_str()),
-                                spe_program_handle_deleter());
-}
-
-
-spe_program_handle_sptr 
-gc_program_handle_from_address(spe_program_handle_t *handle)
-{
-  return spe_program_handle_sptr(handle, nop_spe_program_handle_deleter());
-}
-
-const std::string
-gc_job_status_string(gc_job_status_t status)
-{
-  switch(status){
-  case JS_OK:                  return "JS_OK";
-  case JS_SHUTTING_DOWN:       return "JS_SHUTTING_DOWN";
-  case JS_TOO_MANY_CLIENTS:    return "JS_TOO_MANY_CLIENTS";
-  case JS_UNKNOWN_PROC:                return "JS_UNKNOWN_PROC";
-  case JS_BAD_DIRECTION:       return "JS_BAD_DIRECTION";
-  case JS_BAD_EAH:             return "JS_BAD_EAH";
-  case JS_BAD_N_DIRECT:                return "JS_BAD_N_DIRECT";
-  case JS_BAD_N_EA:            return "JS_BAD_N_EA";
-  case JS_ARGS_TOO_LONG:       return "JS_ARGS_TOO_LONG";
-  case JS_BAD_JUJU:            return "JS_BAD_JUJU";
-  case JS_BAD_JOB_DESC:                return "JS_BAD_JOB_DESC";
-  default:
-    char buf[100];
-    snprintf(buf, sizeof(buf), "unknown gc_job_status_t (%d)\n", status);
-    return buf;
-  }
-}
-
-/*
- * exception classes
- */
-
-gc_exception::gc_exception(const std::string &msg)
-  : runtime_error(msg)
-{
-}
-
-gc_unknown_proc::gc_unknown_proc(const std::string &msg)
-  : gc_exception("gc_unknown_proc: " + msg)
-{
-}
-
-gc_bad_alloc::gc_bad_alloc(const std::string &msg)
-  : gc_exception("gc_bad_alloc: " + msg)
-{
-}
-
-gc_bad_align::gc_bad_align(const std::string &msg)
-  : gc_exception("gc_bad_align: " + msg)
-{
-}
-
-gc_bad_submit::gc_bad_submit(const std::string &name, gc_job_status_t status)
-  : gc_exception("gc_bad_submit(" + name + "): " + gc_job_status_string(status))
-{
-}
diff --git a/gcell/src/lib/runtime/gc_job_manager.h b/gcell/src/lib/runtime/gc_job_manager.h
deleted file mode 100644 (file)
index 67abce7..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JOB_MANAGER_H
-#define INCLUDED_GC_JOB_MANAGER_H
-
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
-#include <vector>
-#include <string>
-#include <stdexcept>
-#include <libspe2.h>
-#include "gc_job_desc.h"
-
-class gc_job_manager;
-typedef boost::shared_ptr<gc_job_manager> gc_job_manager_sptr;
-typedef boost::shared_ptr<spe_program_handle_t> spe_program_handle_sptr;
-typedef boost::shared_ptr<gc_job_desc> gc_job_desc_sptr;
-
-/*!
- * \brief Return a boost::shared_ptr to an spe_program_handle_t
- *
- * \param filename is the name of the SPE ELF executable to open.
- *
- * Calls spe_image_open to open the file.  If successful returns a
- * boost::shared_ptr that will call spe_image_close when it's time to
- * free the object.
- *
- * Returns the equivalent of the NULL pointer if the file cannot be
- * opened, or if it's not an SPE ELF object file.
- *
- * \sa gc_program_handle_from_address
- */
-spe_program_handle_sptr 
-gc_program_handle_from_filename(const std::string &filename);
-
-/*!
- * \brief Return a boost::shared_ptr to an spe_program_handle_t
- *
- * \param handle is a non-zero pointer to an embedded SPE image.
- *
- * If successful returns a boost::shared_ptr that does nothing when
- * it's time to free the object.
- *
- * \sa gc_program_handle_from_filename
- */
-spe_program_handle_sptr 
-gc_program_handle_from_address(spe_program_handle_t *handle);
-
-/*!
- * \brief map gc_job_status_t into a string
- */
-const std::string
-gc_job_status_string(gc_job_status_t status);
-
-/*
- * \brief Options that configure the job_manager.
- * The default values are reasonable.
- */
-struct gc_jm_options {
-  unsigned int max_jobs;           // max # of job descriptors in system
-  unsigned int max_client_threads;  // max # of client threads of job manager
-  unsigned int nspes;              // how many SPEs shall we use? 0 -> all of them
-  bool gang_schedule;              // shall we gang schedule?
-  bool use_affinity;               // shall we try for affinity (FIXME not implmented)
-  bool enable_logging;             // shall we log SPE events?
-  uint32_t log2_nlog_entries;             // log2 of number of log entries (default is 12 == 4k)
-  spe_program_handle_sptr program_handle;  // program to load into SPEs
-
-  gc_jm_options() :
-    max_jobs(0), max_client_threads(0), nspes(0),
-    gang_schedule(false), use_affinity(false),
-    enable_logging(false), log2_nlog_entries(12)
-  {
-  }
-
-  gc_jm_options(spe_program_handle_sptr program_handle_,
-               unsigned int nspes_ = 0) :
-    max_jobs(0), max_client_threads(0), nspes(nspes_),
-    gang_schedule(false), use_affinity(false),
-    enable_logging(false), log2_nlog_entries(12),
-    program_handle(program_handle_)
-  {
-  }
-};
-
-enum gc_wait_mode {
-  GC_WAIT_ANY,
-  GC_WAIT_ALL,
-};
-
-/*
- * exception classes
- */
-class gc_exception : public std::runtime_error
-{
-public:
-  gc_exception(const std::string &msg);
-};
-
-class gc_unknown_proc : public gc_exception
-{
-public:
-  gc_unknown_proc(const std::string &msg);
-};
-
-class gc_bad_alloc : public gc_exception
-{
-public:
-  gc_bad_alloc(const std::string &msg);
-};
-
-class gc_bad_align : public gc_exception
-{
-public:
-  gc_bad_align(const std::string &msg);
-};
-
-class gc_bad_submit : public gc_exception
-{
-public:
-  gc_bad_submit(const std::string &name, gc_job_status_t status);
-};
-
-/*
- * \brief Create an instance of the job manager
- */
-gc_job_manager_sptr
-gc_make_job_manager(const gc_jm_options *options = 0);
-
-
-/*!
- * \brief Abstract class that manages SPE jobs.
- *
- * There is typically a single instance derived from this class.
- * It is safe to call its methods from any thread.
- */
-class gc_job_manager : boost::noncopyable
-{
-public:
-  gc_job_manager(const gc_jm_options *options = 0); 
-
-  virtual ~gc_job_manager();
-
-  /*!
-   * Stop accepting new jobs.  Wait for existing jobs to complete.
-   * Return all managed SPE's to the system.
-   */
-  virtual bool shutdown() = 0;
-
-  /*!
-   * \brief Return number of SPE's currently allocated to job manager.
-   */
-  virtual int nspes() const = 0;
-
-  /*!
-   * \brief Return a pointer to a properly aligned job descriptor,
-   * or throws gc_bad_alloc if there are none available.
-   */
-  virtual gc_job_desc *alloc_job_desc() = 0;
-
-  /*
-   *! Free a job descriptor previously allocated with alloc_job_desc()
-   *
-   * \param[in] jd pointer to job descriptor to free.
-   */
-  virtual void free_job_desc(gc_job_desc *jd) = 0;
-
-  /*!
-   * \brief Submit a job for asynchronous processing on an SPE.
-   *
-   * \param[in] jd pointer to job description
-   *
-   * The caller must not read or write the job description
-   * or any of the memory associated with any indirect arguments
-   * until after calling wait_job.
-   *
-   * \returns true iff the job was successfully enqueued.
-   * If submit_job returns false, check jd->status for additional info.
-   */
-  virtual bool submit_job(gc_job_desc *jd) = 0;
-
-  /*!
-   * \brief Wait for job to complete.
-   *
-   * A thread may only wait for jobs which it submitted.
-   *
-   * \returns true if sucessful, else false.
-   */
-  virtual bool 
-  wait_job(gc_job_desc *jd) = 0;
-
-  /*!
-   * \brief wait for 1 or more jobs to complete.
-   *
-   * \param[input] njobs is the length of arrays \p jd and \p done.
-   * \param[input] jd are the jobs that are to be waited for.
-   * \param[output] done indicates whether the corresponding job is complete.
-   * \param[input] mode indicates whether to wait for ALL or ANY of the jobs
-   *   in \p jd to complete.
-   *
-   * A thread may only wait for jobs which it submitted.
-   *
-   * \returns number of jobs completed, or -1 if error.
-   * The caller must examine the status field of each job to confirm
-   * successful completion of the job.
-   */
-  virtual int
-  wait_jobs(unsigned int njobs,
-           gc_job_desc *jd[], bool done[], gc_wait_mode mode) = 0;
-
-  /*!
-   * Return the maximum number of bytes of EA arguments that may be
-   * copied to or from the SPE in a single job.  The limit applies
-   * independently to the "get" and "put" args.  
-   * \sa gc_job_desc_t, gc_job_ea_args_t
-   */
-  virtual int ea_args_maxsize() = 0;
-
-  /*!
-   * Return gc_proc_id_t associated with spu procedure \p proc_name if one
-   * exists, otherwise throws gc_unknown_proc.
-   */
-  virtual gc_proc_id_t lookup_proc(const std::string &proc_name) = 0;
-  
-  /*!
-   * Return a vector of all known spu procedure names.
-   */
-  virtual std::vector<std::string> proc_names() = 0;
-
-  virtual void set_debug(int debug);
-  virtual int debug();
-
-  /* ----- static methods ----- */
-
-  /*!
-   * \brief Set the singleton gc_job_manager instance.
-   * \param mgr is the job manager instance.
-   *
-   * The singleton is weakly held, thus the caller must maintain
-   * a reference to the mgr for the duration.  (If we held the
-   * manager strongly, the destructor would never be called, and the
-   * resources (SPEs) would not be returned.)  Bottom line: the
-   * caller is responsible for life-time management.
-   */
-  static void set_singleton(gc_job_manager_sptr mgr);
-
-  /*!
-   * \brief Retrieve the singleton gc_job_manager instance.
-   *
-   * Returns the singleton gc_job_manager instance or raises
-   * boost::bad_weak_ptr if the singleton is empty.
-   */
-  static gc_job_manager_sptr singleton();
-
-  /*!
-   * \brief return a boost::shared_ptr to a job descriptor.
-   */
-  static gc_job_desc_sptr make_jd_sptr(gc_job_manager_sptr mgr, gc_job_desc *jd);
-
-  /*!
-   * \brief allocate a job descriptor and return a boost::shared_ptr to it.
-   */
-  static gc_job_desc_sptr alloc_job_desc(gc_job_manager_sptr mgr);
-};
-
-
-#endif /* INCLUDED_GC_JOB_MANAGER_H */
diff --git a/gcell/src/lib/runtime/gc_job_manager_impl.cc b/gcell/src/lib/runtime/gc_job_manager_impl.cc
deleted file mode 100644 (file)
index 2b4b83f..0000000
+++ /dev/null
@@ -1,1249 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <gc_job_manager_impl.h>
-#include <gc_mbox.h>
-#include <gc_proc_def_utils.h>
-#include <gc_aligned_alloc.h>
-#include <stdio.h>
-#include <stdexcept>
-#include <stdlib.h>
-#include <atomic_dec_if_positive.h>
-#include <memory_barrier.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-
-
-static const size_t CACHE_LINE_SIZE = 128;
-
-static const unsigned int DEFAULT_MAX_JOBS = 128;
-static const unsigned int DEFAULT_MAX_CLIENT_THREADS = 64;
-
-// FIXME this really depends on the SPU code...
-static const unsigned int MAX_TOTAL_INDIRECT_LENGTH = 16 * 1024;
-
-
-static bool          s_key_initialized = false;
-static pthread_key_t s_client_key;
-
-static int s_worker_debug = 0;
-
-// custom deleter of gang_contexts for use with boost::shared_ptr
-class gang_deleter {
-public:
-  void operator()(spe_gang_context_ptr_t ctx) {
-    if (ctx){
-      int r = spe_gang_context_destroy(ctx);
-      if (r != 0){
-       perror("spe_gang_context_destroy");
-      }
-    }
-  }
-};
-
-
-// custom deleter of anything that can be freed with "free"
-class free_deleter {
-public:
-  void operator()(void *p) {
-    free(p);
-  }
-};
-
-
-/*
- * Called when client thread is destroyed.
- * We mark our client info free.
- */
-static void
-client_key_destructor(void *p)
-{
-  ((gc_client_thread_info *) p)->d_free = 1;
-}
-
-static bool
-is_power_of_2(uint32_t x)
-{
-  return (x != 0) && !(x & (x - 1));
-}
-
-////////////////////////////////////////////////////////////////////////
-
-
-gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options)
-  : d_debug(0), d_spu_args(0),
-    d_eh_cond(&d_eh_mutex), d_eh_thread(0), d_eh_state(EHS_INIT),
-    d_shutdown_requested(false),
-    d_client_thread(0), d_ea_args_maxsize(0),
-    d_proc_def(0), d_proc_def_ls_addr(0), d_nproc_defs(0)
-{
-  if (!s_key_initialized){
-    int r = pthread_key_create(&s_client_key, client_key_destructor);
-    if (r != 0)
-      throw std::runtime_error("pthread_key_create");
-    s_key_initialized = true;
-  }
-
-  // ensure it's zero
-  pthread_setspecific(s_client_key, 0);
-
-  if (options != 0)
-    d_options = *options;
-
-  // provide the real default for those indicated with a zero
-  if (d_options.max_jobs == 0)
-    d_options.max_jobs = DEFAULT_MAX_JOBS;
-  if (d_options.max_client_threads == 0)
-    d_options.max_client_threads = DEFAULT_MAX_CLIENT_THREADS;
-
-  if (!d_options.program_handle){
-    fprintf(stderr, "gc_job_manager: options->program_handle must be non-zero\n");
-    throw std::runtime_error("gc_job_manager: options->program_handle must be non-zero");
-  }
-
-  int ncpu_nodes = spe_cpu_info_get(SPE_COUNT_PHYSICAL_CPU_NODES, -1);
-  int nusable_spes = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, -1);
-
-  if (debug()){
-    printf("cpu_nodes = %d\n", ncpu_nodes);
-    for (int i = 0; i < ncpu_nodes; i++){
-      printf("node[%d].physical_spes = %2d\n", i,
-            spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, i));
-      printf("node[%d].usable_spes   = %2d\n", i,
-            spe_cpu_info_get(SPE_COUNT_USABLE_SPES, i));
-    }
-  }
-
-  // clamp nspes
-  d_options.nspes = std::min(d_options.nspes, (unsigned int) MAX_SPES);
-  nusable_spes = std::min(nusable_spes, (int) MAX_SPES);
-
-  //
-  // sanity check requested number of spes.
-  //
-  if (d_options.nspes == 0)    // use all of them
-    d_options.nspes = nusable_spes;
-  else {
-    if (d_options.nspes > (unsigned int) nusable_spes){
-      fprintf(stderr,
-             "gc_job_manager: warning: caller requested %d spes.  There are only %d available.\n",
-             d_options.nspes, nusable_spes);
-      if (d_options.gang_schedule){
-       // If we're gang scheduling we'll never get scheduled if we
-       // ask for more than are available.
-       throw std::out_of_range("gang_scheduling: not enough spes available");
-      }
-      else {   // FIXME clamp to usable.  problem on PS3 when overcommited
-       fprintf(stderr, "gc_job_manager: clamping nspes to %d\n", nusable_spes);
-       d_options.nspes = nusable_spes;
-      }
-    }
-  }
-
-  if (d_options.use_affinity){
-    printf("gc_job_manager: warning: affinity request was ignored\n");
-  }
-
-  if (d_options.gang_schedule){
-    d_gang = spe_gang_context_sptr(spe_gang_context_create(0), gang_deleter());
-    if (!d_gang){
-      perror("gc_job_manager_impl[spe_gang_context_create]");
-      throw std::runtime_error("spe_gang_context_create");
-    }
-  }
-
-  // ----------------------------------------------------------------
-  // initalize the job queue
-  
-  d_queue = (gc_jd_queue_t *) gc_aligned_alloc(sizeof(gc_jd_queue_t), CACHE_LINE_SIZE);
-  _d_queue_boost =
-    boost::shared_ptr<void>((void *) d_queue, free_deleter());
-  gc_jd_queue_init(d_queue);
-
-
-  // ----------------------------------------------------------------
-  // create the spe contexts
-
-  // 1 spu_arg struct for each SPE
-  assert(sizeof(gc_spu_args_t) % 16 == 0);
-  d_spu_args =
-    (gc_spu_args_t *) gc_aligned_alloc(MAX_SPES * sizeof(gc_spu_args_t), 16);
-  _d_spu_args_boost =
-    boost::shared_ptr<void>((void *) d_spu_args, free_deleter());
-
-  // 2 completion info structs for each SPE (we double buffer them)
-  assert(sizeof(gc_comp_info_t) % CACHE_LINE_SIZE == 0);
-  d_comp_info =
-    (gc_comp_info_t *) gc_aligned_alloc(2 * MAX_SPES * sizeof(gc_comp_info_t),
-                                       CACHE_LINE_SIZE);
-  _d_comp_info_boost =
-    boost::shared_ptr<void>((void *) d_comp_info, free_deleter());
-
-
-  // get a handle to the spe program
-
-  spe_program_handle_t *spe_image = d_options.program_handle.get();
-
-  // fish proc_def table out of SPE ELF file
-
-  if (!gcpd_find_table(spe_image, &d_proc_def, &d_nproc_defs, &d_proc_def_ls_addr)){
-    fprintf(stderr, "gc_job_manager_impl: couldn't find gc_proc_defs in SPE ELF file.\n");
-    throw std::runtime_error("no gc_proc_defs");
-  }
-  // fprintf(stderr, "d_proc_def_ls_addr = 0x%0x\n", d_proc_def_ls_addr);
-
-  int spe_flags = (SPE_EVENTS_ENABLE
-                  | SPE_CFG_SIGNOTIFY1_OR
-                  | SPE_CFG_SIGNOTIFY2_OR);
-  
-  for (unsigned int i = 0; i < d_options.nspes; i++){
-    // FIXME affinity stuff goes here
-    d_worker[i].spe_ctx = spe_context_create(spe_flags, d_gang.get());;
-    if (d_worker[i].spe_ctx == 0){
-      perror("spe_context_create");
-      throw std::runtime_error("spe_context_create");
-    }
-    d_worker[i].spe_idx = i;
-    d_worker[i].spu_args = &d_spu_args[i];
-    d_worker[i].spu_args->queue = ptr_to_ea(d_queue);
-    d_worker[i].spu_args->comp_info[0] = ptr_to_ea(&d_comp_info[2*i+0]);
-    d_worker[i].spu_args->comp_info[1] = ptr_to_ea(&d_comp_info[2*i+1]);
-    d_worker[i].spu_args->spu_idx = i;
-    d_worker[i].spu_args->nspus = d_options.nspes;
-    d_worker[i].spu_args->proc_def_ls_addr = d_proc_def_ls_addr;
-    d_worker[i].spu_args->nproc_defs = d_nproc_defs;
-    d_worker[i].spu_args->log.base = 0;
-    d_worker[i].spu_args->log.nentries = 0;
-    d_worker[i].state = WS_INIT;
-
-    int r = spe_program_load(d_worker[i].spe_ctx, spe_image);
-    if (r != 0){
-      perror("spe_program_load");
-      throw std::runtime_error("spe_program_load");
-    }
-  }
-
-  setup_logfiles();
-
-  // ----------------------------------------------------------------
-  // initalize the free list of job descriptors
-  
-  d_free_list = (gc_jd_stack_t *) gc_aligned_alloc(sizeof(gc_jd_stack_t), CACHE_LINE_SIZE);
-  // This ensures that the memory associated with d_free_list is
-  // automatically freed in the destructor or if an exception occurs
-  // here in the constructor.
-  _d_free_list_boost =
-    boost::shared_ptr<void>((void *) d_free_list, free_deleter());
-  gc_jd_stack_init(d_free_list);
-
-  if (debug()){
-    printf("sizeof(d_jd[0]) = %d (0x%x)\n", sizeof(d_jd[0]), sizeof(d_jd[0]));
-    printf("max_jobs = %u\n", d_options.max_jobs);
-  }
-
-  // Initialize the array of job descriptors.
-  d_jd = (gc_job_desc_t *) gc_aligned_alloc(sizeof(d_jd[0]) * d_options.max_jobs, CACHE_LINE_SIZE);
-  _d_jd_boost = boost::shared_ptr<void>((void *) d_jd, free_deleter());
-
-
-  // set unique job_id
-  for (int i = 0; i < (int) d_options.max_jobs; i++)
-    d_jd[i].sys.job_id = i;
-
-  // push them onto the free list
-  for (int i = d_options.max_jobs - 1; i >= 0; i--)
-    free_job_desc(&d_jd[i]);
-
-  // ----------------------------------------------------------------
-  // initialize d_client_thread
-
-  {
-    gc_client_thread_info_sa cti(
-         new gc_client_thread_info[d_options.max_client_threads]);
-
-    d_client_thread.swap(cti);
-
-    for (unsigned int i = 0; i < d_options.max_client_threads; i++)
-      d_client_thread[i].d_client_id = i;
-  }
-
-  // ----------------------------------------------------------------
-  // initialize bitvectors
-
-  // initialize d_bvlen, the number of longs in job related bitvectors.
-  int bits_per_long = sizeof(unsigned long) * 8;
-  d_bvlen = (d_options.max_jobs + bits_per_long - 1) / bits_per_long;
-
-  // allocate all bitvectors in a single cache-aligned chunk
-  size_t nlongs = d_bvlen * d_options.max_client_threads;
-  void *p = gc_aligned_alloc(nlongs * sizeof(unsigned long), CACHE_LINE_SIZE);
-  _d_all_bitvectors = boost::shared_ptr<void>(p, free_deleter());
-
-  // Now point the gc_client_thread_info bitvectors into this storage
-  unsigned long *v = (unsigned long *) p;
-
-  for (unsigned int i = 0; i < d_options.max_client_threads; i++, v += d_bvlen)
-    d_client_thread[i].d_jobs_done = v;
-
-
-  // ----------------------------------------------------------------
-  // create the spe event handler & worker (SPE) threads
-
-  create_event_handler();
-
-}
-
-////////////////////////////////////////////////////////////////////////
-
-gc_job_manager_impl::~gc_job_manager_impl()
-{
-  shutdown();
-
-  d_jd = 0;            // handled via _d_jd_boost
-  d_free_list = 0;     // handled via _d_free_list_boost
-  d_queue = 0;         // handled via _d_queue_boost
-
-  // clear cti, since we've deleted the underlying data
-  pthread_setspecific(s_client_key, 0);
-
-  unmap_logfiles();
-}
-
-bool
-gc_job_manager_impl::shutdown()
-{
-  omni_mutex_lock      l(d_eh_mutex);
-
-  d_shutdown_requested = true;         // set flag for event handler thread
-
-  // should only happens during early QA code
-  if (d_eh_thread == 0 && d_eh_state == EHS_INIT)
-    return false;
-
-  while (d_eh_state != EHS_DEAD)       // wait for it to finish
-    d_eh_cond.wait();
-
-  return true;
-}
-
-int
-gc_job_manager_impl::nspes() const
-{
-  return d_options.nspes;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void
-gc_job_manager_impl::bv_zero(unsigned long *bv)
-{
-  memset(bv, 0, sizeof(unsigned long) * d_bvlen);
-}
-
-inline void
-gc_job_manager_impl::bv_clr(unsigned long *bv, unsigned int bitno)
-{
-  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
-  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
-  bv[wi] &= ~(1UL << bi);
-}
-
-inline void
-gc_job_manager_impl::bv_set(unsigned long *bv, unsigned int bitno)
-{
-  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
-  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
-  bv[wi] |= (1UL << bi);
-}
-
-inline bool
-gc_job_manager_impl::bv_isset(unsigned long *bv, unsigned int bitno)
-{
-  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
-  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
-  return (bv[wi] & (1UL << bi)) != 0;
-}
-
-inline bool
-gc_job_manager_impl::bv_isclr(unsigned long *bv, unsigned int bitno)
-{
-  unsigned int wi = bitno / (sizeof (unsigned long) * 8);
-  unsigned int bi = bitno & ((sizeof (unsigned long) * 8) - 1);
-  return (bv[wi] & (1UL << bi)) == 0;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-gc_job_desc *
-gc_job_manager_impl::alloc_job_desc()
-{
-  // stack is lock free, and safe to call from any thread
-  gc_job_desc *jd = gc_jd_stack_pop(d_free_list);
-  if (jd == 0)
-    throw gc_bad_alloc("alloc_job_desc: none available");
-
-  return jd;
-}
-
-void
-gc_job_manager_impl::free_job_desc(gc_job_desc *jd)
-{
-  // stack is lock free, thus safe to call from any thread
-  if (jd != 0)
-    gc_jd_stack_push(d_free_list, jd);
-}
-
-////////////////////////////////////////////////////////////////////////
-
-/*
- * We check as much as we can here on the PPE side, so that the SPE
- * doesn't have to.
- */
-static bool
-check_direct_args(gc_job_desc *jd, gc_job_direct_args *args)
-{
-  if (args->nargs > MAX_ARGS_DIRECT){
-    jd->status = JS_BAD_N_DIRECT;
-    return false;
-  }
-
-  return true;
-}
-
-static bool
-check_ea_args(gc_job_desc *jd, gc_job_ea_args *p)
-{
-  if (p->nargs > MAX_ARGS_EA){
-    jd->status = JS_BAD_N_EA;
-    return false;
-  }
-
-  uint32_t dir_union = 0;
-
-  for (unsigned int i = 0; i < p->nargs; i++){
-    dir_union |= p->arg[i].direction;
-    switch(p->arg[i].direction){
-    case GCJD_DMA_GET:
-    case GCJD_DMA_PUT:
-      break;
-
-    default:
-      jd->status = JS_BAD_DIRECTION;
-      return false;
-    }
-  }
-
-  if (p->nargs > 1){
-    unsigned int common_eah = (p->arg[0].ea_addr) >> 32;
-    for (unsigned int i = 1; i < p->nargs; i++){
-      if ((p->arg[i].ea_addr >> 32) != common_eah){
-       jd->status = JS_BAD_EAH;
-       return false;
-      }
-    }
-  }
-
-  jd->sys.direction_union = dir_union;
-  return true;
-}
-
-bool
-gc_job_manager_impl::submit_job(gc_job_desc *jd)
-{
-  if (unlikely(d_shutdown_requested)){
-    jd->status = JS_SHUTTING_DOWN;
-    return false;
-  }
-
-  // Ensure it's one of our job descriptors
-
-  if (jd < d_jd || jd >= &d_jd[d_options.max_jobs]){
-    jd->status = JS_BAD_JOB_DESC;
-    return false;
-  }
-
-  // Ensure we've got a client_thread_info assigned to this thread.
-  
-  gc_client_thread_info *cti =
-    (gc_client_thread_info *) pthread_getspecific(s_client_key);
-  if (unlikely(cti == 0)){
-    if ((cti = alloc_cti()) == 0){
-      fprintf(stderr, "gc_job_manager_impl::submit_job: Too many client threads.\n");
-      jd->status = JS_TOO_MANY_CLIENTS;
-      return false;
-    }
-    int r = pthread_setspecific(s_client_key, cti);
-    if (r != 0){
-      jd->status = JS_BAD_JUJU;
-      fprintf(stderr, "pthread_setspecific failed (return = %d)\n", r);
-      return false;
-    }
-  }
-
-  if (jd->proc_id == GCP_UNKNOWN_PROC){
-    jd->status = JS_UNKNOWN_PROC;
-    return false;
-  }
-
-  if (!check_direct_args(jd, &jd->input))
-    return false;
-
-  if (!check_direct_args(jd, &jd->output))
-    return false;
-
-  if (!check_ea_args(jd, &jd->eaa))
-    return false;
-
-  jd->status = JS_OK;
-  jd->sys.client_id = cti->d_client_id;
-
-  // FIXME keep count of jobs in progress?
-  
-  gc_jd_queue_enqueue(d_queue, jd);
-  return true;
-}
-
-bool
-gc_job_manager_impl::wait_job(gc_job_desc *jd)
-{
-  bool done;
-  return wait_jobs(1, &jd, &done, GC_WAIT_ANY) == 1 && jd->status == JS_OK;
-}
-
-int
-gc_job_manager_impl::wait_jobs(unsigned int njobs,
-                              gc_job_desc *jd[],
-                              bool done[],
-                              gc_wait_mode mode)
-{
-  unsigned int i;
-
-  gc_client_thread_info *cti =
-    (gc_client_thread_info *) pthread_getspecific(s_client_key);
-  if (unlikely(cti == 0))
-    return -1;
-
-  for (i = 0; i < njobs; i++){
-    done[i] = false;
-    if (unlikely(jd[i]->sys.client_id != cti->d_client_id)){
-      fprintf(stderr, "gc_job_manager_impl::wait_jobs: can't wait for a job you didn't submit\n");
-      return -1;
-    }
-  }
-
-  {
-    omni_mutex_lock    l(cti->d_mutex);
-
-    // setup info for event handler
-    cti->d_state = (mode == GC_WAIT_ANY) ? CT_WAIT_ANY : CT_WAIT_ALL;
-    cti->d_njobs_waiting_for = njobs;
-    cti->d_jobs_waiting_for = jd;
-    assert(cti->d_jobs_done != 0);
-
-    unsigned int ndone = 0;
-
-    // wait for jobs to complete
-    
-    while (1){
-      ndone = 0;
-      for (i= 0; i < njobs; i++){
-       if (done[i])
-         ndone++;
-       else if (bv_isset(cti->d_jobs_done, jd[i]->sys.job_id)){
-         bv_clr(cti->d_jobs_done, jd[i]->sys.job_id);
-         done[i] = true;
-         ndone++;
-       }
-      }
-
-      if (mode == GC_WAIT_ANY && ndone > 0)
-       break;
-
-      if (mode == GC_WAIT_ALL && ndone == njobs)
-       break;
-
-      // FIXME what happens when somebody calls shutdown?
-
-      cti->d_cond.wait();      // wait for event handler to wake us up
-    }
-
-    cti->d_state = CT_NOT_WAITING;  
-    cti->d_njobs_waiting_for = 0;      // tidy up (not reqd)
-    cti->d_jobs_waiting_for = 0;       // tidy up (not reqd)
-    return ndone;
-  }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-bool
-gc_job_manager_impl::send_all_spes(uint32_t msg)
-{
-  bool ok = true;
-
-  for (unsigned int i = 0; i < d_options.nspes; i++)
-    ok &= send_spe(i, msg);
-
-  return ok;
-}
-
-bool
-gc_job_manager_impl::send_spe(unsigned int spe, uint32_t msg)
-{
-  if (spe >= d_options.nspes)
-    return false;
-
-  int r = spe_in_mbox_write(d_worker[spe].spe_ctx, &msg, 1,
-                           SPE_MBOX_ALL_BLOCKING);
-  if (r < 0){
-    perror("spe_in_mbox_write");
-    return false;
-  }
-
-  return r == 1;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-static void
-pthread_create_failure_msg(int r, const char *which)
-{
-  char buf[256];
-  char *s = 0;
-
-  switch (r){
-  case EAGAIN: s = "EAGAIN"; break;
-  case EINVAL: s = "EINVAL"; break;
-  case EPERM:  s = "EPERM";  break;
-  default:
-    snprintf(buf, sizeof(buf), "Unknown error %d", r);
-    s = buf;
-    break;
-  }
-  fprintf(stderr, "pthread_create[%s] failed: %s\n", which, s);
-}
-
-
-static bool
-start_thread(pthread_t *thread,
-            void *(*start_routine)(void *),  void *arg,
-            const char *msg)
-{
-  pthread_attr_t attr;
-  pthread_attr_init(&attr);
-  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
-  // FIXME save sigprocmask
-  // FIXME set sigprocmask
-
-  int r = pthread_create(thread, &attr, start_routine, arg);
-    
-  // FIXME restore sigprocmask
-
-  if (r != 0){
-    pthread_create_failure_msg(r, msg);
-    return false;
-  }
-  return true;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-
-static void *start_worker(void *arg);
-
-static void *
-start_event_handler(void *arg)
-{
-  gc_job_manager_impl *p = (gc_job_manager_impl *) arg;
-  p->event_handler_loop();
-  return 0;
-}
-
-void
-gc_job_manager_impl::create_event_handler()
-{
-  // create the SPE event handler and register our interest in events
-
-  d_spe_event_handler.ptr = spe_event_handler_create();
-  if (d_spe_event_handler.ptr == 0){
-    perror("spe_event_handler_create");
-    throw std::runtime_error("spe_event_handler_create");
-  }
-
-  for (unsigned int i = 0; i < d_options.nspes; i++){
-    spe_event_unit_t   eu;
-    memset(&eu, 0, sizeof(eu));
-    eu.events = SPE_EVENT_OUT_INTR_MBOX | SPE_EVENT_SPE_STOPPED;
-    eu.spe = d_worker[i].spe_ctx;
-    eu.data.u32 = i;   // set in events returned by spe_event_wait
-
-    if (spe_event_handler_register(d_spe_event_handler.ptr, &eu) != 0){
-      perror("spe_event_handler_register");
-      throw std::runtime_error("spe_event_handler_register");
-    }
-  }
-
-  // create our event handling thread
-
-  if (!start_thread(&d_eh_thread, start_event_handler, this, "event_handler")){
-    throw std::runtime_error("pthread_create");
-  }
-
-  // create the SPE worker threads
-
-  bool ok = true;
-  for (unsigned int i = 0; ok && i < d_options.nspes; i++){
-    char name[256];
-    snprintf(name, sizeof(name), "worker[%d]", i);
-    ok &= start_thread(&d_worker[i].thread, start_worker,
-                      &d_worker[i], name);
-  }
-
-  if (!ok){
-    //
-    // FIXME Clean up the mess.  Need to terminate event handler and all workers.
-    //
-    // this should cause the workers to exit, unless they're seriously broken
-    send_all_spes(MK_MBOX_MSG(OP_EXIT, 0));
-
-    shutdown();
-
-    throw std::runtime_error("pthread_create");
-  }
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void
-gc_job_manager_impl::set_eh_state(evt_handler_state s)
-{
-  omni_mutex_lock      l(d_eh_mutex);
-  d_eh_state = s;
-  d_eh_cond.broadcast();
-}
-
-void
-gc_job_manager_impl::set_ea_args_maxsize(int maxsize)
-{
-  omni_mutex_lock      l(d_eh_mutex);
-  d_ea_args_maxsize = maxsize;
-  d_eh_cond.broadcast();
-}
-
-void
-gc_job_manager_impl::print_event(spe_event_unit_t *evt)
-{
-  printf("evt: spe = %d events = (0x%x)", evt->data.u32, evt->events);
-
-  if (evt->events & SPE_EVENT_OUT_INTR_MBOX)
-    printf(" OUT_INTR_MBOX");
-  
-  if (evt->events & SPE_EVENT_IN_MBOX)
-    printf(" IN_MBOX");
-  
-  if (evt->events & SPE_EVENT_TAG_GROUP)
-    printf(" TAG_GROUP");
-  
-  if (evt->events & SPE_EVENT_SPE_STOPPED)
-    printf(" SPE_STOPPED");
-
-  printf("\n");
-}
-
-struct job_client_info {
-  uint16_t     job_id;
-  uint16_t     client_id;
-};
-
-static int
-compare_jci_clients(const void *va, const void *vb)
-{
-  const job_client_info *a = (job_client_info *) va;
-  const job_client_info *b = (job_client_info *) vb;
-
-  return a->client_id - b->client_id;
-}
-
-void
-gc_job_manager_impl::notify_clients_jobs_are_done(unsigned int spe_num,
-                                                 unsigned int completion_info_idx)
-{
-  const char *msg = "gc_job_manager_impl::notify_client_job_is_done (INTERNAL ERROR)";
-
-  smp_rmb();  // order reads so we know that data sent from SPE is here
-
-  gc_comp_info_t *ci = &d_comp_info[2 * spe_num + (completion_info_idx & 0x1)];
-
-  if (ci->ncomplete == 0){     // never happens, but ensures code below is correct
-    ci->in_use = 0;
-    return;
-  }
-
-  if (0){
-    static int total_jobs;
-    static int total_msgs;
-    total_msgs++;
-    total_jobs += ci->ncomplete;
-    printf("ppe:     tj = %6d  tm = %6d\n", total_jobs, total_msgs);
-  }
-
-  job_client_info gci[GC_CI_NJOBS];
-
-  /*
-   * Make one pass through and sanity check everything while filling in gci
-   */
-  for (unsigned int i = 0; i < ci->ncomplete; i++){
-    unsigned int job_id = ci->job_id[i];
-
-    if (job_id >= d_options.max_jobs){
-      // internal error, shouldn't happen
-      fprintf(stderr,"%s: invalid job_id = %d\n", msg, job_id);
-      ci->in_use = 0;          // clear flag so SPE knows we're done with it
-      return;
-    }
-    gc_job_desc *jd = &d_jd[job_id];
-
-    if (jd->sys.client_id >= d_options.max_client_threads){
-      // internal error, shouldn't happen
-      fprintf(stderr, "%s: invalid client_id = %d\n", msg, jd->sys.client_id);
-      ci->in_use = 0;          // clear flag so SPE knows we're done with it
-      return;
-    }
-
-    gci[i].job_id = job_id;
-    gci[i].client_id = jd->sys.client_id;
-  }
-
-  // sort by client_id so we only have to lock & signal once / client
-
-  if (ci->ncomplete > 1)
-    qsort(gci, ci->ncomplete, sizeof(gci[0]), compare_jci_clients);
-
-  // "wind-in" 
-
-  gc_client_thread_info *last_cti = &d_client_thread[gci[0].client_id];
-  last_cti->d_mutex.lock();
-  bv_set(last_cti->d_jobs_done, gci[0].job_id);  // mark job done
-
-  for (unsigned int i = 1; i < ci->ncomplete; i++){
-
-    gc_client_thread_info *cti = &d_client_thread[gci[i].client_id];
-
-    if (cti != last_cti){      // new client?
-
-      // yes.  signal old client, unlock old, lock new
-
-      // FIXME we could distinguish between CT_WAIT_ALL & CT_WAIT_ANY
-
-      if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL)
-       last_cti->d_cond.signal();      // wake client thread up
-
-      last_cti->d_mutex.unlock();
-      cti->d_mutex.lock();
-      last_cti = cti;
-    }
-
-    // mark job done
-    bv_set(cti->d_jobs_done, gci[i].job_id);
-  }
-
-  // "wind-out"
-
-  if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL)
-    last_cti->d_cond.signal(); // wake client thread up
-  last_cti->d_mutex.unlock();
-
-  ci->in_use = 0;              // clear flag so SPE knows we're done with it
-}
-
-void
-gc_job_manager_impl::handle_event(spe_event_unit_t *evt)
-{
-  // print_event(evt);
-
-  int spe_num = evt->data.u32;
-
-  // only a single event type can be signaled at a time
-  
-  if (evt->events == SPE_EVENT_OUT_INTR_MBOX) { // SPE sent us 1 or more msgs
-    static const int NMSGS = 32;
-    unsigned int msg[NMSGS];
-    int n = spe_out_intr_mbox_read(evt->spe, msg, NMSGS, SPE_MBOX_ANY_BLOCKING);
-    // printf("spe_out_intr_mbox_read = %d\n", n);
-    if (n < 0){
-      perror("spe_out_intr_mbox_read");
-    }
-    else {
-      for (int i = 0; i < n; i++){
-       switch(MBOX_MSG_OP(msg[i])){
-       case OP_JOBS_DONE:
-         if (debug())
-           printf("eh: job_done (0x%08x) from spu[%d]\n", msg[i], spe_num);
-         notify_clients_jobs_are_done(spe_num, MBOX_MSG_ARG(msg[i]));
-         break;
-
-       case OP_SPU_BUFSIZE:
-         set_ea_args_maxsize(MBOX_MSG_ARG(msg[i]));
-         break;
-
-       case OP_EXIT:
-       default:
-         printf("eh: Unexpected msg (0x%08x) from spu[%d]\n", msg[i], spe_num);
-         break;
-       }
-      }
-    }
-  }
-  else if (evt->events == SPE_EVENT_SPE_STOPPED){ // the SPE stopped
-    spe_stop_info_t si;
-    int r = spe_stop_info_read(evt->spe, &si);
-    if (r < 0){
-      perror("spe_stop_info_read");
-    }
-    else {
-      switch (si.stop_reason){
-      case SPE_EXIT:
-       if (debug()){
-         printf("eh: spu[%d] SPE_EXIT w/ exit_code = %d\n",
-                spe_num, si.result.spe_exit_code);
-       }
-       break;
-      case SPE_STOP_AND_SIGNAL:
-       printf("eh: spu[%d] SPE_STOP_AND_SIGNAL w/ spe_signal_code = 0x%x\n",
-              spe_num, si.result.spe_signal_code);
-       break;
-      case SPE_RUNTIME_ERROR:
-       printf("eh: spu[%d] SPE_RUNTIME_ERROR w/ spe_runtime_error = 0x%x\n",
-              spe_num, si.result.spe_runtime_error);
-       break;
-      case SPE_RUNTIME_EXCEPTION:
-       printf("eh: spu[%d] SPE_RUNTIME_EXCEPTION w/ spe_runtime_exception = 0x%x\n",
-              spe_num, si.result.spe_runtime_exception);
-       break;
-      case SPE_RUNTIME_FATAL:
-       printf("eh: spu[%d] SPE_RUNTIME_FATAL w/ spe_runtime_fatal = 0x%x\n",
-              spe_num, si.result.spe_runtime_fatal);
-       break;
-      case SPE_CALLBACK_ERROR:
-       printf("eh: spu[%d] SPE_CALLBACK_ERROR w/ spe_callback_error = 0x%x\n",
-              spe_num, si.result.spe_callback_error);
-       break;
-      case SPE_ISOLATION_ERROR:
-       printf("eh: spu[%d] SPE_ISOLATION_ERROR w/ spe_isolation_error = 0x%x\n",
-              spe_num, si.result.spe_isolation_error);
-       break;
-      default:
-       printf("eh: spu[%d] UNKNOWN STOP REASON (%d) w/ spu_status = 0x%x\n",
-              spe_num, si.stop_reason, si.spu_status);
-       break;
-      }
-    }
-  }
-#if 0 // not enabled
-  else if (evt->events == SPE_EVENT_IN_MBOX){   // there's room to write to SPE
-    // spe_in_mbox_write (ignore)
-  }
-  else if (evt->events == SPE_EVENT_TAG_GROUP){         // our DMA completed
-    // spe_mfcio_tag_status_read
-  }
-#endif
-  else {
-    fprintf(stderr, "handle_event: unexpected evt->events = 0x%x\n", evt->events);
-    return;
-  }
-}
-
-//
-// This is the "main program" of the event handling thread
-//
-void
-gc_job_manager_impl::event_handler_loop()
-{
-  static const int MAX_EVENTS = 16;
-  static const int TIMEOUT = 20;       // how long to block in milliseconds
-
-  spe_event_unit_t events[MAX_EVENTS];
-
-  if (d_debug)
-    printf("event_handler_loop: starting\n");
-
-  set_eh_state(EHS_RUNNING);
-
-  // ask the first spe for its max bufsize
-  send_spe(0, MK_MBOX_MSG(OP_GET_SPU_BUFSIZE, 0));
-
-  while (1){
-    switch(d_eh_state){
-
-    case EHS_RUNNING:      // normal stuff
-      if (d_shutdown_requested) {
-       set_eh_state(EHS_SHUTTING_DOWN);
-      }
-      break;
-
-    case EHS_SHUTTING_DOWN:
-
-      // FIXME wait until job queue is empty, then tell them to exit
-
-      send_all_spes(MK_MBOX_MSG(OP_EXIT, 0));
-      set_eh_state(EHS_WAITING_FOR_WORKERS_TO_DIE);
-      break;
-
-    case EHS_WAITING_FOR_WORKERS_TO_DIE:
-      {
-       bool all_dead = true;
-       for (unsigned int i = 0; i < d_options.nspes; i++)
-         all_dead &= d_worker[i].state == WS_DEAD;
-
-       if (all_dead){
-         set_eh_state(EHS_DEAD);
-         if (d_debug)
-           printf("event_handler_loop: exiting\n");
-         return;
-       }
-      }
-      break;
-
-    default:
-      set_eh_state(EHS_DEAD);
-      printf("event_handler_loop(default): exiting\n");
-      return;
-    }
-
-    // block waiting for events...
-    int nevents = spe_event_wait(d_spe_event_handler.ptr,
-                                events, MAX_EVENTS, TIMEOUT);
-    if (nevents < 0){
-      perror("spe_wait_event");
-      // FIXME bail?
-    }
-    for (int i = 0; i < nevents; i++){
-      handle_event(&events[i]);
-    }
-  }
-}
-
-////////////////////////////////////////////////////////////////////////
-// This is the top of the SPE worker threads
-
-static void *
-start_worker(void *arg)
-{
-  worker_ctx *w = (worker_ctx *) arg;
-  spe_stop_info_t      si;
-
-  w->state = WS_RUNNING;
-  if (s_worker_debug)
-    printf("worker[%d]: WS_RUNNING\n", w->spe_idx);
-
-  unsigned int entry = SPE_DEFAULT_ENTRY;
-  int r = spe_context_run(w->spe_ctx,  &entry, 0, w->spu_args, 0, &si);
-
-  if (r < 0){                  // error
-    char buf[64];
-    snprintf(buf, sizeof(buf), "worker[%d]: spe_context_run", w->spe_idx);
-    perror(buf);
-  }
-  else if (r == 0){
-    // spe program called exit.
-    if (s_worker_debug)
-      printf("worker[%d]: SPE_EXIT w/ exit_code = %d\n",
-            w->spe_idx, si.result.spe_exit_code);
-  }
-  else {
-    // called stop_and_signal
-    //
-    // I'm not sure we'll ever get here.  I think the event
-    // handler will catch this...
-    printf("worker[%d]: SPE_STOP_AND_SIGNAL w/ spe_signal_code = 0x%x\n",
-          w->spe_idx, si.result.spe_signal_code);
-  }
-
-  // in any event, we're committing suicide now ;)
-  if (s_worker_debug)
-    printf("worker[%d]: WS_DEAD\n", w->spe_idx);
-
-  w->state = WS_DEAD;
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-gc_client_thread_info *
-gc_job_manager_impl::alloc_cti()
-{
-  for (unsigned int i = 0; i < d_options.max_client_threads; i++){
-    if (d_client_thread[i].d_free){
-      // try to atomically grab it
-      if (_atomic_dec_if_positive(ptr_to_ea(&d_client_thread[i].d_free)) == 0){
-       // got it...
-       gc_client_thread_info *cti = &d_client_thread[i];
-       cti->d_state = CT_NOT_WAITING;
-       bv_zero(cti->d_jobs_done);
-       cti->d_njobs_waiting_for = 0;
-       cti->d_jobs_waiting_for = 0;
-       
-       return cti;
-      }
-    }
-  }
-  return 0;
-}
-
-void
-gc_job_manager_impl::free_cti(gc_client_thread_info *cti)
-{
-  assert((size_t) (cti - d_client_thread.get()) < d_options.max_client_threads);
-  cti->d_free = 1;
-}
-
-int
-gc_job_manager_impl::ea_args_maxsize()
-{
-  omni_mutex_lock      l(d_eh_mutex);
-
-  while (d_ea_args_maxsize == 0)       // wait for it to be initialized
-    d_eh_cond.wait();
-
-  return d_ea_args_maxsize;
-}
-
-void
-gc_job_manager_impl::set_debug(int debug)
-{
-  d_debug = debug;
-  s_worker_debug = debug;
-}
-
-int
-gc_job_manager_impl::debug()
-{
-  return d_debug;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-void
-gc_job_manager_impl::setup_logfiles()
-{
-  if (!d_options.enable_logging)
-    return;
-
-  if (d_options.log2_nlog_entries == 0)
-    d_options.log2_nlog_entries = 12;
-
-  // must end up a multiple of the page size
-
-  size_t pagesize = getpagesize();
-  size_t s = (1 << d_options.log2_nlog_entries) * sizeof(gc_log_entry_t);
-  s = ((s + pagesize - 1) / pagesize) * pagesize;
-  size_t nentries = s / sizeof(gc_log_entry_t);
-  assert(is_power_of_2(nentries));
-
-  for (unsigned int i = 0; i < d_options.nspes; i++){
-    char filename[100];
-    snprintf(filename, sizeof(filename), "spu_log.%02d", i);
-    int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0664);
-    if (fd == -1){
-      perror(filename);
-      return;
-    }
-    lseek(fd, s - 1, SEEK_SET);
-    write(fd, "\0", 1);
-    void *p = mmap(0, s, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
-    if (p == MAP_FAILED){
-      perror("gc_job_manager_impl::setup_logfiles: mmap");
-      close(fd);
-      return;
-    }
-    close(fd);
-    memset(p, 0, s);
-    d_spu_args[i].log.base = ptr_to_ea(p);
-    d_spu_args[i].log.nentries = nentries;
-  }
-}
-
-void
-gc_job_manager_impl::sync_logfiles()
-{
-  for (unsigned int i = 0; i < d_options.nspes; i++){
-    if (d_spu_args[i].log.base)
-      msync(ea_to_ptr(d_spu_args[i].log.base),
-           d_spu_args[i].log.nentries * sizeof(gc_log_entry_t),
-           MS_ASYNC);
-  }
-}
-
-void
-gc_job_manager_impl::unmap_logfiles()
-{
-  for (unsigned int i = 0; i < d_options.nspes; i++){
-    if (d_spu_args[i].log.base)
-      munmap(ea_to_ptr(d_spu_args[i].log.base),
-            d_spu_args[i].log.nentries * sizeof(gc_log_entry_t));
-  }
-}
-
-////////////////////////////////////////////////////////////////////////
-//
-// lookup proc names in d_proc_def table
-
-gc_proc_id_t 
-gc_job_manager_impl::lookup_proc(const std::string &proc_name)
-{
-  for (int i = 0; i < d_nproc_defs; i++)
-    if (proc_name == d_proc_def[i].name)
-      return i;
-
-  throw gc_unknown_proc(proc_name);
-}
-
-std::vector<std::string>
-gc_job_manager_impl::proc_names()
-{
-  std::vector<std::string> r;
-  for (int i = 0; i < d_nproc_defs; i++)
-    r.push_back(d_proc_def[i].name);
-
-  return r;
-}
-
-////////////////////////////////////////////////////////////////////////
-
-worker_ctx::~worker_ctx()
-{
-  if (spe_ctx){
-    int r = spe_context_destroy(spe_ctx);
-    if (r != 0){
-      perror("spe_context_destroy");
-    }
-    spe_ctx = 0;
-  }
-  state = WS_FREE;
-}
diff --git a/gcell/src/lib/runtime/gc_job_manager_impl.h b/gcell/src/lib/runtime/gc_job_manager_impl.h
deleted file mode 100644 (file)
index fcc24dc..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_GC_JOB_MANAGER_IMPL_H
-#define INCLUDED_GC_JOB_MANAGER_IMPL_H
-
-#include "gc_job_manager.h"
-#include "gc_client_thread_info.h"
-#include "gc_jd_stack.h"
-#include "gc_jd_queue.h"
-#include "gc_spu_args.h"
-#include <libspe2.h>
-#include <vector>
-#include <boost/scoped_array.hpp>
-
-typedef boost::shared_ptr<spe_gang_context> spe_gang_context_sptr;
-typedef boost::shared_ptr<spe_program_handle_t> spe_program_handle_sptr;
-typedef boost::scoped_array<gc_client_thread_info> gc_client_thread_info_sa;
-
-
-enum worker_state {
-  WS_FREE,     // not in use
-  WS_INIT,     // allocated and being initialized
-  WS_RUNNING,  // the thread is running
-  WS_DEAD,     // the thread is dead
-};
-
-struct worker_ctx {
-  volatile worker_state        state;
-  unsigned int         spe_idx;        // [0, nspes-1]
-  spe_context_ptr_t    spe_ctx;
-  pthread_t            thread;
-  gc_spu_args_t                *spu_args;      // pointer to 16-byte aligned struct
-
-  worker_ctx()
-    : state(WS_FREE), spe_idx(0), spe_ctx(0),
-      thread(0), spu_args(0) {}
-  ~worker_ctx();
-};
-
-enum evt_handler_state {
-  EHS_INIT,            // being initialized
-  EHS_RUNNING,         // thread is running
-  EHS_SHUTTING_DOWN,   // in process of shutting down everything
-  EHS_WAITING_FOR_WORKERS_TO_DIE,
-  EHS_DEAD,            // thread is dead
-};
-
-struct spe_event_handler {
-  spe_event_handler_ptr_t      ptr;
-
-  spe_event_handler() : ptr(0) {}
-  ~spe_event_handler(){
-    if (ptr){
-      if (spe_event_handler_destroy(ptr) != 0){
-       perror("spe_event_handler_destroy");
-      }
-    }
-  }
-};
-
-
-/*!
- * \brief Concrete class that manages SPE jobs.
- *
- * This class contains all the implementation details.
- */
-class gc_job_manager_impl : public gc_job_manager
-{
-  enum { MAX_SPES =  16 };
-
-  int                    d_debug;
-  gc_jm_options                  d_options;
-  spe_program_handle_sptr d_spe_image;
-  spe_gang_context_sptr   d_gang;              // boost::shared_ptr
-
-  worker_ctx            d_worker[MAX_SPES];    // SPE ctx, thread, etc
-  gc_spu_args_t                *d_spu_args;            // 16-byte aligned structs
-  boost::shared_ptr<void> _d_spu_args_boost;   // hack for automatic storage mgmt
-
-  gc_comp_info_t       *d_comp_info;           // 128-byte aligned structs
-  boost::shared_ptr<void> _d_comp_info_boost;  // hack for automatic storage mgmt
-
-  // used to coordinate communication w/ the event handling thread
-  omni_mutex            d_eh_mutex;
-  omni_condition        d_eh_cond;
-  pthread_t             d_eh_thread;           // the event handler thread
-  volatile evt_handler_state   d_eh_state;
-  volatile bool                        d_shutdown_requested;
-  spe_event_handler     d_spe_event_handler;
-  
-
-  // All of the job descriptors are hung off of here.
-  // We allocate them all in a single cache aligned chunk.
-  gc_job_desc_t                *d_jd;                  // [options.max_jobs]
-  boost::shared_ptr<void> _d_jd_boost;         // hack for automatic storage mgmt
-
-  gc_client_thread_info_sa d_client_thread;    // [options.max_client_threads]
-
-  // We use bitvectors to represent the completing state of a job.  Each
-  // bitvector is d_bvlen longs in length.
-  int                   d_bvlen;               // bit vector length in longs
-
-  // This contains the storage for all the bitvectors used by the job
-  // manager.  There's 1 for each client thread, in the d_jobs_done
-  // field.  We allocate them all in a single cache aligned chunk.
-  boost::shared_ptr<void> _d_all_bitvectors;   // hack for automatic storage mgmt
-
-  // Lock free stack where we keep track of the free job descriptors.
-  gc_jd_stack_t                *d_free_list;           // stack of free job descriptors
-  boost::shared_ptr<void> _d_free_list_boost;  // hack for automatic storage mgmt
-
-  // The PPE inserts jobs here; SPEs pull jobs from here.
-  gc_jd_queue_t                *d_queue;               // job queue
-  boost::shared_ptr<void> _d_queue_boost;      // hack for automatic storage mgmt
-
-  int                   d_ea_args_maxsize;
-
-  struct gc_proc_def   *d_proc_def;            // the SPE procedure table
-  uint32_t              d_proc_def_ls_addr;    // the LS address of the table
-  int                   d_nproc_defs;          // number of proc_defs in table
-
-  gc_client_thread_info *alloc_cti();
-  void free_cti(gc_client_thread_info *cti);
-
-  void create_event_handler();
-  void set_eh_state(evt_handler_state s);
-  void set_ea_args_maxsize(int maxsize);
-
-  void notify_clients_jobs_are_done(unsigned int spe_num,
-                                   unsigned int completion_info_idx);
-
-public:
-  void event_handler_loop();   // really private
-
-private:
-  bool send_all_spes(uint32_t msg);
-  bool send_spe(unsigned int spe, uint32_t msg);
-  void print_event(spe_event_unit_t *evt);
-  void handle_event(spe_event_unit_t *evt);
-
-  // bitvector ops
-  void bv_zero(unsigned long *bv);
-  void bv_clr(unsigned long *bv, unsigned int bitno);
-  void bv_set(unsigned long *bv, unsigned int bitno);
-  bool bv_isset(unsigned long *bv, unsigned int bitno);
-  bool bv_isclr(unsigned long *bv, unsigned int bitno);
-
-  void setup_logfiles();
-  void sync_logfiles();
-  void unmap_logfiles();
-
-  friend gc_job_manager_sptr gc_make_job_manager(const gc_jm_options *options);
-  
-  gc_job_manager_impl(const gc_jm_options *options = 0);
-
-public:
-  virtual ~gc_job_manager_impl();
-
-  /*!
-   * Stop accepting new jobs.  Wait for existing jobs to complete.
-   * Return all managed SPE's to the system.
-   */
-  virtual bool shutdown();
-
-  /*!
-   * \brief Return number of SPE's currently allocated to job manager.
-   */
-  virtual int nspes() const;
-
-  /*!
-   * \brief Return a pointer to a properly aligned job descriptor,
-   * or zero if none are available.
-   */
-  virtual gc_job_desc *alloc_job_desc();
-
-  /*
-   *! Return a job descriptor previously allocated with alloc_job_desc()
-   *
-   * \param[in] jd pointer to job descriptor to free.
-   */
-  virtual void free_job_desc(gc_job_desc *jd);
-
-  /*!
-   * \brief Submit a job for asynchronous processing on an SPE.
-   *
-   * \param[in] jd pointer to job description
-   *
-   * The caller must not read or write the job description
-   * or any of the memory associated with any indirect arguments
-   * until after calling wait_job.
-   *
-   * \returns true iff the job was successfully enqueued.
-   * If submit_job returns false, check jd->status for additional info.
-   */
-  virtual bool submit_job(gc_job_desc *jd);
-
-  /*!
-   * \brief Wait for job to complete.
-   *
-   * A thread may only wait for jobs which it submitted.
-   *
-   * \returns true if sucessful, else false.
-   */
-  virtual bool 
-  wait_job(gc_job_desc *jd);
-
-  /*!
-   * \brief wait for 1 or more jobs to complete.
-   *
-   * \param[input] njobs is the length of arrays \p jd and \p done.
-   * \param[input] jd are the jobs that are to be waited for.
-   * \param[output] done indicates whether the corresponding job is complete.
-   * \param[input] mode indicates whether to wait for ALL or ANY of the jobs
-   *   in \p jd to complete.
-   *
-   * A thread may only wait for jobs which it submitted.
-   *
-   * \returns number of jobs completed, or -1 if error.
-   */
-  virtual int
-  wait_jobs(unsigned int njobs,
-           gc_job_desc *jd[], bool done[], gc_wait_mode mode);
-
-  virtual int ea_args_maxsize();
-
-  virtual gc_proc_id_t lookup_proc(const std::string &name);
-  virtual std::vector<std::string> proc_names();
-
-  virtual void set_debug(int debug);
-  virtual int debug();
-};
-
-#endif /* INCLUDED_GC_JOB_MANAGER_IMPL_H */
diff --git a/gcell/src/lib/runtime/gc_proc_def_utils.cc b/gcell/src/lib/runtime/gc_proc_def_utils.cc
deleted file mode 100644 (file)
index c5b9848..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gc_proc_def_utils.h>
-#include <gc_declare_proc.h>
-#include <elf.h>
-#include <stdio.h>
-#include <string.h>
-
-static const unsigned char expected[EI_PAD] = {
-  ELFMAG0,
-  ELFMAG1,
-  ELFMAG2,
-  ELFMAG3,
-  ELFCLASS32,
-  ELFDATA2MSB,
-  EV_CURRENT,
-  ELFOSABI_SYSV,
-  0
-};
-
-
-/*
- * Basically we're going to find the GC_PROC_DEF_SECTION section
- * in the ELF file and return a pointer to it.  The only things in that
- * section are gc_proc_def's
- */
-bool 
-gcpd_find_table(spe_program_handle_t *handle,
-               struct gc_proc_def **table, int *nentries, uint32_t *ls_addr)
-{
-  if (!handle || !table || !nentries)
-    return false;
-
-  *table = 0;
-  *nentries = 0;
-  
-  Elf32_Ehdr *ehdr = (Elf32_Ehdr *)handle->elf_image;
-  if (!ehdr){
-    fprintf(stderr, "gcpd: No ELF image has been loaded\n");
-    return false;
-  }
-
-  // quick check that we're looking at a SPE EXEC object
-
-  if (memcmp(ehdr->e_ident, expected, EI_PAD) != 0){
-    fprintf(stderr, "gcpd: invalid ELF header\n");
-    return false;
-  }
-
-  if (ehdr->e_machine != 0x17){                // confirm machine type (EM_SPU)
-    fprintf(stderr, "gcpd: not an SPE ELF object\n");
-    return false;
-  }
-
-  if (ehdr->e_type != ET_EXEC){
-    fprintf(stderr, "gcpd: invalid SPE ELF type.\n");
-    fprintf(stderr, "gcpd: SPE type %d != %d\n", ehdr->e_type, ET_EXEC);
-    return false;
-  }
-
-  // find the section header table
-
-  Elf32_Shdr *shdr;
-  Elf32_Shdr *sh;
-
-  if (ehdr->e_shentsize != sizeof (*shdr)){
-    fprintf(stderr, "gcpd: invalid section header format.\n");
-    return false;
-  }
-
-  if (ehdr->e_shnum == 0){
-    fprintf(stderr, "gcpd: no section headers in file.\n");
-    return false;
-  }
-
-  shdr = (Elf32_Shdr *) ((char *)ehdr + ehdr->e_shoff);
-  char *str_table = (char *)ehdr + shdr[ehdr->e_shstrndx].sh_offset;
-
-  // traverse the sections looking for GC_PROC_DEF_SECTION
-  
-  for (sh = shdr; sh < &shdr[ehdr->e_shnum]; sh++){
-    if (0){
-      fprintf(stderr, "section name: %s (start: 0x%04x, size: 0x%04x)\n",
-             str_table + sh->sh_name, sh->sh_offset, sh->sh_size);
-    }
-
-    if (strcmp(GC_PROC_DEF_SECTION, str_table+sh->sh_name) == 0){
-      *table = (struct gc_proc_def *)((char *)ehdr + sh->sh_offset);
-      if (sh->sh_size % (sizeof(struct gc_proc_def)) != 0){
-       fprintf(stderr, "gcpd: %s section has invalid format\n", GC_PROC_DEF_SECTION);
-       return false;
-      }
-      *nentries = sh->sh_size / sizeof(struct gc_proc_def);
-      *ls_addr = sh->sh_addr;
-      return true;
-    }
-  }
-
-  return false;
-}
diff --git a/gcell/src/lib/runtime/gc_proc_def_utils.h b/gcell/src/lib/runtime/gc_proc_def_utils.h
deleted file mode 100644 (file)
index c59e472..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_PROC_DEF_UTILS_H
-#define INCLUDED_GC_PROC_DEF_UTILS_H
-
-#include <gc_declare_proc.h>
-#include <libspe2.h>
-
-/*!
- * \brief find the gc_proc_def table in the SPE program
- *
- * \param[in]  program is the handle to the loaded SPE program
- * \param[out] table points to the table, if it's found
- * \param[out] nentries is set to the number of entries in the table.
- * \param[out] ls_addr is set to the Local Store address of the table
- *
- * \returns true if successful, else false
- */
-bool
-gcpd_find_table(spe_program_handle_t *program,
-               struct gc_proc_def **table, int *nentries, uint32_t *ls_addr);
-
-
-#endif /* INCLUDED_GC_PROC_DEF_UTILS_H */
diff --git a/gcell/src/lib/runtime/gcell-embedspu-libtool b/gcell/src/lib/runtime/gcell-embedspu-libtool
deleted file mode 100755 (executable)
index a4ee53b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 2 ]; then
-  echo "usage: gcell-embedspu-libtool file.lo spu_executable_file" 1>&2
-  exit 1
-fi
-
-lo_file=$1
-spu_executable=$2
-symbol_name=${lo_file%%.lo}
-
-# generate the .o file that wraps the SPU executable
-ppu-embedspu -m32 -fpic ${symbol_name} ${spu_executable} .libs/${symbol_name}.o
-
-# generate the .lo libtool file that points at all the right places
-rm -f $lo_file
-cat >$lo_file.new <<EOF
-# $lo_file - a libtool object file
-# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-pic_object='.libs/${symbol_name}.o'
-non_pic_object=none
-EOF
-
-mv $lo_file.new $lo_file
-
diff --git a/gcell/src/lib/runtime/qa_gcell_runtime.cc b/gcell/src/lib/runtime/qa_gcell_runtime.cc
deleted file mode 100644 (file)
index fef9a7f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/*
- * This class gathers together all the test cases for the lib
- * directory into a single test suite.  As you create new test cases,
- * add them here.
- */
-
-#include <qa_gcell_runtime.h>
-#include <qa_jd_stack.h>
-#include <qa_jd_queue.h>
-#include <qa_job_manager.h>
-
-CppUnit::TestSuite *
-qa_gcell_runtime::suite()
-{
-  CppUnit::TestSuite   *s = new CppUnit::TestSuite("runtime");
-
-  s->addTest(qa_jd_stack::suite());
-  s->addTest(qa_jd_queue::suite());
-  s->addTest(qa_job_manager::suite());
-
-  return s;
-}
diff --git a/gcell/src/lib/runtime/qa_gcell_runtime.h b/gcell/src/lib/runtime/qa_gcell_runtime.h
deleted file mode 100644 (file)
index 36180c9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_QA_GCELL_RUNTIME_H
-#define INCLUDED_QA_GCELL_RUNTIME_H
-
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for the runtime directory
-
-class qa_gcell_runtime {
-public:
-  //! return suite of tests
-  static CppUnit::TestSuite *suite();
-};
-
-
-#endif /* INCLUDED_QA_GCELL_RUNTIME_H */
diff --git a/gcell/src/lib/runtime/qa_jd_queue.cc b/gcell/src/lib/runtime/qa_jd_queue.cc
deleted file mode 100644 (file)
index 267d4cf..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "qa_jd_queue.h"
-#include <cppunit/TestAssert.h>
-#include "gc_jd_queue.h"
-#include <stdio.h>
-
-
-
-static const int NJDS = 16;
-static gc_jd_queue_t queue;
-static gc_job_desc_t jds[NJDS];
-
-// no brainer, single threaded basic checkout
-void
-qa_jd_queue::t1()
-{
-  // N.B., queue allocated stuff doesn't obey ((aligned (N))) attributes
-  //const int NJDS = 8;
-  //gc_jd_queue_t queue;
-  //gc_job_desc_t jds[NJDS];
-
-  //printf("&queue   = %p\n", &queue);
-  //printf("&jds[0] = %p\n", &jds[0]);
-  //printf("&jds[1] = %p\n", &jds[1]);
-
-  CPPUNIT_ASSERT(((uintptr_t) &queue & 0x7f) == 0);
-  CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
-  CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
-
-  gc_jd_queue_init(&queue);
-
-  CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
-
-  gc_jd_queue_enqueue(&queue, &jds[0]);
-  CPPUNIT_ASSERT_EQUAL(&jds[0], gc_jd_queue_dequeue(&queue));
-
-  CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
-
-  for (int i = 0; i < NJDS; i++)
-    gc_jd_queue_enqueue(&queue, &jds[i]);
-
-  for (int i = 0; i < NJDS; i++)
-    CPPUNIT_ASSERT_EQUAL(&jds[i], gc_jd_queue_dequeue(&queue));
-
-  CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
-}
-
-// FIXME multithreaded (running on PPE)
-void
-qa_jd_queue::t2()
-{
-}
-
-// FIXME multithreaded (running on PPE & SPE)
-void
-qa_jd_queue::t3()
-{
-}
diff --git a/gcell/src/lib/runtime/qa_jd_queue.h b/gcell/src/lib/runtime/qa_jd_queue.h
deleted file mode 100644 (file)
index 5e1aab8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_QA_JD_QUEUE_H
-#define INCLUDED_QA_JD_QUEUE_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_jd_queue : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_jd_queue);
-  CPPUNIT_TEST(t1);
-  CPPUNIT_TEST(t2);
-  CPPUNIT_TEST(t3);
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-  void t1();
-  void t2();
-  void t3();
-};
-
-
-#endif /* INCLUDED_QA_JD_QUEUE_H */
diff --git a/gcell/src/lib/runtime/qa_jd_stack.cc b/gcell/src/lib/runtime/qa_jd_stack.cc
deleted file mode 100644 (file)
index 67e97c9..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "qa_jd_stack.h"
-#include <cppunit/TestAssert.h>
-#include "gc_jd_stack.h"
-#include <stdio.h>
-
-
-
-static const int NJDS = 8;
-static gc_jd_stack_t stack;
-static gc_job_desc_t jds[NJDS];
-
-// no brainer, single threaded basic checkout
-void
-qa_jd_stack::t1()
-{
-  // N.B., stack allocated stuff doesn't obey ((aligned (N))) attributes
-  //const int NJDS = 8;
-  //gc_jd_stack_t stack;
-  //gc_job_desc_t jds[NJDS];
-
-  //printf("&stack   = %p\n", &stack);
-  //printf("&jds[0] = %p\n", &jds[0]);
-  //printf("&jds[1] = %p\n", &jds[1]);
-
-  CPPUNIT_ASSERT(((uintptr_t) &stack & 0x7f) == 0);
-  CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
-  CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
-
-  gc_jd_stack_init(&stack);
-
-  CPPUNIT_ASSERT(gc_jd_stack_pop(&stack) == 0);
-
-  for (int i = 0; i < NJDS; i++)
-    gc_jd_stack_push(&stack, &jds[i]);
-
-  for (int i = 0; i < NJDS; i++)
-    CPPUNIT_ASSERT_EQUAL(&jds[NJDS - i - 1], gc_jd_stack_pop(&stack));
-
-  CPPUNIT_ASSERT(gc_jd_stack_pop(&stack) == 0);
-}
-
-// FIXME multithreaded (running on PPE)
-void
-qa_jd_stack::t2()
-{
-}
diff --git a/gcell/src/lib/runtime/qa_jd_stack.h b/gcell/src/lib/runtime/qa_jd_stack.h
deleted file mode 100644 (file)
index 1546bbf..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_QA_JD_STACK_H
-#define INCLUDED_QA_JD_STACK_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_jd_stack : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_jd_stack);
-  CPPUNIT_TEST(t1);
-  CPPUNIT_TEST(t2);
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-  void t1();
-  void t2();
-
-};
-
-
-
-#endif /* INCLUDED_QA_JD_STACK_H */
diff --git a/gcell/src/lib/runtime/qa_job_manager.cc b/gcell/src/lib/runtime/qa_job_manager.cc
deleted file mode 100644 (file)
index e37e3c3..0000000
+++ /dev/null
@@ -1,790 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "qa_job_manager.h"
-#include <cppunit/TestAssert.h>
-#include "gc_job_manager.h"
-#include <stdexcept>
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-#include <string.h>
-
-#include <malloc.h>
-
-// handle to embedded SPU executable w/ QA routines
-extern spe_program_handle_t gcell_runtime_qa;
-
-#if 0
-static void
-gc_msleep(unsigned long millisecs)
-{
-  int r;
-  struct timespec tv;
-  tv.tv_sec = millisecs / 1000;
-  tv.tv_nsec = (millisecs - (tv.tv_sec * 1000)) * 1000000;
-  
-  while (1){
-    r = nanosleep(&tv, &tv);
-    if (r == 0)
-      return;
-    if (r == -1 && errno == EINTR)
-      continue;
-    perror("nanosleep");
-    return;
-  }
-}
-#endif
-
-void
-qa_job_manager::leak_check(test_t t, const std::string &name)
-{
-  struct mallinfo before, after;
-
-  before = mallinfo();
-  (this->*t)();
-  after = mallinfo();
-
-  size_t delta = after.uordblks - before.uordblks;
-  if (delta != 0){
-    std::cout << name << " leaked memory\n";
-    printf("  before.uordblks = %6d\n", before.uordblks);
-    printf("  after.uordblks  = %6d\n",  after.uordblks);
-    printf("  delta = %d\n", after.uordblks - before.uordblks);
-  }
-}
-
-void
-qa_job_manager::t0()
-{
-  //leak_check(&qa_job_manager::t1_body, "t1-0");
-}
-
-void
-qa_job_manager::t1()
-{
-  t1_body();           // leaks 800 bytes first time, could be one-time inits
-  leak_check(&qa_job_manager::t1_body, "t1");
-}
-
-void
-qa_job_manager::t2()
-{
-  leak_check(&qa_job_manager::t2_body, "t2");
-}
-
-void
-qa_job_manager::t3()
-{
-  t3_body();           // leaks first time only, could be cppunit
-  leak_check(&qa_job_manager::t3_body, "t3");
-}
-
-void
-qa_job_manager::t4()
-{
-  leak_check(&qa_job_manager::t4_body, "t4");
-}
-
-void
-qa_job_manager::t5()
-{
-  leak_check(&qa_job_manager::t5_body, "t5");
-}
-
-void
-qa_job_manager::t6()
-{
-  leak_check(&qa_job_manager::t6_body, "t6");
-}
-
-void
-qa_job_manager::t7()
-{
-  leak_check(&qa_job_manager::t7_body, "t7");
-}
-
-void
-qa_job_manager::t8()
-{
-  leak_check(&qa_job_manager::t8_body, "t8");
-}
-
-void
-qa_job_manager::t9()
-{
-  leak_check(&qa_job_manager::t9_body, "t9");
-}
-
-void
-qa_job_manager::t10()
-{
-  leak_check(&qa_job_manager::t10_body, "t10");
-}
-
-void
-qa_job_manager::t11()
-{
-  leak_check(&qa_job_manager::t11_body, "t11");
-}
-
-void
-qa_job_manager::t12()
-{
-  leak_check(&qa_job_manager::t12_body, "t12");
-}
-
-void
-qa_job_manager::t13()
-{
-  leak_check(&qa_job_manager::t13_body, "t13");
-}
-
-void
-qa_job_manager::t14()
-{
-  leak_check(&qa_job_manager::t14_body, "t14");
-}
-
-void
-qa_job_manager::t15()
-{
-  leak_check(&qa_job_manager::t15_body, "t15");
-}
-
-// ----------------------------------------------------------------
-
-void
-qa_job_manager::t1_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  mgr = gc_make_job_manager(&opts);
-}
-
-void
-qa_job_manager::t2_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 100;
-  opts.gang_schedule = false;
-  mgr = gc_make_job_manager(&opts);
-}
-
-void
-qa_job_manager::t3_body()
-{
-  // This leaks memory the first time it's invoked, but I'm not sure
-  // if it's us or the underlying exception handling mechanism, or
-  // cppunit.  cppunit is the prime suspect.
-
-#if 0
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 100;
-  opts.gang_schedule = true;
-  CPPUNIT_ASSERT_THROW(mgr = gc_make_job_manager(&opts), std::out_of_range);
-#endif
-}
-
-static void
-init_jd(gc_job_desc *jd, gc_proc_id_t proc_id)
-{
-  jd->proc_id = proc_id;
-  jd->input.nargs = 0;
-  jd->output.nargs = 0;
-  jd->eaa.nargs = 0;
-}
-
-void
-qa_job_manager::t4_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-  //mgr->set_debug(-1);
-  static const int NJOBS = 32;
-  gc_job_desc *jds[NJOBS];
-  bool done[NJOBS];
-
-  gc_proc_id_t gcp_no_such;
-  CPPUNIT_ASSERT_THROW(gcp_no_such = mgr->lookup_proc("--no-such-proc-name--"), gc_unknown_proc);
-
-  gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
-  CPPUNIT_ASSERT(gcp_qa_nop != GCP_UNKNOWN_PROC);
-
-  for (int i = 0; i < NJOBS; i++){
-    jds[i] = mgr->alloc_job_desc();
-    init_jd(jds[i], gcp_qa_nop);
-  }
-
-  for (int i = 0; i < NJOBS; i++){
-    if (!mgr->submit_job(jds[i])){
-      printf("%d: submit_job(jds[%d]) failed, status = %d\n",
-            __LINE__, i, jds[i]->status);
-    }
-  }
-
-  int n = mgr->wait_jobs(NJOBS, jds, done, GC_WAIT_ALL);
-  CPPUNIT_ASSERT_EQUAL(NJOBS, n);
-
-  for (int i = 0; i < NJOBS; i++){
-    mgr->free_job_desc(jds[i]);
-  }
-}
-
-void
-qa_job_manager::t5_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 0;      // use them all
-  mgr = gc_make_job_manager(&opts);
-  //mgr->set_debug(-1);
-  static const int NJOBS = 32;
-  gc_job_desc *jds[NJOBS];
-  bool done[NJOBS];
-
-  gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
-
-  for (int i = 0; i < NJOBS; i++){
-    jds[i] = mgr->alloc_job_desc();
-    init_jd(jds[i], gcp_qa_nop);
-  }
-
-  for (int i = 0; i < NJOBS; i++){
-    if (!mgr->submit_job(jds[i])){
-      printf("%d: submit_job(jds[%d]) failed, status = %d\n",
-            __LINE__, i, jds[i]->status);
-    }
-  }
-
-  int n = mgr->wait_jobs(NJOBS, jds, done, GC_WAIT_ALL);
-  CPPUNIT_ASSERT_EQUAL(NJOBS, n);
-
-  for (int i = 0; i < NJOBS; i++){
-    mgr->free_job_desc(jds[i]);
-  }
-}
-
-void
-qa_job_manager::t6_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;      
-  mgr = gc_make_job_manager(&opts);
-  gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
-  gc_job_desc *jd = mgr->alloc_job_desc();
-
-  
-  // test for success with gcp_qa_nop procedure
-  init_jd(jd, gcp_qa_nop);
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
-  }
-
-  // test for JS_UNKNOWN_PROC with bogus procedure
-  init_jd(jd, -2);
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_UNKNOWN_PROC, jd->status);
-  }
-
-  mgr->free_job_desc(jd);
-}
-
-static int
-sum_shorts(short *p, int nshorts)
-{
-  int total = 0;
-  for (int i = 0; i < nshorts; i++)
-    total += p[i];
-
-  return total;
-}
-
-static void
-test_sum_shorts(gc_job_manager_sptr mgr, short *buf, int nshorts)
-{
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
-
-  init_jd(jd, gcp_qa_sum_shorts);
-  jd->eaa.nargs = 1;
-  jd->eaa.arg[0].ea_addr = ptr_to_ea(buf);
-  jd->eaa.arg[0].direction = GCJD_DMA_GET;
-  jd->eaa.arg[0].get_size = nshorts * sizeof(short);
-  
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
-    int expected = sum_shorts(buf, nshorts);
-    int actual = jd->output.arg[0].s32;
-    CPPUNIT_ASSERT_EQUAL(expected, actual);
-  }
-
-  mgr->free_job_desc(jd);
-}
-
-static const int NS = 32768;
-static short short_buf[NS] _AL128;     // for known alignment
-
-//
-// test all "get" alignments and sizes
-//
-void
-qa_job_manager::t7_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-
-  int ea_args_maxsize = mgr->ea_args_maxsize();
-
-  for (int i = 0; i < NS; i++) // init buffer with known qty
-    short_buf[i] = 0x1234 + i;
-  
-  for (int offset = 0; offset <= 128; offset++){
-    for (int len = 0; len <= 128; len++){
-      test_sum_shorts(mgr, &short_buf[offset], len);
-    }
-  }
-
-  // confirm maximum length
-  for (int offset = 0; offset <= 64; offset++){
-    test_sum_shorts(mgr, &short_buf[offset], ea_args_maxsize/sizeof(short));
-  }
-}
-
-//
-// test "get" args too long
-//
-void
-qa_job_manager::t8_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
-
-  init_jd(jd, gcp_qa_sum_shorts);
-  jd->eaa.nargs = 1;
-  jd->eaa.arg[0].ea_addr = 0;
-  jd->eaa.arg[0].direction = GCJD_DMA_GET;
-  jd->eaa.arg[0].get_size = 1 << 20;
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_ARGS_TOO_LONG, jd->status);
-  }
-
-  mgr->free_job_desc(jd);
-}
-
-//
-// test MAX_ARGS_EA "get" case
-//
-void
-qa_job_manager::t9_body()
-{
-  static const int N = 127;
-  static const int M = 201;
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
-
-  init_jd(jd, gcp_qa_sum_shorts);
-  jd->eaa.nargs = MAX_ARGS_EA;
-  for (int i = 0; i < MAX_ARGS_EA; i++){
-    jd->eaa.arg[i].direction = GCJD_DMA_GET;
-    jd->eaa.arg[i].ea_addr = ptr_to_ea(&short_buf[i * M]);
-    jd->eaa.arg[i].get_size = N * sizeof(short);
-  }
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
-    for (int i = 0; i < MAX_ARGS_EA; i++){
-      int expected = sum_shorts(&short_buf[i * M], N);
-      int actual = jd->output.arg[i].s32;
-      CPPUNIT_ASSERT_EQUAL(expected, actual);
-    }
-  }
-
-  mgr->free_job_desc(jd);
-}
-
-static bool
-confirm_const(const unsigned char *buf, size_t len, unsigned char v)
-{
-  bool ok = true;
-
-  for (size_t i = 0; i < len; i++){
-    if (buf[i] != v){
-      ok = false;
-      printf("confirm_const: buf[%6d] = 0x%02x, expected = 0x%02x\n",
-            i, buf[i], v);
-    }
-  }
-
-  return ok;
-}
-
-static bool
-confirm_seq(const unsigned char *buf, size_t len, unsigned char v)
-{
-  bool ok = true;
-
-  for (size_t i = 0; i < len; i++, v++){
-    if (buf[i] != v){
-      ok = false;
-      printf("confirm_seq: buf[%6d] = 0x%02x, expected = 0x%02x\n",
-            i, buf[i], v);
-    }
-  }
-
-  return ok;
-}
-
-static void
-test_put_seq(gc_job_manager_sptr mgr, int offset, int len, int starting_val)
-{
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
-
-  unsigned char *buf = (unsigned char *) short_buf;
-  size_t buf_len = sizeof(short_buf);
-  memset(buf, 0xff, buf_len);
-
-  // two cache lines into the buffer, so we can check before and after
-  int fixed_offset = 256;
-
-  init_jd(jd, gcp_qa_put_seq);
-  jd->input.nargs = 1;
-  jd->input.arg[0].s32 = starting_val;
-  jd->eaa.nargs = 1;
-  jd->eaa.arg[0].ea_addr = ptr_to_ea(buf + fixed_offset + offset);
-  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
-  jd->eaa.arg[0].put_size = len;
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
-    
-    // check before
-    CPPUNIT_ASSERT(confirm_const(&buf[0], fixed_offset + offset, 0xff)); 
-
-    // check sequence
-    CPPUNIT_ASSERT(confirm_seq(&buf[fixed_offset + offset], len, starting_val));
-
-    // check after
-    CPPUNIT_ASSERT(confirm_const(&buf[fixed_offset + offset + len],
-                                buf_len - fixed_offset - offset - len, 0xff));
-  }
-  mgr->free_job_desc(jd);
-}
-
-//
-// Test all "put" alignments and sizes
-//
-void
-qa_job_manager::t10_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-
-  int starting_val = 13;
-
-  for (int offset = 0; offset <= 128; offset++){
-    for (int len = 0; len <= 128; len++){
-      test_put_seq(mgr, offset, len, starting_val++);
-    }
-  }
-
-  int ea_args_maxsize = mgr->ea_args_maxsize();
-
-  // confirm maximum length
-  for (int offset = 0; offset <= 64; offset++){
-    test_put_seq(mgr, offset, ea_args_maxsize, starting_val++);
-  }
-}
-
-//
-// test "put" args too long
-//
-void
-qa_job_manager::t11_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
-
-  init_jd(jd, gcp_qa_put_seq);
-  jd->input.nargs = 1;
-  jd->input.arg[0].s32 = 0;
-  jd->eaa.nargs = 1;
-  jd->eaa.arg[0].ea_addr = 0;
-  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
-  jd->eaa.arg[0].put_size = 1 << 20;
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_ARGS_TOO_LONG, jd->status);
-  }
-
-  mgr->free_job_desc(jd);
-}
-
-//
-// test MAX_ARGS_EA "put" case
-//
-void
-qa_job_manager::t12_body()
-{
-  static const int N = 127;
-  static const int M = 201;
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
-
-  unsigned char *buf = (unsigned char *) short_buf;
-  size_t buf_len = sizeof(short_buf);
-  memset(buf, 0xff, buf_len);
-
-  // two cache lines into the buffer, so we can check before and after
-  int fixed_offset = 256;
-
-  int starting_val = 13;
-
-  init_jd(jd, gcp_qa_put_seq);
-  jd->input.nargs = 1;
-  jd->input.arg[0].s32 = starting_val;
-  jd->eaa.nargs = MAX_ARGS_EA;
-  for (int i = 0; i < MAX_ARGS_EA; i++){
-    jd->eaa.arg[i].direction = GCJD_DMA_PUT;
-    jd->eaa.arg[i].ea_addr = ptr_to_ea(&buf[i * M + fixed_offset]);
-    jd->eaa.arg[i].put_size = N;
-  }
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
-    for (int i = 0; i < MAX_ARGS_EA; i++){
-      CPPUNIT_ASSERT(confirm_seq(&buf[i * M + fixed_offset], N, starting_val));
-      starting_val += N;
-    }
-  }
-
-  mgr->free_job_desc(jd);
-}
-
-//
-// test qa_copy primitive
-//
-void
-qa_job_manager::t13_body()
-{
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-
-  memset(short_buf, 0, sizeof(short_buf));
-  for (int i = 0; i < NS/2; i++)       // init buffer with known qty
-    short_buf[i] = 0x1234 + i;
-
-  int nshorts = NS/2;
-
-  gc_job_desc *jd = mgr->alloc_job_desc();
-  gc_proc_id_t gcp_qa_copy = mgr->lookup_proc("qa_copy");
-
-#if 0
-  printf("gcq_qa_copy = %d\n", gcp_qa_copy);
-  std::vector<std::string> procs = mgr->proc_names();
-  for (unsigned int i = 0; i < procs.size(); ++i)
-    std::cout << procs[i] << std::endl;
-#endif
-
-  init_jd(jd, gcp_qa_copy);
-  jd->eaa.nargs = 2;
-  jd->eaa.arg[0].ea_addr = ptr_to_ea(&short_buf[nshorts]);
-  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
-  jd->eaa.arg[0].put_size = nshorts * sizeof(short);
-  
-  jd->eaa.arg[1].ea_addr = ptr_to_ea(&short_buf[0]);
-  jd->eaa.arg[1].direction = GCJD_DMA_GET;
-  jd->eaa.arg[1].get_size = nshorts * sizeof(short);
-  
-
-  if (!mgr->submit_job(jd)){
-    printf("%d: submit_job(jd) failed, status = %d\n", __LINE__, jd->status);
-  }
-  else {
-    mgr->wait_job(jd);
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
-    CPPUNIT_ASSERT_EQUAL(0, jd->output.arg[0].s32);
-
-    bool ok = true;
-    for (int i = 0; i < nshorts; i++){
-      if (short_buf[i] != short_buf[i + nshorts])
-       ok = false;
-    }
-    CPPUNIT_ASSERT(ok);
-  }
-  mgr->free_job_desc(jd);
-}
-
-/*
- * Parallel submission of NJOBS "put" jobs will test double buffered puts.
- */
-void
-qa_job_manager::t14_body()
-{
-  //return;
-
-  //static const int NJOBS = 64;
-  static const int NJOBS = 128;
-  static const int LEN_PER_JOB = 1021;
-  unsigned char    buf[NJOBS * LEN_PER_JOB];
-  gc_job_desc_t          *jd[NJOBS];
-  bool            done[NJOBS];
-
-  static const int STARTING_VAL = 13;
-
-  memset(buf, 0xff, LEN_PER_JOB * NJOBS);
-
-  gc_job_manager_sptr mgr;
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  mgr = gc_make_job_manager(&opts);
-
-
-  gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
-
-  // do all the initialization up front
-
-  for (int i = 0, val = STARTING_VAL; i < NJOBS; i++, val += 3){
-    jd[i] = mgr->alloc_job_desc();
-    init_jd(jd[i], gcp_qa_put_seq);
-    jd[i]->input.nargs = 1;
-    jd[i]->input.arg[0].s32 = val;
-    jd[i]->eaa.nargs = 1;
-    jd[i]->eaa.arg[0].ea_addr = ptr_to_ea(&buf[i * LEN_PER_JOB]);
-    jd[i]->eaa.arg[0].direction = GCJD_DMA_PUT;
-    jd[i]->eaa.arg[0].put_size = LEN_PER_JOB;
-  }
-
-  // submit them all
-
-  for (int i = 0; i < NJOBS; i++){
-    if (!mgr->submit_job(jd[i])){
-      printf("%d: submit_job(jd[%2d]) failed, status = %d\n", __LINE__, i, jd[i]->status);
-    }
-  }
-
-  // wait for them all
-
-  int n = mgr->wait_jobs(NJOBS, jd, done, GC_WAIT_ALL);
-  CPPUNIT_ASSERT_EQUAL(NJOBS, n);
-
-  // check results
-
-  for (int i = 0, val = STARTING_VAL; i < NJOBS; i++, val += 3){
-    CPPUNIT_ASSERT_EQUAL(JS_OK, jd[i]->status);
-    CPPUNIT_ASSERT(confirm_seq(&buf[i * LEN_PER_JOB], LEN_PER_JOB, val));
-  }
-  
-  // cleanup
-  for (int i = 0; i < NJOBS; i++)
-    mgr->free_job_desc(jd[i]);
-}
-
-void
-qa_job_manager::t15_body()
-{
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
-  opts.nspes = 1;
-  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
-
-  gc_job_manager::set_singleton(mgr);
-
-  CPPUNIT_ASSERT(gc_job_manager::singleton());
-  mgr.reset();
-  CPPUNIT_ASSERT_THROW(gc_job_manager::singleton(), boost::bad_weak_ptr);
-}
diff --git a/gcell/src/lib/runtime/qa_job_manager.h b/gcell/src/lib/runtime/qa_job_manager.h
deleted file mode 100644 (file)
index ab3325b..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_QA_JOB_MANAGER_H
-#define INCLUDED_QA_JOB_MANAGER_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_job_manager;
-typedef void (qa_job_manager::*test_t)();
-
-
-class qa_job_manager : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_job_manager);
-  CPPUNIT_TEST(t0);
-  CPPUNIT_TEST(t1);
-  CPPUNIT_TEST(t2);
-  CPPUNIT_TEST(t3);
-  CPPUNIT_TEST(t4);
-  CPPUNIT_TEST(t5);
-  CPPUNIT_TEST(t6);
-  CPPUNIT_TEST(t7);
-  CPPUNIT_TEST(t8);
-  CPPUNIT_TEST(t9);
-  CPPUNIT_TEST(t10);
-  CPPUNIT_TEST(t11);
-  CPPUNIT_TEST(t12);
-  CPPUNIT_TEST(t13);
-  CPPUNIT_TEST(t14);
-  CPPUNIT_TEST(t15);
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-  void leak_check(test_t t, const std::string &name);
-
-  void t0();
-  void t1();
-  void t1_body();
-  void t2();
-  void t2_body();
-  void t3();
-  void t3_body();
-  void t4();
-  void t4_body();
-  void t5();
-  void t5_body();
-  void t6();
-  void t6_body();
-  void t7();
-  void t7_body();
-  void t8();
-  void t8_body();
-  void t9();
-  void t9_body();
-  void t10();
-  void t10_body();
-  void t11();
-  void t11_body();
-  void t12();
-  void t12_body();
-  void t13();
-  void t13_body();
-  void t14();
-  void t14_body();
-  void t15();
-  void t15_body();
-
-};
-
-#endif /* INCLUDED_QA_JOB_MANAGER_H */
diff --git a/gcell/src/lib/runtime/spu/gc_delay.c b/gcell/src/lib/runtime/spu/gc_delay.c
deleted file mode 100644 (file)
index 21ee587..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "gc_delay.h"
-#include <compiler.h>
-
-inline static void
-gc_udelay_1us(void)
-{
-  unsigned int i = 158;
-
-  do {  // 20 clocks per iteration of the loop
-    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
-    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
-    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
-    asm ("nop $127; nop $127");
-  } while(--i != 0);
-}
-
-void
-gc_udelay(unsigned int usecs)
-{
-  unsigned int i;
-  for (i = 0; i < usecs; i++)
-    gc_udelay_1us();
-}
-
-void
-gc_cdelay(unsigned int cpu_cycles)
-{
-  if (cpu_cycles < 40) // roughly the amount of overhead
-    return;
-  
-  cpu_cycles >>= 2;    // about 4 cycles / loop
-
-  while (cpu_cycles-- != 0){
-    asm ("nop $127");  // keeps compiler from removing the loop
-  }
-}
-
diff --git a/gcell/src/lib/runtime/spu/gc_logging.c b/gcell/src/lib/runtime/spu/gc_logging.c
deleted file mode 100644 (file)
index 65a5375..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <gc_logging.h>
-#include <spu_intrinsics.h>
-#include <spu_mfcio.h>
-#include <gc_spu_args.h>
-
-static gc_eaddr_t     log_base_ea;     // base address of log entries in EA
-static uint32_t              log_idx_mask;     // nentries - 1
-static uint32_t              log_idx;          // current log entry index
-static uint32_t              log_seqno;
-
-static int           log_tags;         // two consecutive tags
-static int           tmp_buffer_busy;  // bitmask: buffer busy state
-static int           tmp_buffer_idx;   // 0 or 1
-static gc_log_entry_t tmp_buffer[2];
-
-void
-_gc_log_init(gc_log_t info)
-{
-  spu_write_decrementer(~0);
-
-  log_base_ea = info.base;
-  log_idx_mask = info.nentries - 1;
-  log_idx = 0;
-  log_seqno = 0;
-
-  log_tags = mfc_multi_tag_reserve(2);
-  tmp_buffer_busy = 0;
-  tmp_buffer_idx = 0;
-
-  gc_log_write0(GCL_SS_SYS, 0);
-}
-
-void
-_gc_log_write(gc_log_entry_t entry)
-{
-  if (log_base_ea == 0)
-    return;
-
-  entry.seqno = log_seqno++;
-  entry.timestamp = spu_read_decrementer();
-
-  if (tmp_buffer_busy & (1 << tmp_buffer_idx)){
-    mfc_write_tag_mask(1 << (log_tags + tmp_buffer_idx));
-    mfc_read_tag_status_all();
-  }
-
-  tmp_buffer[tmp_buffer_idx] = entry;  // save local copy
-
-  mfc_put(&tmp_buffer[tmp_buffer_idx],
-         log_base_ea + log_idx * sizeof(entry), sizeof(entry),
-         log_tags + tmp_buffer_idx, 0, 0);
-
-  tmp_buffer_busy |= (1 << tmp_buffer_idx);
-  tmp_buffer_idx ^= 0x1;
-  log_idx = (log_idx + 1) & log_idx_mask;
-}
diff --git a/gcell/src/lib/runtime/spu/gc_main.c b/gcell/src/lib/runtime/spu/gc_main.c
deleted file mode 100644 (file)
index 1e5b03d..0000000
+++ /dev/null
@@ -1,707 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-// #define ENABLE_GC_LOGGING   // define to enable logging
-
-#include <spu_intrinsics.h>
-#include <spu_mfcio.h>
-#include <sync_utils.h>
-#include "gc_spu_config.h"
-#include "gc_spu_args.h"
-#include "gc_job_desc.h"
-#include "gc_mbox.h"
-#include "gc_jd_queue.h"
-#include "gc_delay.h"
-#include "gc_declare_proc.h"
-#include "gc_random.h"
-#include "spu_buffers.h"
-#include <string.h>
-#include <assert.h>
-#include <stdio.h>
-
-
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
-//! round x down to p2 boundary (p2 must be a power-of-2)
-#define ROUND_DN(x, p2) ((x) & ~((p2)-1))
-
-//! round x up to p2 boundary (p2 must be a power-of-2)
-#define ROUND_UP(x, p2) (((x)+((p2)-1)) & ~((p2)-1))
-
-
-#define USE_LLR_LOST_EVENT     0       // define to 0 or 1
-
-int                    gc_sys_tag;     // tag for misc DMA operations
-static gc_spu_args_t   spu_args;
-
-static struct gc_proc_def *gc_proc_def;        // procedure entry points
-
-// ------------------------------------------------------------------------
-
-// state for DMA'ing arguments in and out
-
-static int get_tag;            // 1 tag for job arg gets
-static int put_tags;           // 2 tags for job arg puts
-
-static int pb_idx = 0;         // current put buffer index (0 or 1)
-
-// bitmask (bit per put buffer): bit is set if DMA is started but not complete
-static int put_in_progress = 0;
-#define PBI_MASK(_pbi_) (1 << (_pbi_))
-
-// ------------------------------------------------------------------------
-
-// our working copy of the completion info
-static gc_comp_info_t  comp_info = {  
-  .in_use = 1,
-  .ncomplete = 0
-};
-
-static int ci_idx = 0;         // index of current comp_info
-static int ci_tags;            // two consecutive dma tags
-
-// ------------------------------------------------------------------------
-
-/*
- * Wait until EA copy of comp_info[idx].in_use is 0
- */
-static void
-wait_for_ppe_to_be_done_with_comp_info(int idx)
-{
-  char _tmp[256];
-  char *buf = (char *) ALIGN(_tmp, 128);       // get cache-aligned buffer
-  gc_comp_info_t *p = (gc_comp_info_t *) buf;
-
-  assert(sizeof(gc_comp_info_t) == 128);
-
-  do {
-    mfc_get(buf, spu_args.comp_info[idx], 128, gc_sys_tag, 0, 0);
-    mfc_write_tag_mask(1 << gc_sys_tag);
-    mfc_read_tag_status_all();
-    if (p->in_use == 0)
-      return;
-
-    gc_udelay(5);
-
-  } while (1);
-}
-
-static void
-flush_completion_info(void)
-{
-  // events: 0x3X
-
-  static int total_complete = 0;
-
-  if (comp_info.ncomplete == 0)
-    return;
-  
-  // ensure that PPE is done with the buffer we're about to overwrite
-  wait_for_ppe_to_be_done_with_comp_info(ci_idx);
-
-  // dma the comp_info out to PPE
-  int tag = ci_tags + ci_idx;
-  mfc_put(&comp_info, spu_args.comp_info[ci_idx], sizeof(gc_comp_info_t), tag, 0, 0);
-
-  // we need to wait for the completion info to finish, as well as
-  // any EA argument puts.
-
-  int tag_mask = 1 << tag;             // the comp_info tag
-  if (put_in_progress & PBI_MASK(0))
-    tag_mask |= (1 << (put_tags + 0));
-  if (put_in_progress & PBI_MASK(1))
-    tag_mask |= (1 << (put_tags + 1));
-
-  gc_log_write2(GCL_SS_SYS, 0x30, put_in_progress, tag_mask);
-
-  mfc_write_tag_mask(tag_mask);                // the tags we're interested in
-  mfc_read_tag_status_all();           // wait for DMA to complete
-  put_in_progress = 0;                 // mark them all complete
-
-  total_complete += comp_info.ncomplete;
-  gc_log_write4(GCL_SS_SYS, 0x31,
-               put_in_progress, ci_idx, comp_info.ncomplete, total_complete);
-
-  // send PPE a message
-  spu_writech(SPU_WrOutIntrMbox, MK_MBOX_MSG(OP_JOBS_DONE, ci_idx));
-
-  ci_idx ^= 0x1;       // switch buffers
-  comp_info.in_use = 1;
-  comp_info.ncomplete = 0;
-}
-
-// ------------------------------------------------------------------------
-
-static unsigned int backoff;           // current backoff value in clock cycles
-static unsigned int _backoff_start;
-static unsigned int _backoff_cap;
-
-/*
- * For 3.2 GHz SPE
- *
- * 12    4095 cycles    1.3 us
- * 13    8191 cycles    2.6 us
- * 14   16383 cycles    5.1 us
- * 15   32767 cycles   10.2 us
- * 16                  20.4 us
- * 17                  40.8 us
- * 18                  81.9 us
- * 19                 163.8 us
- * 20                 327.7 us
- * 21                 655.4 us
- */
-static unsigned char log2_backoff_start[16] = {
-// 1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
-// -------------------------------------------------------------
-  12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16
-};
-  
-static unsigned char log2_backoff_cap[16] = {
-// 1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
-// -------------------------------------------------------------
-  17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 21, 21
-};
-  
-static void
-backoff_init(void)
-{
-  _backoff_cap   = (1 << (log2_backoff_cap[(spu_args.nspus - 1) & 0xf])) - 1;
-  _backoff_start = (1 << (log2_backoff_start[(spu_args.nspus - 1) & 0xf])) - 1;
-  
-  backoff = _backoff_start;
-}
-
-static void 
-backoff_reset(void)
-{
-  backoff = _backoff_start;
-}
-
-#if 0
-
-static void
-backoff_delay(void)
-{
-  gc_cdelay(backoff);
-
-  // capped exponential backoff
-  backoff = ((backoff << 1) + 1) & _backoff_cap;
-}
-
-#else
-
-#define RANDOM_WEIGHT  0.2
-
-static void
-backoff_delay(void)
-{
-  gc_cdelay(backoff);
-
-  backoff = ((backoff << 1) + 1);
-  if (backoff > _backoff_cap)
-    backoff = _backoff_cap;
-
-  float r = (RANDOM_WEIGHT * (2.0 * (gc_uniform_deviate() - 0.5)));
-  backoff = backoff * (1.0 + r);
-}
-
-#endif
-
-// ------------------------------------------------------------------------
-
-static inline unsigned int
-make_mask(int nbits)
-{
-  return ~(~0 << nbits);
-}
-
-static unsigned int   dc_work;
-static int            dc_put_tag;
-static unsigned char *dc_ls_base;
-static gc_eaddr_t     dc_ea_base;
-
-// divide and conquer
-static void
-d_and_c(unsigned int offset, unsigned int len)
-{
-  unsigned int mask = make_mask(len) << offset;
-  unsigned int t = mask & dc_work;
-  if (t == 0)          // nothing to do
-    return;
-  if (t == mask){      // got a match, generate dma
-    mfc_put(dc_ls_base + offset, dc_ea_base + offset, len, dc_put_tag, 0, 0);
-  }
-  else {               // bisect
-    len >>= 1;
-    d_and_c(offset, len);
-    d_and_c(offset + len, len);
-  }
-}
-
-// Handle the nasty case of a dma xfer that's less than 16 bytes long.
-// len is guaranteed to be in [1, 15]
-
-static void
-handle_slow_and_tedious_dma(gc_eaddr_t ea, unsigned char *ls,
-                           unsigned int len, int put_tag)
-{
-  // Set up for divide and conquer
-  unsigned int alignment = ((uintptr_t) ls) & 0x7;
-  dc_work = make_mask(len) << alignment;
-  dc_ls_base = (unsigned char *) ROUND_DN((uintptr_t) ls, 8);
-  dc_ea_base = ROUND_DN(ea, (gc_eaddr_t) 8);
-  dc_put_tag = put_tag;
-
-  d_and_c( 0, 8);
-  d_and_c( 8, 8);
-  d_and_c(16, 8);
-}
-
-
-static void
-process_job(gc_eaddr_t jd_ea, gc_job_desc_t *jd)
-{
-  // events: 0x2X
-
-  jd->status = JS_OK;  // assume success
-
-  if (jd->proc_id >= spu_args.nproc_defs)
-    jd->status = JS_UNKNOWN_PROC;
-    
-  else {
-  
-    if (jd->eaa.nargs == 0)
-      (*gc_proc_def[jd->proc_id].proc)(&jd->input, &jd->output, &jd->eaa);
-
-    else {     // handle EA args that must be DMA'd in/out
-
-      gc_job_ea_args_t *eaa = &jd->eaa;
-
-      int NELMS =
-       MAX(MAX_ARGS_EA,
-           (GC_SPU_BUFSIZE + MFC_MAX_DMA_SIZE - 1) / MFC_MAX_DMA_SIZE);
-
-      mfc_list_element_t  dma_get_list[NELMS];
-      //mfc_list_element_t  dma_put_list[NELMS];
-      
-      memset(dma_get_list, 0, sizeof(dma_get_list));
-      //memset(dma_put_list, 0, sizeof(dma_put_list));
-
-      int gli = 0;     // get list index
-      //int pli = 0;   // put list index
-
-      unsigned char *get_base = _gci_getbuf[0];
-      unsigned char *get_t = get_base;
-      unsigned int   total_get_dma_len = 0;
-
-      unsigned char *put_base = _gci_putbuf[pb_idx];
-      unsigned char *put_t = put_base;
-      unsigned int   total_put_alloc = 0;
-      int           put_tag = put_tags + pb_idx;
-
-      // Do we have any "put" args?  If so ensure that previous
-      // dma from this buffer is complete
-
-      gc_log_write2(GCL_SS_SYS, 0x24, put_in_progress, jd->sys.direction_union);
-
-      if ((jd->sys.direction_union & GCJD_DMA_PUT)
-         && (put_in_progress & PBI_MASK(pb_idx))){
-
-       gc_log_write2(GCL_SS_SYS, 0x25, put_in_progress, 1 << put_tag);
-
-       mfc_write_tag_mask(1 << put_tag);       // the tag we're interested in
-       mfc_read_tag_status_all();              // wait for DMA to complete
-       put_in_progress &= ~(PBI_MASK(pb_idx));
-
-       gc_log_write1(GCL_SS_SYS, 0x26, put_in_progress);
-      }
-
-
-      // for now, all EA's must have the same high 32-bits
-      gc_eaddr_t common_ea = eaa->arg[0].ea_addr;
-
-
-      // assign LS addresses for buffers
-      
-      for (unsigned int i = 0; i < eaa->nargs; i++){
-
-       gc_eaddr_t      ea_base = 0;
-       unsigned char  *ls_base;
-       int             offset;
-       unsigned int    dma_len;
-
-       if (eaa->arg[i].direction == GCJD_DMA_GET){
-         ea_base = ROUND_DN(eaa->arg[i].ea_addr, (gc_eaddr_t) CACHE_LINE_SIZE);
-         offset = eaa->arg[i].ea_addr & (CACHE_LINE_SIZE-1);
-         dma_len = ROUND_UP(eaa->arg[i].get_size + offset, CACHE_LINE_SIZE);
-         total_get_dma_len += dma_len;
-
-         if (total_get_dma_len > GC_SPU_BUFSIZE){
-           jd->status = JS_ARGS_TOO_LONG;
-           goto wrap_up;
-         }
-
-         ls_base = get_t;
-         get_t += dma_len;
-         eaa->arg[i].ls_addr = ls_base + offset;
-
-         if (0){
-           assert((mfc_ea2l(eaa->arg[i].ea_addr) & 0x7f) == ((intptr_t)eaa->arg[i].ls_addr & 0x7f));
-           assert((ea_base & 0x7f) == 0);
-           assert(((intptr_t)ls_base & 0x7f) == 0);
-           assert((dma_len & 0x7f) == 0);
-           assert((eaa->arg[i].get_size <= dma_len)
-                  && dma_len <= (eaa->arg[i].get_size + offset + CACHE_LINE_SIZE - 1));
-         }
-
-         // add to dma get list 
-         // FIXME (someday) the dma list is where the JS_BAD_EAH limitation comes from
-
-         while (dma_len != 0){
-           int n = MIN(dma_len, MFC_MAX_DMA_SIZE);
-           dma_get_list[gli].size = n;
-           dma_get_list[gli].eal = mfc_ea2l(ea_base);
-           dma_len -= n;
-           ea_base += n;
-           gli++;
-         }
-       }
-
-       else if (eaa->arg[i].direction == GCJD_DMA_PUT){
-         //
-         // This case is a trickier than the PUT case since we can't
-         // write outside of the bounds of the user provided buffer.
-         // We still align the buffers to 128-bytes for good performance
-         // in the middle portion of the xfers.
-         //
-         ea_base = ROUND_DN(eaa->arg[i].ea_addr, (gc_eaddr_t) CACHE_LINE_SIZE);
-         offset = eaa->arg[i].ea_addr & (CACHE_LINE_SIZE-1);
-
-         uint32_t ls_alloc_len =
-           ROUND_UP(eaa->arg[i].put_size + offset, CACHE_LINE_SIZE);
-
-         total_put_alloc += ls_alloc_len;
-
-         if (total_put_alloc > GC_SPU_BUFSIZE){
-           jd->status = JS_ARGS_TOO_LONG;
-           goto wrap_up;
-         }
-
-         ls_base = put_t;
-         put_t += ls_alloc_len;
-         eaa->arg[i].ls_addr = ls_base + offset;
-
-         if (1){
-           assert((mfc_ea2l(eaa->arg[i].ea_addr) & 0x7f)
-                  == ((intptr_t)eaa->arg[i].ls_addr & 0x7f));
-           assert((ea_base & 0x7f) == 0);
-           assert(((intptr_t)ls_base & 0x7f) == 0);
-         }
-       }
-
-       else
-         assert(0);
-      }
-
-      // fire off the dma to fetch the args and wait for it to complete
-      mfc_getl(get_base, common_ea, dma_get_list, gli*sizeof(dma_get_list[0]), get_tag, 0, 0);
-      mfc_write_tag_mask(1 << get_tag);                // the tag we're interested in
-      mfc_read_tag_status_all();               // wait for DMA to complete
-
-      // do the work
-      (*gc_proc_def[jd->proc_id].proc)(&jd->input, &jd->output, &jd->eaa);
-
-
-      // Do we have any "put" args?  If so copy them out
-      if (jd->sys.direction_union & GCJD_DMA_PUT){
-
-       // Do the copy out using single DMA xfers.  The LS ranges
-       // aren't generally contiguous.
-       
-       bool started_dma = false;
-
-       for (unsigned int i = 0; i < eaa->nargs; i++){
-         if (eaa->arg[i].direction == GCJD_DMA_PUT && eaa->arg[i].put_size != 0){
-           
-           started_dma = true;
-
-           gc_eaddr_t       ea;
-           unsigned char   *ls;
-           unsigned int     len;
-
-           ea = eaa->arg[i].ea_addr;
-           ls = (unsigned char *) eaa->arg[i].ls_addr;
-           len = eaa->arg[i].put_size;
-
-           if (len < 16)
-             handle_slow_and_tedious_dma(ea, ls, len, put_tag);
-           
-           else {
-             if ((ea & 0xf) != 0){
-
-               // printf("1:  ea = 0x%x  len = %5d\n", (int) ea, len);
-               
-               // handle the "pre-multiple-of-16" portion
-               // do 1, 2, 4, or 8 byte xfers as required
-
-               if (ea & 0x1){                          // do a 1-byte xfer
-                 mfc_put(ls, ea, 1, put_tag, 0, 0);
-                 ea += 1;
-                 ls += 1;
-                 len -= 1;
-               }
-               if (ea & 0x2){                          // do a 2-byte xfer
-                 mfc_put(ls, ea, 2, put_tag, 0, 0);
-                 ea += 2;
-                 ls += 2;
-                 len -= 2;
-               }
-               if (ea & 0x4){                          // do a 4-byte xfer
-                 mfc_put(ls, ea, 4, put_tag, 0, 0);
-                 ea += 4;
-                 ls += 4;
-                 len -= 4;
-               }
-               if (ea & 0x8){                          // do an 8-byte xfer
-                 mfc_put(ls, ea, 8, put_tag, 0, 0);
-                 ea += 8;
-                 ls += 8;
-                 len -= 8;
-               }
-             }
-
-             if (1){
-               // printf("2:  ea = 0x%x  len = %5d\n", (int) ea, len);
-               assert((ea & 0xf) == 0);
-               assert((((intptr_t) ls) & 0xf) == 0);
-             }
-
-             // handle the "multiple-of-16" portion
-
-             int aligned_len = ROUND_DN(len, 16);
-             len = len & (16 - 1);
-
-             while (aligned_len != 0){
-               int dma_len = MIN(aligned_len, MFC_MAX_DMA_SIZE);
-               mfc_put(ls, ea, dma_len, put_tag, 0, 0);
-               ea += dma_len;
-               ls += dma_len;
-               aligned_len -= dma_len;
-             }
-
-             if (1){
-               // printf("3:  ea = 0x%x  len = %5d\n", (int)ea, len);
-               assert((ea & 0xf) == 0);
-               assert((((intptr_t) ls) & 0xf) == 0);
-             }
-
-             // handle "post-multiple-of-16" portion
-
-             if (len != 0){
-
-               if (len >= 8){                          // do an 8-byte xfer
-                 mfc_put(ls, ea, 8, put_tag, 0, 0);
-                 ea += 8;
-                 ls += 8;
-                 len -= 8;
-               }
-               if (len >= 4){                          // do a 4-byte xfer
-                 mfc_put(ls, ea, 4, put_tag, 0, 0);
-                 ea += 4;
-                 ls += 4;
-                 len -= 4;
-               }
-               if (len >= 2){                          // do a 2-byte xfer
-                 mfc_put(ls, ea, 2, put_tag, 0, 0);
-                 ea += 2;
-                 ls += 2;
-                 len -= 2;
-               }
-               if (len >= 1){                          // do a 1-byte xfer
-                 mfc_put(ls, ea, 1, put_tag, 0, 0);
-                 ea += 1;
-                 ls += 1;
-                 len -= 1;
-               }
-               if (1)
-                 assert(len == 0);
-             }
-           }
-         }
-       }
-       if (started_dma){
-         put_in_progress |= PBI_MASK(pb_idx);          // note it's running
-         gc_log_write2(GCL_SS_SYS, 0x27, put_in_progress, pb_idx);
-         pb_idx ^= 1;                                  // toggle current buffer
-       }
-      }
-    }
-  }
-
- wrap_up:;     // semicolon creates null statement for C99 compliance
-
-  // Copy job descriptor back out to EA.
-  // (The dma will be waited on in flush_completion_info)
-  int tag = ci_tags + ci_idx;                  // use the current completion tag
-  mfc_put(jd, jd_ea, sizeof(*jd), tag, 0, 0);
-
-  // Tell PPE we're done with the job.
-  //
-  // We queue these up until we run out of room, or until we can send
-  // the info to the PPE w/o blocking.  The blocking check is in
-  // main_loop
-
-  comp_info.job_id[comp_info.ncomplete++] = jd->sys.job_id;
-
-  if (comp_info.ncomplete == GC_CI_NJOBS){
-    gc_log_write0(GCL_SS_SYS, 0x28);
-    flush_completion_info();
-  }
-}
-
-static void
-main_loop(void)
-{
-  // events: 0x1X
-
-  static gc_job_desc_t jd;     // static gets us proper alignment
-  gc_eaddr_t           jd_ea;
-  int                  total_jobs = 0;
-
-#if (USE_LLR_LOST_EVENT)
-  // setup events
-  spu_writech(SPU_WrEventMask, MFC_LLR_LOST_EVENT);
-
-  // prime the pump
-  while (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, ci_tags + ci_idx, &jd))
-    process_job(jd_ea, &jd);
-  // we're now holding a lock-line reservation
-#endif
-
-  while (1){
-
-#if (USE_LLR_LOST_EVENT)
-
-    if (unlikely(spu_readchcnt(SPU_RdEventStat))){
-      //
-      // execute standard event handling prologue
-      //
-      int status = spu_readch(SPU_RdEventStat);
-      int mask = spu_readch(SPU_RdEventMask);
-      spu_writech(SPU_WrEventMask, mask & ~status);    // disable active events
-      spu_writech(SPU_WrEventAck, status);             // ack active events
-
-      // execute per-event actions
-
-      if (status & MFC_LLR_LOST_EVENT){
-       //
-       // We've lost a line reservation.  This is most likely caused
-       // by somebody doing something to the queue.  Go look and see
-       // if there's anything for us.
-       //
-       while (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, ci_tags + ci_idx, &jd))
-         process_job(jd_ea, &jd);
-      }
-
-      //
-      // execute standard event handling epilogue
-      //
-      spu_writech(SPU_WrEventMask, mask);      // restore event mask
-    }
-
-#else
-
-    // try to get a job from the job queue 
-    if (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, ci_tags + ci_idx, &jd)){
-      total_jobs++;
-      gc_log_write2(GCL_SS_SYS, 0x10, jd.sys.job_id, total_jobs);
-
-      process_job(jd_ea, &jd); 
-
-      gc_log_write2(GCL_SS_SYS, 0x11, jd.sys.job_id, total_jobs);
-      backoff_reset(); 
-    }
-    else
-      backoff_delay();
-
-#endif
-
-    // any msgs for us?
-
-    if (unlikely(spu_readchcnt(SPU_RdInMbox))){
-      int msg = spu_readch(SPU_RdInMbox);
-      // printf("spu[%d] mbox_msg: 0x%08x\n", spu_args.spu_idx, msg);
-      if (MBOX_MSG_OP(msg) == OP_EXIT){
-       flush_completion_info();
-       return;
-      }
-      if (MBOX_MSG_OP(msg) == OP_GET_SPU_BUFSIZE){
-       spu_writech(SPU_WrOutIntrMbox, MK_MBOX_MSG(OP_SPU_BUFSIZE, GC_SPU_BUFSIZE_BASE));
-      }
-    }
-
-    // If we've got job completion info for the PPE and we can send a
-    // message without blocking, do it.
-
-    if (comp_info.ncomplete != 0 && spu_readchcnt(SPU_WrOutIntrMbox) != 0){
-      gc_log_write0(GCL_SS_SYS, 0x12);
-      flush_completion_info();
-    }
-  }
-}
-
-
-int
-main(unsigned long long spe_id __attribute__((unused)),
-     unsigned long long argp,
-     unsigned long long envp __attribute__((unused)))
-{
-  gc_sys_tag = mfc_tag_reserve();      // allocate a tag for our misc DMA operations
-  get_tag  = mfc_tag_reserve();
-  ci_tags  = mfc_multi_tag_reserve(2);
-  put_tags = mfc_multi_tag_reserve(2);
-
-#if 0  
-  printf("gc_sys_tag = %d\n", gc_sys_tag);
-  printf("get_tag    = %d\n", get_tag);
-  printf("ci_tags    = %d\n", ci_tags);
-  printf("put_tags   = %d\n", put_tags);
-#endif
-
-  // dma the args in
-  mfc_get(&spu_args, argp, sizeof(spu_args), gc_sys_tag, 0, 0);
-  mfc_write_tag_mask(1 << gc_sys_tag); // the tag we're interested in
-  mfc_read_tag_status_all();           // wait for DMA to complete
-
-  // initialize pointer to procedure entry table
-  gc_proc_def = (gc_proc_def_t *) spu_args.proc_def_ls_addr;
-
-  gc_set_seed(spu_args.spu_idx);
-
-  // initialize logging
-  _gc_log_init(spu_args.log);
-
-  backoff_init();              // initialize backoff parameters
-
-  main_loop();
-  return 0;
-}
diff --git a/gcell/src/lib/runtime/spu/gc_random.c b/gcell/src/lib/runtime/spu/gc_random.c
deleted file mode 100644 (file)
index 618cc7e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include <gc_random.h>
-
-static int last_val = 0;
-
-#define        M  714025       // values from Numerical Recipes in C, 1988
-#define A    4096
-#define C  150889
-
-void 
-gc_set_seed(int seed)
-{
-  last_val = ((unsigned int) seed) % M;
-}
-
-float
-gc_uniform_deviate(void)
-{
-  last_val = (last_val * A + C) % M;
-  return (float) last_val / (float) M;
-}
diff --git a/gcell/src/lib/runtime/spu/gc_spu_config.h b/gcell/src/lib/runtime/spu/gc_spu_config.h
deleted file mode 100644 (file)
index 6eff710..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GC_SPU_CONFIG_H
-#define INCLUDED_GC_SPU_CONFIG_H
-
-#include <gc_job_desc.h>
-
-#define CACHE_LINE_SIZE             128              // in bytes
-#define        GC_SPU_BUFSIZE_BASE  (40 * 1024)      //  must be multiple of CACHE_LINE_SIZE
-#define        GC_SPU_BUFSIZE (GC_SPU_BUFSIZE_BASE + MAX_ARGS_EA * CACHE_LINE_SIZE)
-
-#define NGETBUFS       1       // single buffer job arg gets
-#define        NPUTBUFS        2       // double buffer job arg puts
-
-#endif /* INCLUDED_GC_SPU_CONFIG_H */
diff --git a/gcell/src/lib/runtime/spu/gc_spu_jd_queue.c b/gcell/src/lib/runtime/spu/gc_spu_jd_queue.c
deleted file mode 100644 (file)
index 6fa2d6a..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "gc_jd_queue.h"
-#include "mutex_lock.h"
-#include "mutex_unlock.h"
-#include "gc_delay.h"
-#include "gc_random.h"
-
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-
-extern int gc_sys_tag;
-
-#define        INITIAL_BACKOFF    32.0
-#define MAX_BACKOFF    16384.0
-#define        RANDOM_WEIGHT       0.2
-
-static float
-next_backoff(float backoff)
-{
-  // exponential with random
-  float t = backoff * 2.0;
-  if (t > MAX_BACKOFF)
-    t = MAX_BACKOFF;
-
-  float r = (RANDOM_WEIGHT * (2.0 * (gc_uniform_deviate() - 0.5)));
-  t = t * (1.0 + r);
-
-  return t;
-}
-
-bool
-gc_jd_queue_dequeue(gc_eaddr_t q, gc_eaddr_t *item_ea,
-                   int jd_tag, gc_job_desc_t *item)
-{
-  int  status;
-  char         _tmp[256];
-  gc_jd_queue_t *local_q =
-    (gc_jd_queue_t *) ALIGN(_tmp, 128);                // get cache-aligned buffer
-  
-  float backoff = next_backoff(INITIAL_BACKOFF);
-
-  do {
-    // Copy the queue structure in and get a lock line reservation.
-    // (The structure is 128-byte aligned and completely fills a cache-line)
-
-    mfc_getllar(local_q, q, 0, 0);
-    spu_readch(MFC_RdAtomicStat);
-
-    if (local_q->mutex != 0)           // somebody else has it locked
-      return false;
-
-    if (local_q->head == 0)            // the queue is empty
-      return false;
-
-    // Try to acquire the lock
-
-    local_q->mutex = 1;
-    mfc_putllc(local_q, q, 0, 0);
-    status = spu_readch(MFC_RdAtomicStat);
-
-    if (status != 0){
-      gc_cdelay((int) backoff);
-      backoff = next_backoff(backoff);
-    }
-
-  } while (status != 0);
-
-  // we're now holding the lock
-    
-  // copy in job descriptor at head of queue
-  *item_ea = local_q->head;
-  
-  // We must use the fence with the jd_tag to ensure that any
-  // previously initiated put of a job desc is locally ordered before
-  // the get of the new one.
-  mfc_getf(item, local_q->head, sizeof(gc_job_desc_t), jd_tag, 0, 0);
-  mfc_write_tag_mask(1 << jd_tag);     // the tag we're interested in
-  mfc_read_tag_status_all();           // wait for DMA to complete
-
-  local_q->head = item->sys.next;
-  item->sys.next = 0;
-  if (local_q->head == 0)              // now empty?
-    local_q->tail = 0;
-
-  // Copy the queue struct back out and unlock the mutex in one fell swoop.
-  // We use the unconditional put since it's faster and we own the lock.
-
-  local_q->mutex = 0;
-  mfc_putlluc(local_q, q, 0, 0);
-  spu_readch(MFC_RdAtomicStat);
-
-  return true;
-}
diff --git a/gcell/src/lib/runtime/spu/gcell_runtime_qa.c b/gcell/src/lib/runtime/spu/gcell_runtime_qa.c
deleted file mode 100644 (file)
index ac44273..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <gc_delay.h>
-#include <gc_declare_proc.h>
-#include <string.h>
-
-
-static void
-qa_nop(const gc_job_direct_args_t *input _UNUSED,
-       gc_job_direct_args_t *output _UNUSED,
-       const gc_job_ea_args_t *eaa _UNUSED)
-{
-}
-
-GC_DECLARE_PROC(qa_nop, "qa_nop");
-
-static int
-sum_shorts(short *p, int nshorts)
-{
-  int total = 0;
-  for (int i = 0; i < nshorts; i++)
-    total += p[i];
-
-  return total;
-}
-
-static void
-qa_sum_shorts(const gc_job_direct_args_t *input _UNUSED,
-             gc_job_direct_args_t *output,
-             const gc_job_ea_args_t *eaa)
-{
-  for (unsigned int i = 0; i < eaa->nargs; i++){
-    short *p = eaa->arg[i].ls_addr;
-    int n = eaa->arg[i].get_size / sizeof(short);
-    output->arg[i].s32 = sum_shorts(p, n);
-    //printf("qa_sum_shorts(%p, %d) = %d\n",  p, n, output->arg[i].s32);
-  }
-}
-
-GC_DECLARE_PROC(qa_sum_shorts, "qa_sum_shorts");
-
-static void
-write_seq(unsigned char *p, int nbytes, int counter)
-{
-  for (int i = 0; i < nbytes; i++)
-    p[i] = counter++;
-}
-
-static void
-qa_put_seq(const gc_job_direct_args_t *input,
-          gc_job_direct_args_t *output _UNUSED,
-          const gc_job_ea_args_t *eaa)
-{
-  int counter = input->arg[0].s32;
-
-  for (unsigned int i = 0; i < eaa->nargs; i++){
-    unsigned char *p = eaa->arg[i].ls_addr;
-    int n = eaa->arg[i].put_size;
-    write_seq(p, n, counter);
-    counter += n;
-  }
-}
-
-GC_DECLARE_PROC(qa_put_seq, "qa_put_seq");
-
-static void
-qa_copy(const gc_job_direct_args_t *input _UNUSED,
-       gc_job_direct_args_t *output,
-       const gc_job_ea_args_t *eaa)
-{
-  if (eaa->nargs != 2
-      || eaa->arg[0].direction != GCJD_DMA_PUT
-      || eaa->arg[1].direction != GCJD_DMA_GET){
-    output->arg[0].s32 = -1;
-    return;
-  }
-
-  output->arg[0].s32 = 0;
-  unsigned n = eaa->arg[0].put_size;
-  if (eaa->arg[1].get_size < n)
-    n = eaa->arg[1].get_size;
-  
-  memcpy(eaa->arg[0].ls_addr, eaa->arg[1].ls_addr, n);
-}
-
-GC_DECLARE_PROC(qa_copy, "qa_copy");
diff --git a/gcell/src/lib/runtime/spu/spu_buffers.c b/gcell/src/lib/runtime/spu/spu_buffers.c
deleted file mode 100644 (file)
index 58b4059..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <spu_buffers.h>
-#include <compiler.h>
-
-static unsigned char _getbuf[NGETBUFS][GC_SPU_BUFSIZE] _AL128;
-static unsigned char _putbuf[NPUTBUFS][GC_SPU_BUFSIZE] _AL128;
-
-unsigned char *_gci_getbuf[NGETBUFS] = {
-  _getbuf[0]
-};
-
-unsigned char *_gci_putbuf[NPUTBUFS] = {
-  _putbuf[0],
-  _putbuf[1]
-};
diff --git a/gcell/src/lib/runtime/spu/spu_buffers.h b/gcell/src/lib/runtime/spu/spu_buffers.h
deleted file mode 100644 (file)
index 24811dc..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_SPU_BUFFERS_H
-#define INCLUDED_SPU_BUFFERS_H
-
-#include "gc_spu_config.h"
-
-//! pointer to input buffer
-extern unsigned char *_gci_getbuf[NGETBUFS];
-
-//! pointers to output buffers
-extern unsigned char *_gci_putbuf[NPUTBUFS];
-
-#endif /* INCLUDED_SPU_BUFFERS_H */
diff --git a/gcell/src/lib/spu/Makefile.am b/gcell/src/lib/spu/Makefile.am
deleted file mode 100644 (file)
index 7c8e411..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-# We're building a single .a file from files in several
-# subdirectories.  We use the "single Makefile, multiple subdirectory"
-# automake alternative. We're doing this because we're faking out
-# automake and getting it to build for 2 architectures at the same
-# time, the PPE (powerpc64) and the SPE.  The easiest way to handle
-# the SPE was to just build a static library using automake's built in
-# rules, since trying to get libtool to handle two architectures in
-# the same tree seemed untenable.
-
-include $(top_srcdir)/Makefile.common.spu
-
-IBM_SPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/src/ibm/sync/spu_source
-AM_CPPFLAGS = $(GCELL_SPU_INCLUDES) $(IBM_SPU_SYNC_INCLUDES)
-
-lib_LIBRARIES = libgcell_spu.a
-
-# ----------------------------------------------------------------
-# files in the lib/runtime/spu directory
-
-runtime_srcdir = $(srcdir)/../runtime/spu
-
-runtime_spu_sources = \
-       $(runtime_srcdir)/gc_delay.c \
-       $(runtime_srcdir)/gc_spu_jd_queue.c \
-       $(runtime_srcdir)/spu_buffers.c \
-       $(runtime_srcdir)/gc_logging.c \
-       $(runtime_srcdir)/gc_main.c \
-       $(runtime_srcdir)/gc_random.c
-
-
-runtime_spu_headers =
-
-runtime_spu_noinst_headers = \
-       $(runtime_srcdir)/gc_spu_config.h \
-       $(runtime_srcdir)/spu_buffers.h 
-
-# ----------------------------------------------------------------
-# files in the lib/general/spu directory
-
-general_srcdir = $(srcdir)/../general/spu
-
-general_spu_sources = \
-       $(general_srcdir)/fft_1d_r2.c \
-       $(general_srcdir)/memset.S
-
-general_spu_headers = \
-       $(general_srcdir)/gc_spu_macs.h \
-       $(general_srcdir)/libfft.h
-
-general_spu_noinst_headers = \
-       $(general_srcdir)/fft_1d.h \
-       $(general_srcdir)/fft_1d_r2.h
-
-# The QA code for (usually) non-PPE visible support routines in lib/general/spu
-general_spu_qa_sources = \
-       $(general_srcdir)/qa_memset.c
-
-# ----------------------------------------------------------------
-# files in the lib/wrapper/spu directory
-
-wrapper_srcdir = $(srcdir)/../wrapper/spu
-
-wrapper_spu_sources = \
-       $(wrapper_srcdir)/gcs_fft_1d_r2.c
-
-wrapper_spu_headers =
-
-wrapper_spu_noinst_headers =
-
-# ----------------------------------------------------------------
-# build the library from the files in the three directories
-
-libgcell_spu_a_SOURCES = \
-       $(runtime_spu_sources) \
-       $(general_spu_sources) \
-       $(wrapper_spu_sources)
-
-gcellspuinclude_HEADERS = \
-       $(runtime_spu_headers) \
-       $(general_spu_headers) \
-       $(wrapper_spu_headers)
-
-noinst_HEADERS = \
-       $(runtime_spu_noinst_headers) \
-       $(general_spu_noinst_headers) \
-       $(wrapper_spu_noinst_headers)
-
-# ----------------------------------------------------------------
-# build some SPU executables
-
-noinst_PROGRAMS = \
-       gcell_all \
-       gcell_runtime_qa \
-       gcell_general_qa
-
-#
-# All known non-QA gcell procs (at least until they get too big).
-#
-gcell_all_SOURCES = $(wrapper_spu_sources)
-gcell_all_LDADD = libgcell_spu.a
-
-#
-# The QA code required for testing the runtime.
-#
-gcell_runtime_qa_SOURCES = $(runtime_srcdir)/gcell_runtime_qa.c
-gcell_runtime_qa_LDADD = libgcell_spu.a
-
-#
-# The QA code required for testing the SPE support routines in lib/general/spu
-#
-gcell_general_qa_SOURCES = $(general_spu_qa_sources)
-gcell_general_qa_LDADD = libgcell_spu.a
diff --git a/gcell/src/lib/wrapper/Makefile.am b/gcell/src/lib/wrapper/Makefile.am
deleted file mode 100644 (file)
index 8d92b7b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-include $(top_srcdir)/Makefile.common
-
-AM_CPPFLAGS = $(DEFINES) $(GCELL_INCLUDES) $(FFTW3F_CFLAGS) $(WITH_INCLUDES)
-
-noinst_LTLIBRARIES = libwrapper.la libwrapper-qa.la
-
-#
-# generate libtool.lo's that contain embedded SPU executables
-#
-gcell_all.lo: ../spu/gcell_all
-       $(GCELL_EMBEDSPU_LIBTOOL) $@ $<
-
-gcell_general_qa.lo: ../spu/gcell_general_qa
-       $(GCELL_EMBEDSPU_LIBTOOL) $@ $<
-
-
-
-# The primary library
-
-libwrapper_la_SOURCES = \
-       gcp_fft_1d_r2.cc
-
-libwrapper_la_LIBADD = \
-       gcell_all.lo
-
-
-# The QA library
-
-libwrapper_qa_la_SOURCES = \
-       qa_gcell_general.cc \
-       qa_gcell_wrapper.cc \
-       qa_gcp_fft_1d_r2.cc
-
-libwrapper_qa_la_LIBADD = \
-       gcell_general_qa.lo \
-       -lfftw3f
-
-# Headers
-
-gcellinclude_HEADERS = \
-       gcp_fft_1d_r2.h
-
-noinst_HEADERS = \
-       qa_gcell_general.h \
-       qa_gcell_wrapper.h \
-       qa_gcp_fft_1d_r2.h
-
-
-CLEANFILES = gcell_all.lo gcell_general_qa.lo
-
diff --git a/gcell/src/lib/wrapper/gcp_fft_1d_r2.cc b/gcell/src/lib/wrapper/gcp_fft_1d_r2.cc
deleted file mode 100644 (file)
index 07267e3..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <gcp_fft_1d_r2.h>
-#include <stdint.h>
-#include <stdexcept>
-#include <math.h>
-
-static void
-init_jd(gc_job_desc *jd,
-       gc_proc_id_t proc_id,
-       unsigned log2_fft_length,
-       bool shift,
-       std::complex<float> *out,
-       const std::complex<float> *in,
-       const std::complex<float> *twiddle,
-       const float *window)
-{
-  jd->proc_id = proc_id;
-  jd->input.nargs = 2;
-  jd->output.nargs = 0;
-  jd->eaa.nargs = 4;
-
-  jd->input.arg[0].u32 = log2_fft_length;
-  jd->input.arg[1].u32 = shift;
-  unsigned int fft_length = 1 << log2_fft_length;
-
-  jd->eaa.arg[0].ea_addr = ptr_to_ea(out);
-  jd->eaa.arg[0].direction = GCJD_DMA_PUT;
-  jd->eaa.arg[0].put_size = sizeof(std::complex<float>) * fft_length;
-
-  jd->eaa.arg[1].ea_addr = ptr_to_ea(const_cast<std::complex<float>*>(in));
-  jd->eaa.arg[1].direction = GCJD_DMA_GET;
-  jd->eaa.arg[1].get_size = sizeof(std::complex<float>) * fft_length;
-
-  jd->eaa.arg[2].ea_addr = ptr_to_ea(const_cast<std::complex<float>*>(twiddle));
-  jd->eaa.arg[2].direction = GCJD_DMA_GET;
-  jd->eaa.arg[2].get_size = sizeof(std::complex<float>) * fft_length / 4;
-
-  jd->eaa.arg[3].ea_addr = ptr_to_ea(const_cast<float*>(window));
-  jd->eaa.arg[3].direction = GCJD_DMA_GET;
-  if (window == 0)
-    jd->eaa.arg[3].get_size = 0;
-  else
-    jd->eaa.arg[3].get_size = sizeof(float) * fft_length;
-}
-
-  
-gc_job_desc_sptr
-gcp_fft_1d_r2_submit(gc_job_manager_sptr mgr,
-                    unsigned int log2_fft_length,
-                    bool forward,
-                    bool shift,
-                    std::complex<float> *out,
-                    const std::complex<float> *in,
-                    const std::complex<float> *twiddle,
-                    const float *window)
-{
-  unsigned int fft_length = 1 << log2_fft_length;
-  if (fft_length > 4096)
-    throw std::invalid_argument("fft_length > 4096");
-
-  if ((intptr_t)out & 0xf)
-    throw gc_bad_align("out");
-  if ((intptr_t)in & 0xf)
-    throw gc_bad_align("in");
-  if ((intptr_t)twiddle & 0xf)
-    throw gc_bad_align("twiddle");
-  if ((intptr_t)window & 0xf)
-    throw gc_bad_align("window");
-
-  std::string proc_name;
-  if (forward)
-    proc_name = "fwd_fft_1d_r2";
-  else
-    proc_name = "inv_fft_1d_r2";
-
-  gc_proc_id_t fft_id = mgr->lookup_proc(proc_name);
-  gc_job_desc_sptr jd = gc_job_manager::alloc_job_desc(mgr);
-  init_jd(jd.get(), fft_id, log2_fft_length, shift, out, in, twiddle, window);
-  if (!mgr->submit_job(jd.get())){
-    gc_job_status_t s = jd->status;
-    throw gc_bad_submit(proc_name, s);
-  }
-  return jd;
-}
-
-void
-gcp_fft_1d_r2_twiddle(unsigned int log2_fft_length, std::complex<float> *twiddle)
-{
-  unsigned int n = 1 << log2_fft_length;
-
-  twiddle[0].real() = 1.0;
-  twiddle[0].imag() = 0.0;
-  for (unsigned i=1; i < n/4; i++){
-    twiddle[i].real() =  cos(i * 2*M_PI/n);
-    twiddle[n/4 - i].imag() = -twiddle[i].real();
-  }
-}
diff --git a/gcell/src/lib/wrapper/gcp_fft_1d_r2.h b/gcell/src/lib/wrapper/gcp_fft_1d_r2.h
deleted file mode 100644 (file)
index 1207a5f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_GCP_FFT_1D_R2_H
-#define INCLUDED_GCP_FFT_1D_R2_H
-
-#include <gc_job_manager.h>
-#include <complex>
-
-/*!
- * \brief Submit a job that computes the forward or inverse FFT.
- *
- * \param mgr is the job manager instance
- * \param log2_fft_length is the log2 of the fft_length (4 <= x <= 12).
- * \param forward is true to compute the forward transform, else the inverse.
- * \param shift indicates if an "fftshift" should be applied to the output data
- * \param out is the fft_length output from FFT (must be 16-byte aligned).
- * \param in is the fft_length input to FFT (must be 16-byte aligned).
- * \param twiddle is fft_length/4 twiddle factor input to FFT (must be 16-byte aligned).
- * \param window is the window to be applied to the input data.
- *    The window length must be either 0 or fft_length (must be 16-byte aligned).
- *
- * Returns a shared_ptr to a job descriptor which should be passed to wait_job*.
- * Throws an exception in the event of a problem.
- * This uses the FFTW conventions for scaling.  That is, neither the forward nor inverse
- * are scaled by 1/fft_length.
- */
-gc_job_desc_sptr
-gcp_fft_1d_r2_submit(gc_job_manager_sptr mgr,
-                    unsigned int log2_fft_length,
-                    bool forward,
-                    bool shift,
-                    std::complex<float> *out,
-                    const std::complex<float> *in,
-                    const std::complex<float> *twiddle,
-                    const float *window);
-
-/*!
- * \brief Compute twiddle factors 
- *
- * \param log2_fft_length is the log2 of the fft_length.
- * \param W is fft_length/4 twiddle factor output (must be 16-byte aligned).
- */
-void
-gcp_fft_1d_r2_twiddle(unsigned int log2_fft_length, std::complex<float> *W);
-
-#endif /* INCLUDED_GCP_FFT_1D_R2_H */
diff --git a/gcell/src/lib/wrapper/qa_gcell_general.cc b/gcell/src/lib/wrapper/qa_gcell_general.cc
deleted file mode 100644 (file)
index de48201..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "qa_gcell_general.h"
-#include <cppunit/TestAssert.h>
-
-#include <stdio.h>
-#include <stdlib.h>    // random, posix_memalign
-#include <algorithm>
-#include <string.h>
-#include <gc_job_manager.h>
-
-
-// handle to embedded SPU executable
-extern spe_program_handle_t gcell_general_qa;
-
-gc_job_desc_sptr
-gcp_qa_general_submit(gc_job_manager_sptr mgr, const std::string &proc_name)
-{
-  gc_proc_id_t proc_id = mgr->lookup_proc(proc_name);
-  gc_job_desc_sptr jd = gc_job_manager::alloc_job_desc(mgr);
-
-  jd->proc_id = proc_id;
-  jd->input.nargs = 0;
-  jd->output.nargs = 1;
-  jd->eaa.nargs = 0;
-
-  if (!mgr->submit_job(jd.get())){
-    gc_job_status_t s = jd->status;
-    throw gc_bad_submit(proc_name, s);
-  }
-  return jd;
-}
-
-
-bool
-qa_gcell_general::generic_test_body(const std::string &proc_name)
-{
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_general_qa);
-  opts.nspes = 1;
-  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
-
-  gc_job_desc_sptr jd = gcp_qa_general_submit(mgr, proc_name);
-  if (!mgr->wait_job(jd.get())){
-    fprintf(stderr, "wait_job for %s failed: %s\n",
-           proc_name.c_str(),
-           gc_job_status_string(jd->status).c_str());
-    CPPUNIT_ASSERT(0);
-  }
-
-  return jd->output.arg[0].u32;                // bool result from SPE code
-}
-
-/*
- * ------------------------------------------------------------------------
- *                 Add more calls to SPE QA code here...
- * ------------------------------------------------------------------------
- */
-void
-qa_gcell_general::test_memset()
-{
-  CPPUNIT_ASSERT(generic_test_body("qa_memset"));
-}
-
diff --git a/gcell/src/lib/wrapper/qa_gcell_general.h b/gcell/src/lib/wrapper/qa_gcell_general.h
deleted file mode 100644 (file)
index f1e64e7..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef INCLUDED_QA_GCELL_GENERAL_H
-#define INCLUDED_QA_GCELL_GENERAL_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_gcell_general : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_gcell_general);
-  CPPUNIT_TEST(test_memset);
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-  void test_memset();
-
-  bool generic_test_body(const std::string &proc_name);
-};
-
-#endif /* INCLUDED_QA_GCELL_GENERAL_H */
diff --git a/gcell/src/lib/wrapper/qa_gcell_wrapper.cc b/gcell/src/lib/wrapper/qa_gcell_wrapper.cc
deleted file mode 100644 (file)
index d53c610..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/*
- * This class gathers together all the test cases for the lib/wrapper
- * directory into a single test suite.  As you create new test cases,
- * add them here.
- */
-
-#include <qa_gcell_wrapper.h>
-#include <qa_gcell_general.h>
-#include <qa_gcp_fft_1d_r2.h>
-
-CppUnit::TestSuite *
-qa_gcell_wrapper::suite()
-{
-  CppUnit::TestSuite   *s = new CppUnit::TestSuite("wrapper");
-
-  s->addTest(qa_gcell_general::suite());
-  s->addTest(qa_gcp_fft_1d_r2::suite());
-
-  return s;
-}
diff --git a/gcell/src/lib/wrapper/qa_gcell_wrapper.h b/gcell/src/lib/wrapper/qa_gcell_wrapper.h
deleted file mode 100644 (file)
index cb29db8..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_QA_GCELL_WRAPPER_H
-#define INCLUDED_QA_GCELL_WRAPPER_H
-
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for the wrapper directory
-
-class qa_gcell_wrapper {
-public:
-  //! return suite of tests
-  static CppUnit::TestSuite *suite();
-};
-
-
-#endif /* INCLUDED_QA_GCELL_WRAPPER_H */
diff --git a/gcell/src/lib/wrapper/qa_gcp_fft_1d_r2.cc b/gcell/src/lib/wrapper/qa_gcp_fft_1d_r2.cc
deleted file mode 100644 (file)
index dbbe05f..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "qa_gcp_fft_1d_r2.h"
-#include <cppunit/TestAssert.h>
-#include <gcp_fft_1d_r2.h>
-#include <fftw3.h>
-#include <stdio.h>
-#include <stdlib.h>    // random, posix_memalign
-#include <algorithm>
-#include <string.h>
-
-typedef boost::shared_ptr<void> void_sptr;
-
-// handle to embedded SPU executable
-extern spe_program_handle_t gcell_all;
-
-/*
- * Return pointer to cache-aligned chunk of storage of size size bytes.
- * Throw if can't allocate memory.  The storage should be freed
- * with "free" when done.  The memory is initialized to zero.
- */
-static void *
-aligned_alloc(size_t size, size_t alignment = 128)
-{
-  void *p = 0;
-  if (posix_memalign(&p, alignment, size) != 0){
-    perror("posix_memalign");
-    throw std::runtime_error("memory");
-  }
-  memset(p, 0, size);          // zero the memory
-  return p;
-}
-
-class free_deleter {
-public:
-  void operator()(void *p) {
-    free(p);
-  }
-};
-
-static boost::shared_ptr<void>
-aligned_alloc_sptr(size_t size, size_t alignment = 128)
-{
-  return boost::shared_ptr<void>(aligned_alloc(size, alignment), free_deleter());
-}
-
-// test forward FFT
-void
-qa_gcp_fft_1d_r2::t1()
-{
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_all);
-  opts.nspes = 1;
-  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
-
-#if 1
-  for (int log2_fft_size = 5; log2_fft_size <= 12; log2_fft_size++){
-    test(mgr, log2_fft_size, true);
-  }
-#else
-  test(mgr, 5, true);
-#endif
-}
-
-// test inverse FFT
-void
-qa_gcp_fft_1d_r2::t2()
-{
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_all);
-  opts.nspes = 1;
-  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
-
-#if 1
-  for (int log2_fft_size = 5; log2_fft_size <= 12; log2_fft_size++){
-    test(mgr, log2_fft_size, false);
-  }
-#else
-  test(mgr, 5, false);
-#endif
-}
-
-void
-qa_gcp_fft_1d_r2::t3()
-{
-  // FIXME Test fwd and inv with windowing option
-}
-
-void
-qa_gcp_fft_1d_r2::t4()
-{
-  // FIXME Test fwd and inv with shift option
-}
-
-static inline float
-abs_diff(std::complex<float> x, std::complex<float> y)
-{
-  return std::max(std::abs(x.real()-y.real()),
-                 std::abs(x.imag()-y.imag()));
-}
-
-static float
-float_abs_rel_error(float ref, float actual)
-{
-  float delta = ref - actual;
-  if (std::abs(ref) < 1e-18)
-    ref = 1e-18;
-  return std::abs(delta/ref);
-}
-
-static float
-abs_rel_error(std::complex<float> ref, std::complex<float> actual)
-{
-  return std::max(float_abs_rel_error(ref.real(), actual.real()),
-                 float_abs_rel_error(ref.imag(), actual.imag()));
-}
-
-void 
-qa_gcp_fft_1d_r2::test(gc_job_manager_sptr mgr, int log2_fft_size, bool forward)
-{
-  int fft_size = 1 << log2_fft_size;
-
-  // allocate aligned buffers with boost shared_ptr's
-  void_sptr fftw_in_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
-  void_sptr fftw_out_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
-  void_sptr cell_in_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
-  void_sptr cell_out_void = aligned_alloc_sptr(fft_size * sizeof(std::complex<float>), 128);
-  void_sptr cell_twiddle_void = aligned_alloc_sptr(fft_size/4 * sizeof(std::complex<float>), 128);
-
-  // cast them to the type we really want
-  std::complex<float> *fftw_in = (std::complex<float> *) fftw_in_void.get();
-  std::complex<float> *fftw_out = (std::complex<float> *) fftw_out_void.get();
-  std::complex<float> *cell_in = (std::complex<float> *) cell_in_void.get();
-  std::complex<float> *cell_out = (std::complex<float> *) cell_out_void.get();
-  std::complex<float> *cell_twiddle = (std::complex<float> *) cell_twiddle_void.get();
-
-  gcp_fft_1d_r2_twiddle(log2_fft_size, cell_twiddle);
-
-  srandom(1);          // we want reproducibility
-
-  // initialize the input buffers
-  for (int i = 0; i < fft_size; i++){
-    std::complex<float> t((float) (random() & 0xfffff), (float) (random() & 0xfffff));
-    fftw_in[i] = t;
-    cell_in[i] = t;
-  }
-
-  // ------------------------------------------------------------------------
-  // compute the reference answer
-  fftwf_plan plan = fftwf_plan_dft_1d (fft_size,
-                                      reinterpret_cast<fftwf_complex *>(fftw_in), 
-                                      reinterpret_cast<fftwf_complex *>(fftw_out),
-                                      forward ? FFTW_FORWARD : FFTW_BACKWARD,
-                                      FFTW_ESTIMATE);
-  if (plan == 0){
-    fprintf(stderr, "qa_gcp_fft_1d_r2: error creating FFTW plan\n");
-    throw std::runtime_error ("fftwf_plan_dft_r2c_1d failed");
-  }
-  
-  fftwf_execute(plan);
-  fftwf_destroy_plan(plan);
-
-  // ------------------------------------------------------------------------
-  // compute the answer on the cell
-  gc_job_desc_sptr jd = gcp_fft_1d_r2_submit(mgr, log2_fft_size, forward, false,
-                                            cell_out, cell_in, cell_twiddle, 0);
-  if (!mgr->wait_job(jd.get())){
-    fprintf(stderr, "wait_job failed: %s\n", gc_job_status_string(jd->status).c_str());
-    CPPUNIT_ASSERT(0);
-  }
-
-  // ------------------------------------------------------------------------
-  // compute the maximum of the relative error
-  float max_rel = 0.0;
-  for (int i = 0; i < fft_size; i++){
-    max_rel = std::max(max_rel, abs_rel_error(fftw_out[i], cell_out[i]));
-    if (0)
-      printf("(%16.3f, %16.3fj)  (%16.3f, %16.3fj)  (%16.3f, %16.3fj)\n",
-            fftw_out[i].real(), fftw_out[i].imag(),
-            cell_out[i].real(), cell_out[i].imag(),
-            fftw_out[i].real() - cell_out[i].real(),
-            fftw_out[i].imag() - cell_out[i].imag());
-  }
-
-  fprintf(stdout, "%s fft_size = %4d  max_rel_error = %e\n",
-         forward ? "fwd" : "rev", fft_size, max_rel);
-
-  CPPUNIT_ASSERT(max_rel <= 5e-3);
-}
diff --git a/gcell/src/lib/wrapper/qa_gcp_fft_1d_r2.h b/gcell/src/lib/wrapper/qa_gcp_fft_1d_r2.h
deleted file mode 100644 (file)
index 38beafb..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#ifndef INCLUDED_QA_GCP_FFT_1D_R2_H
-#define INCLUDED_QA_GCP_FFT_1D_R2_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-#include <gc_job_manager.h>
-
-class qa_gcp_fft_1d_r2 : public CppUnit::TestCase {
-
-  CPPUNIT_TEST_SUITE(qa_gcp_fft_1d_r2);
-  CPPUNIT_TEST(t1);
-  CPPUNIT_TEST(t2);
-  CPPUNIT_TEST(t3);
-  CPPUNIT_TEST(t4);
-  CPPUNIT_TEST_SUITE_END();
-
- private:
-  void t1();
-  void t2();
-  void t3();
-  void t4();
-
-  void test(gc_job_manager_sptr mgr, int log2_fft_size, bool forward);
-};
-
-
-
-#endif /* INCLUDED_QA_GCP_FFT_1D_R2_H */
diff --git a/gcell/src/lib/wrapper/spu/gcs_fft_1d_r2.c b/gcell/src/lib/wrapper/spu/gcs_fft_1d_r2.c
deleted file mode 100644 (file)
index 81e5dfd..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- * 
- * This file is part of GNU Radio
- * 
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- * 
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <gc_declare_proc.h>
-#include <libfft.h>
-#include <assert.h>
-
-/*
- * v is really vector complex<float>
- */
-static void
-conjugate_vector(vector float *v, int nelements)
-{
-  vector float k = {1, -1, 1, -1};
-  int i;
-  for (i = 0; i < nelements; i++)
-    v[i] *= k;
-}
-
-static void
-gcs_fwd_fft_1d_r2(const gc_job_direct_args_t *input,
-                 gc_job_direct_args_t *output __attribute__((unused)),
-                 const gc_job_ea_args_t *eaa)
-{
-  vector float *out = (vector float *) eaa->arg[0].ls_addr;    // complex
-  vector float *in = (vector float *) eaa->arg[1].ls_addr;     // complex
-  vector float *twiddle = (vector float *) eaa->arg[2].ls_addr;        // complex
-  vector float *window = (vector float *) eaa->arg[3].ls_addr; // float
-
-  int log2_fft_length = input->arg[0].u32;
-  int shift = input->arg[1].u32;       // non-zero if we should apply fftshift
-
-  if (eaa->arg[3].get_size){   // apply window
-    // FIXME pointwise multiply in *= window
-    assert(0);
-  }
-
-  fft_1d_r2(out, in, twiddle, log2_fft_length);
-
-  if (shift){
-    // FIXME apply "fftshift" to output data in-place
-    assert(0);
-  }
-}
-
-GC_DECLARE_PROC(gcs_fwd_fft_1d_r2, "fwd_fft_1d_r2");
-
-static void
-gcs_inv_fft_1d_r2(const gc_job_direct_args_t *input,
-                 gc_job_direct_args_t *output __attribute__((unused)),
-                 const gc_job_ea_args_t *eaa)
-{
-  vector float *out = (vector float *) eaa->arg[0].ls_addr;    // complex
-  vector float *in = (vector float *) eaa->arg[1].ls_addr;     // complex
-  vector float *twiddle = (vector float *) eaa->arg[2].ls_addr;        // complex
-  vector float *window = (vector float *) eaa->arg[3].ls_addr; // float
-
-  int log2_fft_length = input->arg[0].u32;
-  int shift = input->arg[1].u32;       // non-zero if we should apply fftshift
-
-  if (eaa->arg[3].get_size){   // apply window
-    // FIXME pointwise multiply in *= window
-    assert(0);
-  }
-
-  if (shift){
-    // FIXME apply "fftshift" to input data in-place
-    assert(0);
-  }
-
-  conjugate_vector(in, 1 << (log2_fft_length - 1));
-  fft_1d_r2(out, in, twiddle, log2_fft_length);
-  conjugate_vector(out, 1 << (log2_fft_length - 1));
-}
-
-GC_DECLARE_PROC(gcs_inv_fft_1d_r2, "inv_fft_1d_r2");
index 23f602895769c46c5b33f3bcad1d543dd9c2a465..cbe7abcc7709ac0efe2f306276c45e2e8dc6d4f4 100644 (file)
@@ -28,7 +28,7 @@
 #include "gnuradio_swig_bug_workaround.h"      // mandatory bug fix
 //#include <stdexcept>
 
-#include <gc_job_manager.h>
+#include <gcell/gc_job_manager.h>
 #include <gcell_fft_vcc.h>  
 
 %}
index b53f0c330a896047aa2d4fac657e1daec8c38b83..8bbcfb2b9e8b10b549352b4ac2860928c7d6253b 100644 (file)
@@ -26,9 +26,9 @@
 
 #include <gcell_fft_vcc.h>
 #include <gr_io_signature.h>
-#include <gc_job_manager.h>
-#include <gc_aligned_alloc.h>
-#include <gcp_fft_1d_r2.h>
+#include <gcell/gc_job_manager.h>
+#include <gcell/gc_aligned_alloc.h>
+#include <gcell/gcp_fft_1d_r2.h>
 #include <math.h>
 #include <assert.h>
 #include <stdexcept>
index d95b76c4cf4709477b754db367686e07c0465a07..88a4f520703126e311d67984cd5ecba44aaa8a5d 100755 (executable)
@@ -33,7 +33,7 @@ primes = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,
 class test_fft_filter(gr_unittest.TestCase):
 
     def setUp(self):
-        ph = gcell.program_handle_from_filename("../../gcell/src/lib/spu/gcell_all")
+        ph = gcell.program_handle_from_filename("../../gcell/lib/spu/gcell_all")
         opts = gcell.jm_options(ph, 1)
         self.mgr = gcell.job_manager(opts)
         gcell.set_singleton(self.mgr)