Are there any easy approach to port code?

48 views
Skip to first unread message

hfbl...@gmail.com

unread,
Jan 12, 2017, 5:12:30 AM1/12/17
to blis-discuss
Hi, blis masters:

I want to use efficient matrix multiplication in my project and fortunately i found that blis_gemm just meet my requirement well.
While due to hardware limit(it is too big to use libblis.a directly), i want to port code as small as i can.

So my queston is are there any easy approach to quickly finish the port job? Thanks in advance.

Thanks and Regards,
YiDing

Devin Matthews

unread,
Jan 12, 2017, 12:51:51 PM1/12/17
to blis-d...@googlegroups.com
If you are linking BLIS statically, then I think the linker should
delete all of the symbols that aren't actually used (at least with the
right flags). If it is still too big after that, then I think you are
out of luck since BLIS has a significantly smaller footprint than e.g.
OpenBLAS or MKL. What hardware is this?

Devin Matthews

Jeff Hammond

unread,
Jan 12, 2017, 1:14:40 PM1/12/17
to Devin Matthews, blis-discuss
If the linker suggestion from Devin doesn't do what you want, you can tediously figure out all the dependencies of blis_gemm and paste that code into a single file and see how small the compiler can make it.  This is, of course, a completely unsustainable hack that you only one to do once a year or so.

The other question is how close to optimal of performance do you need and for what problem sizes?  If you are trying to multiple matrices of 100x100 to 500x500 on an embedded processor and would be happy with 75% of peak, then you could use BLIS and the associated academic material as a guide and write your own super-lean kernel.  See https://github.com/flame/how-to-optimize-gemm/wiki.

Jeff

--
You received this message because you are subscribed to the Google Groups "blis-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blis-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to blis-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/blis-discuss.
For more options, visit https://groups.google.com/d/optout.



--

Robert Van De Geijn

unread,
Jan 12, 2017, 1:30:56 PM1/12/17
to Jeff Hammond, Devin Matthews, blis-discuss
BLISlab would be the better academic exercise: https://github.com/flame/blislab


To unsubscribe from this group and stop receiving emails from it, send an email to blis-discuss...@googlegroups.com.

zukic....@gmail.com

unread,
Jul 15, 2020, 9:25:59 AM7/15/20
to blis-discuss
Hello Jeff, 

is there some "smart" way to do what you suggested in your answer to the original question: "..you can tediously figure out all the dependencies of blis_gemm and paste that code into a single file"? Thank you for your time. 

On Thursday, January 12, 2017 at 7:14:40 PM UTC+1, Jeff Hammond wrote:
If the linker suggestion from Devin doesn't do what you want, you can tediously figure out all the dependencies of blis_gemm and paste that code into a single file and see how small the compiler can make it.  This is, of course, a completely unsustainable hack that you only one to do once a year or so.

The other question is how close to optimal of performance do you need and for what problem sizes?  If you are trying to multiple matrices of 100x100 to 500x500 on an embedded processor and would be happy with 75% of peak, then you could use BLIS and the associated academic material as a guide and write your own super-lean kernel.  See https://github.com/flame/how-to-optimize-gemm/wiki.

Jeff
On Thu, Jan 12, 2017 at 9:51 AM, Devin Matthews <devinam...@gmail.com> wrote:
If you are linking BLIS statically, then I think the linker should delete all of the symbols that aren't actually used (at least with the right flags). If it is still too big after that, then I think you are out of luck since BLIS has a significantly smaller footprint than e.g. OpenBLAS or MKL. What hardware is this?

Devin Matthews


On 1/12/17 4:12 AM, hfbl...@gmail.com wrote:
Hi, blis masters:

I want to use efficient matrix multiplication in my project and fortunately i found that blis_gemm just meet my requirement well.
While due to hardware limit(it is too big to use libblis.a directly), i want to port code as small as i can.

So my queston is are there any easy approach to quickly finish the port job? Thanks in advance.

Thanks and Regards,
YiDing


--
You received this message because you are subscribed to the Google Groups "blis-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blis-d...@googlegroups.com.

To post to this group, send email to blis-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/blis-discuss.
For more options, visit https://groups.google.com/d/optout.

Jeff Hammond

unread,
Jul 15, 2020, 10:00:55 AM7/15/20
to zukic....@gmail.com, blis-discuss
I don't know.  Here are some suggestions, which I have not personally tried in this context:


If you write a unit test that calls the BLIS method(s) you need, you can use GCOV to see what portion of the library that test covers.  Then you can delete the rest.  An easier but less aggressive way to prune the library of object files would be to  remove unused objects with "ar -d".

You could delete all o the associated source files from the build system if you prefer.  You could be more aggressive than this and delete unused source code from the remaining source files that are built, but that's likely to be tedious and error-prone.

2) Another way to look for unused code is described in https://flameeyes.blog/2008/03/14/how-to-avoid-unused-functions-to-creep-into-final-binaries/ but I guess that's less accurate and more work than GCOV, assuming I understand GCOV properly.

3) My method for this is to write a test program that calls the function I need and try to link it without the library.  This identifies missing symbols.  Then I include those symbols from the object code.  Then I repeat until it links.  This is mindless and crude but I've used it many times and it works well enough for my purposes.

Jeff

To unsubscribe from this group and stop receiving emails from it, send an email to blis-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blis-discuss/edf57d13-8ac3-40d7-af60-b9e7ee9fef95o%40googlegroups.com.

Lee Killough

unread,
Jul 15, 2020, 12:04:51 PM7/15/20
to Jeff Hammond, zukic....@gmail.com, blis-discuss
You can use:

ld -r -u bli_dgemm -o small.o

(Replace "bli_dgemm" with whatever function you need.)

This creates a .o file with the function you need and all of its dependencies.

-r is the "partial linking" flag which creates a .o file after linking other files. The output file can, in turn, be linked with.

-u "undefines" a symbol, pulling in all of its dependencies.

Lee

[Please forward to interested parties, since Google Groups does not accept email from my address.] 

On Jul 15, 2020, at 07:01, Jeff Hammond <jeff.s...@gmail.com> wrote:



Devin Matthews

unread,
Jul 15, 2020, 12:12:02 PM7/15/20
to blis-d...@googlegroups.com
FYI I received this through the mailing list so apparently Google has completed their ocular assessment and concluded that you are not a threat!

Devin

Lee Killough

unread,
Jul 15, 2020, 12:28:33 PM7/15/20
to Jeff Hammond, zukic....@gmail.com, blis-discuss
Of course, I meant:

ld -r -u bli_dgemm libblis.a -o small.o

Lee

(Funny, my phone keeps correcting libblis as kibbles :)

On Jul 15, 2020, at 09:05, Lee Killough <kill...@leekillough.com> wrote:


Reply all
Reply to author
Forward
0 new messages