From assem at codesourcery.com Thu Jul 6 16:30:30 2006 From: assem at codesourcery.com (Assem Salama) Date: Thu, 06 Jul 2006 12:30:30 -0400 Subject: Matlab IO Message-ID: <44AD3AA6.1070708@codesourcery.com> Everyone, New Matlab IO patch with Jule's suggestions. Thanks, Assem -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: cvs.diff.07062006.1.log URL: From jules at codesourcery.com Thu Jul 6 21:16:35 2006 From: jules at codesourcery.com (Jules Bergmann) Date: Thu, 06 Jul 2006 17:16:35 -0400 Subject: [vsipl++] Matlab IO In-Reply-To: <44AD3AA6.1070708@codesourcery.com> References: <44AD3AA6.1070708@codesourcery.com> Message-ID: <44AD7DB3.7070306@codesourcery.com> Assem, I have 8 comments below. -- Jules > + template > + struct view_header > + { > + data_element header; > + data_element array_flags_header; > + uint32_t array_flags[2]; > + data_element dim_header; > + uint32_t dim[Dim + Dim%2]; //the dim has to be aligned to an 8 byte boundary [1] Can you make sure this comment fits into 80-columns? > + data_element array_name_header; > + }; > + // the read function for real or complex depending of the view that was > + // passed in > + template + typename ViewT> > + void read(std::istream& is,ViewT v,bool swap_bytes) > + { > + vsip::dimension_type const View_dim = ViewT::dim; > + vsip::Index my_index; > + vsip::impl::Length v_extent = extent(v); > + T1 data; > + typedef typename ViewT::value_type scalar_type; > + > + // get num_points > + vsip::length_type num_points = v.size(); > + > + // read all the points > + for(vsip::index_type i=0;i + is.read(reinterpret_cast(&data),sizeof(data)); > + swap(&data,swap_bytes); [2] The intent of the wrapper template function 'swap' is to let the compiler infer template parameters automatically. Since 'data' is of type 'T1', you can just say: swap(&data, swap_bytes); Unless the inferred type would be incorrect, can you remove the explicit parameter? > + > +// operator to read view from matlab file > +template + typename Block0, > + template class View> > +inline > +std::istream& > +operator>>( > + std::istream& is, > + Matlab_bin_formatter > mbf) > +{ > + matlab::data_element temp_data_element; > + matlab::view_header::dim> m_view; > + typedef typename vsip::impl::Scalar_of::type scalar_type; > + typedef matlab::Subview_helper > subview; > + typedef typename subview::realview_type r_v; > + typedef typename subview::imagview_type i_v; > + vsip::dimension_type v_dim = vsip::impl::Dim_of_view::dim; > + > + > + // read header > + is.read(reinterpret_cast(&m_view),sizeof(m_view)); > + [3] When does mbf.header.endian get initialized? Have you written a unit test for these routines? (If not, please do that next). > + // do we need to swap fields? > + matlab::swap_header(m_view,mbf.header.endian); [4] The second arg to swap_header is a bool indicating if bytes should be swapped. Passing mbf.header.endian (a uint16_t) will nearly always be true (unless the matlab file is corrupted). Can you do something like: bool swap_bytes; if (mbf.header.endian == 'M' << 8 | 'I') swap_bytes = false; else if (mbf.header.endian == 'I' << 8 | 'M') swap_bytes = true; else VSIP_IMPL_THROW(std::runtime_error( "Matlab file header has invalid endian field")); matlab::swap_header(m_view, swap_bytes); > + > + // is this complex? > + if(vsip::impl::Is_complex::value && !(m_view.array_flags[0]&(1<<11))) > + VSIP_IMPL_THROW(std::runtime_error( > + "Trying to read complex matrix into a real matrix")); [5] Please change this to "Trying to read a complex view into a real view" > + > + > + // is this the same class? > + if(!((m_view.array_flags[0] & 0xff) == > + (matlab::Matlab_header_traits + std::numeric_limits::is_signed, > + std::numeric_limits::is_integer>::class_type) > + )) > + VSIP_IMPL_THROW(std::runtime_error( > + "Trying to read a matrix of a different class")); [6] Please change this to "Trying to read a view with different class of value type" > + > + // do dimensions agree? > + if(v_dim == 1) m_view.dim_header.size -= 4; // special case for vectors > + if(v_dim != (m_view.dim_header.size/4)) > + VSIP_IMPL_THROW(std::runtime_error( > + "Trying to read a matrix of different dimensions")); [7] Please change this to "Trying to read a view with different dimension" > + > + for(vsip::dimension_type i=0;i + if(mbf.view.size(i) != m_view.dim[i]) > + VSIP_IMPL_THROW(std::runtime_error( > + "Matrix dimensions don't agree")); [8] Please change this to "View dimensions don't agree" -- Jules Bergmann CodeSourcery jules at codesourcery.com (650) 331-3385 x705 From assem at codesourcery.com Fri Jul 7 04:18:47 2006 From: assem at codesourcery.com (Assem Salama) Date: Fri, 07 Jul 2006 00:18:47 -0400 Subject: Matlab IO Message-ID: <44ADE0A7.5090008@codesourcery.com> Everyone, New patch with Jule's suggestions. Assem -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: cvs.diff.07062006.2.log URL: From assem at codesourcery.com Fri Jul 7 04:20:46 2006 From: assem at codesourcery.com (Assem Salama) Date: Fri, 07 Jul 2006 00:20:46 -0400 Subject: [vsipl++] Matlab IO In-Reply-To: <44AD7DB3.7070306@codesourcery.com> References: <44AD3AA6.1070708@codesourcery.com> <44AD7DB3.7070306@codesourcery.com> Message-ID: <44ADE11E.9020107@codesourcery.com> Jules Bergmann wrote: > Assem, I have 8 comments below. -- Jules > > > + template > > + struct view_header > > + { > > + data_element header; > > + data_element array_flags_header; > > + uint32_t array_flags[2]; > > + data_element dim_header; > > + uint32_t dim[Dim + Dim%2]; //the dim has to be aligned to an 8 > byte boundary > > [1] Can you make sure this comment fits into 80-columns? Yes it is. > > > + data_element array_name_header; > > + }; > > > + // the read function for real or complex depending of the view > that was > > + // passed in > > + template > + typename ViewT> > > + void read(std::istream& is,ViewT v,bool swap_bytes) > > + { > > + vsip::dimension_type const View_dim = ViewT::dim; > > + vsip::Index my_index; > > + vsip::impl::Length v_extent = extent(v); > > + T1 data; > > + typedef typename ViewT::value_type scalar_type; > > + > > + // get num_points > > + vsip::length_type num_points = v.size(); > > + > > + // read all the points > > + for(vsip::index_type i=0;i > + is.read(reinterpret_cast(&data),sizeof(data)); > > + swap(&data,swap_bytes); > > [2] The intent of the wrapper template function 'swap' is to let the > compiler infer template parameters automatically. Since 'data' is of > type 'T1', you can just say: > > swap(&data, swap_bytes); > > Unless the inferred type would be incorrect, can you remove the > explicit parameter? > > > > + > > +// operator to read view from matlab file > > +template > + typename Block0, > > + template class View> > > +inline > > +std::istream& > > +operator>>( > > + std::istream& is, > > + Matlab_bin_formatter > mbf) > > +{ > > + matlab::data_element temp_data_element; > > + matlab::view_header::dim> m_view; > > + typedef typename vsip::impl::Scalar_of::type scalar_type; > > + typedef matlab::Subview_helper > subview; > > + typedef typename subview::realview_type r_v; > > + typedef typename subview::imagview_type i_v; > > + vsip::dimension_type v_dim = vsip::impl::Dim_of_view::dim; > > + > > + > > + // read header > > + is.read(reinterpret_cast(&m_view),sizeof(m_view)); > > + > > [3] When does mbf.header.endian get initialized? Have you written a > unit test for these routines? (If not, please do that next). > mbf.header gets initialized in the constructor. I have a test that writes and read vectors,matrices,and tensors. > > > + // do we need to swap fields? > > + matlab::swap_header(m_view,mbf.header.endian); > > [4] The second arg to swap_header is a bool indicating if bytes should > be swapped. Passing mbf.header.endian (a uint16_t) will nearly always > be true (unless the matlab file is corrupted). Can you do something > like: > > bool swap_bytes; > > if (mbf.header.endian == 'M' << 8 | 'I') swap_bytes = false; > else if (mbf.header.endian == 'I' << 8 | 'M') swap_bytes = true; > else > VSIP_IMPL_THROW(std::runtime_error( > "Matlab file header has invalid endian field")); > > matlab::swap_header(m_view, swap_bytes); > > > > + > > + // is this complex? > > + if(vsip::impl::Is_complex::value && > !(m_view.array_flags[0]&(1<<11))) > > + VSIP_IMPL_THROW(std::runtime_error( > > + "Trying to read complex matrix into a real matrix")); > > [5] Please change this to "Trying to read a complex view into a real > view" > > > + > > + > > + // is this the same class? > > + if(!((m_view.array_flags[0] & 0xff) == > > + (matlab::Matlab_header_traits > + std::numeric_limits::is_signed, > > + std::numeric_limits::is_integer>::class_type) > > + )) > > + VSIP_IMPL_THROW(std::runtime_error( > > + "Trying to read a matrix of a different class")); > > [6] Please change this to "Trying to read a view with different class > of value type" > > > + > > + // do dimensions agree? > > + if(v_dim == 1) m_view.dim_header.size -= 4; // special case for > vectors > > + if(v_dim != (m_view.dim_header.size/4)) > > + VSIP_IMPL_THROW(std::runtime_error( > > + "Trying to read a matrix of different dimensions")); > > [7] Please change this to "Trying to read a view with different > dimension" > > > + > > + for(vsip::dimension_type i=0;i > + if(mbf.view.size(i) != m_view.dim[i]) > > + VSIP_IMPL_THROW(std::runtime_error( > > + "Matrix dimensions don't agree")); > > [8] Please change this to "View dimensions don't agree" > > From assem at codesourcery.com Fri Jul 7 04:22:14 2006 From: assem at codesourcery.com (Assem Salama) Date: Fri, 07 Jul 2006 00:22:14 -0400 Subject: Matlab IO Message-ID: <44ADE176.2030702@codesourcery.com> Everyone, Sorry I missed a change in the last patch. This one has it. Assem -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: cvs.diff.07062006.2.log URL: From jules at codesourcery.com Fri Jul 7 16:22:53 2006 From: jules at codesourcery.com (Jules Bergmann) Date: Fri, 07 Jul 2006 12:22:53 -0400 Subject: [vsipl++] Matlab IO In-Reply-To: <44ADE176.2030702@codesourcery.com> References: <44ADE176.2030702@codesourcery.com> Message-ID: <44AE8A5D.8060902@codesourcery.com> Assem Salama wrote: > Everyone, > Sorry I missed a change in the last patch. This one has it. Assem, This looks good, please check it in. thanks! -- Jules -- Jules Bergmann CodeSourcery jules at codesourcery.com (650) 331-3385 x705 From don at codesourcery.com Fri Jul 7 22:01:37 2006 From: don at codesourcery.com (Don McCoy) Date: Fri, 07 Jul 2006 16:01:37 -0600 Subject: [vsipl++] [patch] Benchmarks update In-Reply-To: <44999567.2040902@codesourcery.com> References: <4493531F.5080605@codesourcery.com> <44999567.2040902@codesourcery.com> Message-ID: <44AED9C1.40401@codesourcery.com> Jules Bergmann wrote: > Don, This looks good. Please check it in. -- Jules > > Don McCoy wrote: >> The attached patch fixes one bug (in firbank.cpp) and cleans up the >> makefiles used to build the benchmarks. ... Just a note that this patch has now been committed. Regards, -- Don McCoy don (at) CodeSourcery (888) 776-0262 / (650) 331-3385, x712 From don at codesourcery.com Sat Jul 8 00:01:24 2006 From: don at codesourcery.com (Don McCoy) Date: Fri, 07 Jul 2006 18:01:24 -0600 Subject: [patch] Built-in function profiling Message-ID: <44AEF5D4.5020805@codesourcery.com> This is the first of a series of patches to add built-in profiling capability to VSIPL++. For this initial version, only the FFT, Convolution and Correlation objects have been modified. An example of how to use the profiling features is included in the examples/fft.cpp directory. In brief, it shows the exact type of operation performed, the total amount of time spent (even over multiple calls), the number of times called, the operation count per call and finally, the (calculated) rate of operations (in MFLOPS). Full documentation will be provided in an upcoming patch. Regards, -- Don McCoy don (at) CodeSourcery (888) 776-0262 / (650) 331-3385, x712 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pf1.changes URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pf1.diff URL: From assem at codesourcery.com Sun Jul 9 17:33:57 2006 From: assem at codesourcery.com (Assem Salama) Date: Sun, 09 Jul 2006 13:33:57 -0400 Subject: [vsipl++] Matlab IO In-Reply-To: <44AE8A5D.8060902@codesourcery.com> References: <44ADE176.2030702@codesourcery.com> <44AE8A5D.8060902@codesourcery.com> Message-ID: <44B13E05.9010601@codesourcery.com> Jules, Should I check this in using svn? Thanks, Assem Jules Bergmann wrote: > Assem Salama wrote: >> Everyone, >> Sorry I missed a change in the last patch. This one has it. > > Assem, This looks good, please check it in. thanks! -- Jules > > > From jules at codesourcery.com Mon Jul 10 14:31:02 2006 From: jules at codesourcery.com (Jules Bergmann) Date: Mon, 10 Jul 2006 10:31:02 -0400 Subject: [vsipl++] [patch] Built-in function profiling In-Reply-To: <44AEF5D4.5020805@codesourcery.com> References: <44AEF5D4.5020805@codesourcery.com> Message-ID: <44B264A6.6090302@codesourcery.com> Don McCoy wrote: > This is the first of a series of patches to add built-in profiling > capability to VSIPL++. For this initial version, only the FFT, > Convolution and Correlation objects have been modified. > > An example of how to use the profiling features is included in the > examples/fft.cpp directory. In brief, it shows the exact type of > operation performed, the total amount of time spent (even over multiple > calls), the number of times called, the operation count per call and > finally, the (calculated) rate of operations (in MFLOPS). Full > documentation will be provided in an upcoming patch. Don, this looks good. I have several comments below. Can you please address #1 and #3-#5 before checking in? We can address #2 later. thanks -- Jules > @@ -171,6 +179,7 @@ > Profiler::dump(char* filename, char /*mode*/) > { > std::ofstream file; > + const char delim[] = " : "; While the spaces improve the human readability, they are more difficult to post-process in a languages like perl and python (although the extra difficulty is pretty minor). Let's leave the space in, but in general we should "error" on the side of easier post-processing rather than readability since the profiling output will have a lot of raw information that will be difficult to digest without some reduction. > > file.open(filename); > > @@ -179,16 +188,20 @@ > file << "# mode: pm_trace" << std::endl; > file << "# timer: " << TP::name() << std::endl; > file << "# clocks_per_sec: " << TP::ticks(TP::clocks_per_sec) << std::endl; > + file << "# " << std::endl; > + file << "# index" << delim << "tag" << delim << "ticks" << delim << "open id" > + << delim << "op count" << std::endl; > > for (iterator cur = accum_.begin(); cur != accum_.end(); ++cur) > { > - file << (*cur).first << ":" > - << TP::ticks((*cur).second.total) << ":" > - << (*cur).second.count << std::endl; > + float mflops = (*cur).second.count * (*cur).second.value / > + (1e6 * TP::seconds((*cur).second.total)); > + file << (*cur).first > + << delim << TP::ticks((*cur).second.total) > + << delim << (*cur).second.count > + << delim << (*cur).second.value > + << delim << mflops > + << std::endl; > + // clear log > cur->second.total = TP::zero(); > cur->second.count = 0; [1] I think this should also clear 'value' too. > > +namespace conv > +{ > +template > +struct Op_count > +{ > + static length_type > + apply(length_type kernel_len, length_type output_len) > + { > + return static_cast(kernel_len * output_len * > + (Ops_info::mul + Ops_info::add)); > + } > +}; This could also have been a template function: template inline length_type op_count(...) { return ... } Using a template function slightly simplifies the definition and use, but it makes it difficult to use partial specializations (for example, if you needed to compute the ops counts for complex versus non-complex differently). However, the 'Ops_info' class makes such specialization unnecessary. Either way (class template as it currently is, or function template) is fine. > +} // namespace conv > } // namespace impl > > template