|
Enough to make you weep....
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Hmmm... Your second post on this subject. Do you have a quantum computer in your basement, and need to pay strict attention to the Copenhagen Interpretation?
|
|
|
|
|
No, but I have steve wozinak (the only good thing about apple) in my basement. I lured him there with cookies and promise of a new NeXT
Real programmers use butterflies
|
|
|
|
|
int max(int x, int y) {
return x*(x>y)+y*(x<=y);
}
| |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
---- ----
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\/
int max(int x, int y)
{
if (x > y)
return x;
return y;
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
that would figure
Real programmers use butterflies
|
|
|
|
|
This version uses table lookup, no branching.
int max(int x, int y)
{
int arr[2] = {y, x};
return arr[(int)(x > y)];
}
|
|
|
|
|
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!
|
|
|
|