|
well played
though you do some memory writes there, which might not be a great thing. then again, it might never leave CPU cache anyway. it's definitely more readable than my approach.
Real programmers use butterflies
modified 8-Jan-21 8:56am.
|
|
|
|
|
In this example the branch prediction won't be an issue. It will basically skip only a few statements. The cost of the multiplications will be significant.
|
|
|
|
|
weird then that my stdlib implementation is branchless. also i'd have to check but i think the compiler can generate better instructions for multiplies by 1 and 0
Real programmers use butterflies
modified 8-Jan-21 10:19am.
|
|
|
|
|
is SIMD a medication your on to prevent writing maintainable code ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Yes. It makes my code execute sometimes 16x as fast.
Real programmers use butterflies
|
|
|
|
|
Can I have some of what you're having ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Sure!
avx implementation of strstr() by Wojciech Muła
SIMD-friendly algorithms for substring searching[^]
I didn't make my own because i'm allergic to bugs. this compares 16 bytes at a time.
#define _mm512_set1_epu8(c) _mm512_set1_epi32(uint32_t(c) * 0x01010101u)
size_t avx512f_strstr_v2_anysize(const char* string, size_t n, const char* needle, size_t k) {
assert(n > 0);
assert(k > 0);
const __m512i first = _mm512_set1_epu8(needle[0]);
const __m512i last = _mm512_set1_epu8(needle[k - 1]);
char* haystack = const_cast<char*>(string);
char* end = haystack + n;
for (; haystack < end; haystack += 64) {
const __m512i block_first = _mm512_loadu_si512(haystack + 0);
const __m512i block_last = _mm512_loadu_si512(haystack + k - 1);
const __m512i first_zeros = _mm512_xor_si512(block_first, first);
const __m512i zeros = _mm512_ternarylogic_epi32(first_zeros, block_last, last, 0xf6);
uint32_t mask = zero_byte_mask(zeros);
while (mask) {
const uint64_t p = __builtin_ctz(mask);
if (memcmp(haystack + 4*p + 0, needle, k) == 0) {
return (haystack - string) + 4*p + 0;
}
if (memcmp(haystack + 4*p + 1, needle, k) == 0) {
return (haystack - string) + 4*p + 1;
}
if (memcmp(haystack + 4*p + 2, needle, k) == 0) {
return (haystack - string) + 4*p + 2;
}
if (memcmp(haystack + 4*p + 3, needle, k) == 0) {
return (haystack - string) + 4*p + 3;
}
mask = bits::clear_leftmost_set(mask);
}
}
return size_t(-1);
}
Real programmers use butterflies
|
|
|
|
|
Yesterday Her Dell desktop's CPU fan started making grinding noises . I left it alone, kind of hoping it will behave today. Well, no, it got worse. Checked with Dell and her machine is 5 weeks out of warranty. They wanted to sell me a fan/heatsink combination for over $200! Yikes! Then I had a moment of inspiration. I had a much older Dell, which I had previously stripped of its hard drives, just gathering dust. I hauled its fan out and it was an exact match for her machine's fan.
So now Her machine is running silently with an old fan. I checked the factory label on the failed fan. It proudly boasted that it had some "hydrodynamic" bearing. Well, Mr. Dell, your hydrodynamic bearing went for a swim and drowned! Now I also know what to avoid if I ever have to buy another fan!
Get me coffee and no one gets hurt!
|
|
|
|
|
My desktop has a noisy fan - but only when I turn it on in the morning and everything is cold. One of these days I must find out which one it is and replace it, but since it means me trying to do that before my first coffee it is not such a simple task ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
One of these days I'm going to make a computer with no moving parts in it. Fanless power supply, one of those copper "bloom" looking heat sinks, NVMe, the works.
I didn't really think about the repairing the fans angle, but that's another good reason to build one.
I'm glad you got your fan issue sorted.
Real programmers use butterflies
|
|
|
|
|
Ya know, you can probably get a fan from amazon that will fit for about $10. if you want a high quality fan, should be no more than #20. You shouldn't need to get a heat sink.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
My thoughts as well. I had a family desktop machine that liked to go through CPU fans once or twice a year. I kept the mounting bracket from the original fan. Replacements got glued on with cyanoacrylate, When they needed to be replaced, a little acetone removed the old fan.
Kind of reminded me of my first car, a '72 Ford Maverick that went through water pumps faster than I did oil changes. I even replaced the water pump one time in the college parking lot. I had the process down to a little more than an hour.
Software Zen: delete this;
|
|
|
|
|
Also avoid installing the fan backwards on the heatsink. Nothing bad will happen...for a couple of years, anyway.
(Yes, I've found two installed wrong-way around. I now check before installing factory-mounted CPU fan/heatsink combos.)
|
|
|
|
|
Hydrodynamic is just a fancy word for plain old bearing.
Take out the fan, on one side of the motor you will find a plastic label, if you lift it you'll find the bearing underneath. It needs a drop of oil.
If it goes for long without lubrication it will need replacement, but if it gets a drop of oil already today you might get another year or two of service from the fan.
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
Good advice! Thanks!
Get me coffee and no one gets hurt!
|
|
|
|
|
And I'm trying really hard to stick to that, right at the moment.
Back at the beginning of December, Herself was sent an email by her employer about Covid vaccination bookings - only it was sent by "send to all", which means that every employee in the address book got every other employee's home email address. All 121 of them. A clear breach of GDPR.
I calmed down (since Herself uses my email address as she can't be bothered to read her own) and later sent a polite note to the home manager (via the email address her office bod had so kindly given me and everyone else) explaining what had happened, what the GDPR implications were, and just how big the fines a company can receive for this kind of thing.
I'm nice like that: try to get it resolved without bankrupting the company Herself works for, that's me!
Then today ... I get another email from the same idiot telling me that all pay slips will be sent electronically in future rather than issued physically. And again, she uses "send to all" and I get 117 email addresses ...
And I'm boiling again ... and trying really hard to calm down and not respond until I do ...
What do you have to do to tell these morons that they are doing something really, really, stupid? Preferably without bankrupting a company with GDPR fines?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
notify the authorities. it is the correct thing to do. fines or no fines.
edit. call the offending person by phone, and tell them that if this happens again you will notify the authorities.
|
|
|
|
|
I think I'd just notify the authorities. Since there are over 100 of you in this situation the company won't know which of the 100 to fire.
|
|
|
|
|
Let me guess, they are of the 'I am being forced to use' type. Once is a problem twice dear . I agree with Slacker telephone them and ask them if they know what they did, how they did it and GDPR fines which they could liable for. See if they use email again!
|
|
|
|
|
Just accept the reality that you can't fix stupid. Admirable that you want to help the company.
They could be shown how to use BCC, at least that hides it somewhat.
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
I will add to the make a phone call side. Point out to them clearly that they have done it twice and with a third they will be reported and the fines could be substantial, especially after they have done it three times.
However, one thing to weigh here is whether you afford to have herself lose that job because that seems likely, especially given the nature of the boss. UK labor laws might prohibit such retaliation but I have no idea. Regardless, it could get messy.
Upon further review, it might best to send an anonymous e-mail to him and include the text of the e-mail you will send to the authorities if it happens again. Less chance of retaliation that way.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Rick York wrote: UK labor laws might prohibit such retaliation Do you honestly think that has an effect on corporate behavior toward their employees, in the UK or under similar conditions anywhere in the world?
Labor laws, such as they are, come down to your resources vs. theirs. Guess who wins.
Software Zen: delete this;
|
|
|
|
|
Even in Italy there have been recent reforms that eased this kind of retaliation.
Before "Jobs Act" reform in case of an unjust layoff the company would be forced to rehire the person at the same level as before being fired, pay back the missed salaries during the court case and keep the seniority as if the person worked there in the meantime. Today they just pay damages, which aren't that great anyway.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Yes, I honestly think when employment law is involved your resources don't matter that much because I have witnessed it first hand. Your mileage may vary and, given your condescending tone, I couldn't care less.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
May be 2 years ago I kept receiving a pay stub, as a PDF, being sent every two weeks (at least it was password-protected, which was probably their saving grace), at one of my email addresses using MyActualName@SomeMailServer.com.
The emails were from a big retail chain, very well known here in Canada, and their retail employees aren't exactly "sophisticated" (having a pulse is probably enough to meet their hiring requirements), so my guess had always been that she had given her husband's email address for any electronic correspondence being sent to her (and he happens to share my name, and my address probably matched his, minus a dot or hyphen or something like that).
Those were being sent from some "donotreply@companyname.com" type of account, so I couldn't respond directly to them. After ignoring them for a few months, I was finally annoyed enough to track down an actual address on their web site and sent an email there, which I'm guessing was forwarded to their HR department. The lady working there seemed concerned enough to thank me for reporting this, and assuring me it wouldn't happen again.
After receiving 3 more of these (and me re-sending the same thing each time, and including our prior correspondence), I finally stopped getting emailed the pay stubs. But then a few months later, I was sent yet another email (destined to the same employee) saying something about some mandatory online training, and unique logins were going to be emailed in a short while. I had to guess that even though the incorrect email had probably been purged from the payroll system, it still existed elsewhere as a separate entity.
I dug out the HR contact from a few months prior, explained the situation again, and tried to remain polite as I pointed out that I could just keep quiet and use those credentials that were going to be sent and log into their system as the legitimate employee and do whatever that employee might have been granted the permissions to do. I can't remember exactly what it was, but I used a similar story that was much talked about at the time as an example to illustrate the sort of PR nightmare they could be made to go through if I had any sort of ill intent. I don't recall the details, but I've probably used GDPR laws to point out that, if we were in the exact same situation but happened to be in Europe, they'd be exposing themselves to some..."trouble", to say the least.
I think that time I put it in terms they finally understood, because that was the last I ever heard from them.
|
|
|
|
|