memset16

Member
Posts: 64
Joined: 2008.10
Post: #1
I see android have arm optimised versions of memset: http://code.google.com/p/skia/source/bro...rm.S?r=594

Are the equivilant functions available for the iPhone?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
memset and memset_pattern* do 1, 4, 8, and 16-byte patterns between them. I don't see one that directly does 2-byte patterns, though obviously you can use memset_pattern4 for the purpose.

Code:
man memset_pattern
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #3
Ok. Maybe I'll just try using the android code
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
"yes, here:"
"OK, I guess not, thanks anyway"
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #5
I think he was disappointed that you didn't point him to "optimized" versions. You just pointed out the stdlib versions which clearly must be inferior or why would a custom optimized version exist.

* Skorche shrugs

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #6
Amm. There is no stdlib version for memset16. And what's wrong with trying out the optimised version? You prefer stuff to be slower?
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #7
(Sep 20, 2010 10:19 AM)captainfreedom Wrote:  Amm. There is no stdlib version for memset16. And what's wrong with trying out the optimised version? You prefer stuff to be slower?

Mad
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #8
Uh. The first reply to your post stated that in fact there was a 16 bit version. Also, do you have any reason to believe that these "optimized" versions really are any faster? have you actually tested them or are you just assuming that they are because they exist?

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #9
(Sep 20, 2010 10:19 AM)captainfreedom Wrote:  Amm. There is no stdlib version for memset16.

The man page OneSadCookie pointed to in his first post says otherwise, so I'm nor sure what you mean here:

man memset_pattern Wrote:void
memset_pattern16(void *b, const void *pattern16, size_t len);

(Sep 20, 2010 10:19 AM)captainfreedom Wrote:  And what's wrong with trying out the optimised version? You prefer stuff to be slower?

Skorche's post was tongue-in-cheek, presumably meant to point out that unless you have the profiler measurements to prove it, it's a relatively safe assumption that the stdlib implementation of a function will be optimal. If this is used in a crucial part of your code, and you've profiled it and shown it to be a bottleneck when you implement it with memset_pattern16, then you have a good reason to try out the optimized version. Otherwise, it's premature optimization, which is wasted effort if it doesn't end up being faster than the easy way. Since the only real way to measure that is to implement it both ways and profile your code with both methods, and since there's a perfectly good chance that the easy way will be fast enough in your case (and a chance the hard way is no faster than the easy way), it's logical to only try the hard way if you've already implemented it the easy way and proven it to be a bottleneck.

To the earlier sarcastic posters, the above is not necessarily self-evident. If you assume that every poster here has an intuitive understanding of these things that matches yours, it gives the forum an elitist and unwelcoming tone. Taking the time to explain things unpresumingly not only gives the person asking the question a better chance to learn, but also fosters mutual respect and a more positive forum environment.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
that's 16 bytes, not 16 bits. IDK why he wants 16 bits, but he seems to.

Yes, memset and memset_pattern* are highly optimized.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #11
Ah, I did misread the bit/byte distinction. (I thought it odd that they would bother with < 1 byte patterns, now I know why.) Presumably he wants a 16 bit version for clearing a framebuffer or some such.

I wasn't however being sarcastic in my second reply. I was quite seriously asking if he had tried the stdlib versions and found them to be inefficient for what he wanted. He asked if there were optimized versions and seemed disappointed when the stdlib versions were mentioned.

If the confusion was that there wasn't a 2 byte/16 bit version, then you can just memset_pattern4(buff, pattern | (pattern << 16), length) The assembly code linked does the exact same thing. The 16 bit version just calls the 32 bit version.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply