Wednesday, 12 October 2016

Embedded GPU, EULA & DRM Issues

At work this week, I've had an embedded Linux single board computer come across my desk, I've had to evaluate it.  My brief appraisal came down to "great CPU & memory performance, crippled GPU performance".

Which was strange, as it was touted to be a pretty decent GPU, and indeed it is, and I could use it to perform OpenCL processing, and even got the new boost compute stuff working on it in C++.

But, it would not display anything in hardware, all the rendering of OpenGLES went through the software mesa driver, removing the mesa driver got me a blank screen.  I therefore set about understanding this issue, because the vendor of the board supplied the image I was using, and another of their demo images had all sorts of fancy graphics, spinning tea-pots galore!

So, what was the difference?  A graphics driver!  The locked down image with all the demo's appeared to have a graphics driver, whilst the released end-user images had none.  Annoyingly the vendor also had no working build recipes for their system; they had recipes, they just would not build.

I therefore approached the GPU side directly, looking at other boards with the same chip set and support packages, I found one, and it became obvious why these end-user images had no driver, you had to sign up to an agreement, as to how you were going to employ the GPU.  If you were going to use the board in a product which could access or use DRM controlled material, it was up to the persons/entity accepting the GPU driver agreement to ensure everything was above board.

The vendor of the linux board supplied no driver, not signed, so they would never be liable if your use of their product ripped someone else of.  Clever of them.

However, it left me with the issue of "shall I accept this EULA on behalf of my employer".  After asking around the general consensus of responses fell into two firm camps.  Either "I don't know" or "Just accept it anyway".

This latter attitude is, well frankly it's dangerous, if you don't know what you're signing up for, don't sign up for it!

Happily, I now know what the EULA is asking me to sign up for, I know the product is not going to be using any DRM signed content, and therefore I can continue, but in my opinion it's worth always checking the small print!

Monday, 10 October 2016

Computer Science : Laws of Computing : Imitation & Emulation

"in principle any computer can be programmed to imitate the operation of any other"
 - John Von Neumann


This is an important quote, taken in context of the universal computing machine, it tells us something very fundamental, something important for the operation of a computer, for the security of computer systems and the future of computing as we move forward.

I bring this up as I had a brief chat with my boss today, in passing I was looking for something new to do in the office, it's going to be a tumultuous time in the business, and one of our which I want to be equipped, both equipped with work to do and the knowledge that I'm contributing.

My reasoning?... Well I actually quite like my employer!  As rare as that is.

However, one of the major product lines is based on quite old technology, quite an old processor.  The company is quite heavily invest in this in terms of the code base, but it also seems ideologically it is also very dependent.

Which is why the above statement came to mind, I first learned that phrase in the mid-90s when I was studying computing, and Von Neumann was still kept very much in the forefront of teaching along with others like Turing and Backus, figures who have cast long shadows over computing, but whom seem to be ignored until a documentary is released, or an anniversary comes along.

However, us true geeks, we read and learned about them thirty years ago, long before it was fashionable to do so.

And this phrase then relates directly back into my conversation today, as I pointed out we could easily; very easily; emulate the main processor in the main board of our main product, to start to port ourselves out of the evolutionary dead-end designed into the boards however many decades ago.

It would leave the current chaps with their roles, in fact with more to do, but would also bring those of us with newer ideas, ideas and knowledge about the machines which could perform this emulation into the mainstream.

My bosses reaction was to essentially say there was no way a PC could emulate the processor in our product.

Sadly, he's wrong, not only could a PC do it, easily, but there are already tools and libraries to do it!

The lesson, the basic principles of computing apply everywhere, whether you want them to, or not.

Software Engineering : 5 minutes 33 seconds every C++ developer should watch

Just... Just go watch this, digest it...


I've love to print this out frame by frame, phrase by phrase, and have developers walking through the door recite a line at random every morning.

Tuesday, 4 October 2016

Software Engineering : C++14 Factory Create Pattern for GCC

In my previous Software Engineering item, I covered a factory create pattern, to prevent programmers using my classes with their vanilla constructors, forcing them into using a smart pointer in the hope that they would never get a memory leak from using my classes (assuming my classes clean up cleanly internally).

This pattern can be seen here, but is specific to the Microsoft STL implementation of the Memory classes.

On Linux however, with GCC, you have to make a different class a friend, this is "__gnu_cxx::new_allocator", which like "_Ref_count_obj" is an implementation of a counter to references to the allocated class type.  It is also templated, and used exactly the same way as the Microsoft version.

Use it like this:


You can see my whole screen, with all the code here:

Click to Zoom in

On the left is the example code, on the right you see me invoke g++ with C++14 to compile and then run the example program.

The code clearly shows the private constructor, it's a trivial class, if any of that confuses you then this maybe too advanced an item for you to pick up on just yet, but do come back and learn this, as it's very useful when you've built up your C++ confidence.




Sunday, 2 October 2016

Music : Still Wishing I Sounded Like Hetfield

Yeah, still wish I sounded like James Hetfield...


Though it looks like I have the same hair as Lars now....

Friday, 30 September 2016

Office Best Practices - Expenses & Purchasing System

After taking a stroll through these pages, you may tell that I once commanded quite a large IT budget, in quite a large company.  I worked throughout the UK, into North Africa and out across Eastern Europe with them... There were Four levels of expenses in that organisation:


  1. Capitol Expenses (> £10,000)
  2. Red Band Expenses (<£10,000)
  3. Blue Band Expenses (< £1,000)
  4. Green Band Expenses (< £50)

Each department had a cost code, and various levels of staff were able to order on various levels of expense.  This worked brilliantly, lets go through a couple of examples:

Billy in stores needs a new roll of tape for boxing up equipment, he gets out his Green Band expenses sheet, fills it out, hands it to accounts payable, whom check Billy can use Green Band, which he can, he is listed.  They pass the purchase order to purchasing, and the item arrives at Goods In, and is taken to Billy.

Perfect for small items, it lets routine business be carried out, without fuss, you have accountability, and you don't need a senior; highly paid; person taking time out of their day to check and sign every little order, there is a cap limit on an order, and only certain people are assigned the location, and there are two points at which these orders are checked & summed, accounts payable and purchasing.  If there is any "fiddling" going on, both those points can independently check the other, and both check poor old Billy is not getting a kick back on the company.

Purchasing can also try to seek the best price, and accounts payable can handle taxes and other considerations.  At any point these orders could be sent back, for example, one system I personally worked to implement was a link between accounts & purchasing to the stores database (a FoxPro database at the time - yeah, you remember that!!) and it let them query if anything they were about to order was in stock!  Simple, and for my time it saved the company about £8,500 a year in sundry purchases as we stopped being up to the ears in paper clips, biro's and printer paper!

The other various levels of expenses in this system did need other security measures, so on Blue band, which is where I started as a member of staff, you needed to get a managers signature.  There being three levels of managerial staffing:

  1. Managing Director/CEO
  2. Director
  3. Manager
Each manager had between six and thirty people working for them, each director had between two and five managers, and there was one guy at the top... Well one woman at times, to be honest, and she was better... Any how...

So, a blue band raised by me, went to my manager, then was ordered....

A, Red band, raised by me went to my manager or he raised it, went to a director and was  triple checked.  Very rare were these, so people often knew they were coming, and they were planned for and adhered to the strict budgets in the accounts department.  Us lowly minions ordering the stuff, we put out business case on the form, people knew what was being talked about, and so we knew what was happening, we knew whether someone was just lining their nest with kit, or whether there was a genuine business need.

And when this very business was in trouble and being bought out by a rival in the US, we saw these requests drop and drop, the budget fall and fall, it was easy to understand where the company stood, where everyone stood.  It aided transparency, which made the staff; even in the face of the company being taken over; feel assured there was a plan, and someone was in control.

Finally, a Capitol Expense, I only saw these twice, when I had to buy a company car contract for myself... I loved that Audi... And then when we actually purchased a building, yes a whole building.

They went to the top, were discussed a lot, and got the job done.

This layering, might today seem strange, but I bring it all up, as a history lesson.  This system worked, it wasn't perfect, but it was regulated, it was transparent, it was not based on whom liked whom, or who knew who, it was based on a form, going through a process and getting a result.

Exactly the sort of thing a computer is very good at, and all this today could forego the forms and be an online purchase request system for a company, you log on, you put green's straight through, you put blues to an assigned manager... etc.

So, why the history lesson?  Because today, I've sat for four hours, with not one but two broken HDMI to DVI leads, both my main lead and the spare were broken, and broken in the same way.  I suspect the spare had actually been taken by someone else and their faulty one left in it's place in my cabinet.  But whatever the reason, I had two faults, and two machines down and sat struggling without the target platforms I'm deploying to.

No-one else in the company had any cables of this type, they all generally just use VGA, I'm the exotic one with DVI and HDMI.

So I go to find my boss to ask for cables, I work directly for the Director of Technology, he's a busy man, he's an expensive man to employ I'm sure, so why should he take time out of his day not only to listen to my needing cables, but to carry out the ordering himself?

It beggars belief, he has to find the item he wants me to have, not the item I prefer or have identified, he picks what he wants me to have, he raises the purchase order and he places the order, letting accounts know later.  Then the item may, or may not, come straight to me, it may sit in goods in until I gee them along and ask where the cables are.  Or it may just get sent straight to the very busy Director himself and it'll sit until he has time in his very busy day to open it.

The net result?... Delays and confusion.  The system is a black box.  I believe the idea behind this is that ordering things is seen as an expense, and the ability to order something within the company is seen as a traditional expensive thing.  This maybe because this is a nearly 55 year old company, and they're stuck in very old fashioned attitudes.

There is no need for this cloak and dagger approach, security through obscurity may leave those at the top of the chain feeling secure, but it leaves those of us trying to get the job done stuff waiting.  During the time we sit waiting, I've pondered the risk to reward for the company...

Now, not wanting to let out how much I earn, but lets just say the costs of the items I've needed over the last fortnight would total about two hours of my paid working hours.  How many hours have I spent waiting, stuck, not able to work whilst the kit was ordered by one busy person?... Five.

This is not the "how long to wait for the delivery", this is not "how long to get purchasing to order them", this was just how many hours from my raising the request with the busy Director and his actioning looking for the items and then letting me know they'd been purchased; he in fact didn't let me know, so I just take the difference in time between the end of the first day and the next when I had the mail confirming the order CC'd to me.

Five hours, versus two hours, meaning, if the company accepted, developed or adopted a Green Band expenses policy like the one above, almost tantamount to what might have once been called "petty cash" then they'd save money.

But of course no-one is looking at this holistically, they look at the price of the item, the amount of cash you could be spending on ordering items, and they see a LARGE chunk of money.  The company credit could rack up a lot of items on an order, and they'd be accepted by the suppliers because we're in good standing; and I understand this, I understand the need to secure that process or ordering.  That security should be the responsibility of accounts and purchasing, not the Director of Technology, and not me.

For you see, as much as the cost of ordering items tallies up for the company, and the accounts show that easily, less easily expressed is the cost of an hours time on a salaried worker.  We are a fixed cost, and probably less than the total purchasing power of the whole company.  So it gets ignored as a non-cost.  To leave me sat here waiting costs nothing extra.

Of course however, it does, it leaves me wondering about topics like this, about how the process works, about why I'm locked out of this trivial ordering task; when I used to command huge budgets, why am I not trusted to order a cable now (and I've worked here for a very long time); and if I'm not trusted, am I considered expendable, am I considered a joke.

It's the simple self-analysis of Office Paranoia, and it all begins because of a lack of transparency in ordering, and a lack of forethought as to how much it costs to "risk" letting people order trivial, petty, items as opposed to having an expensively paid Director be comptroller of order slips.

Monday, 26 September 2016

Story Time : Fantastic Rack Mount Mistakes #4

The final story in my little series, really revolves around the dread of all server room administrators... More nerve shredding than fire!  More nerve tingling than granting terminal access!.... We are of course talking about moving server room....

The plan was eeked out of management in literally, fifteen minutes of a meeting... We had three 6' racks all the wiring, all 2U servers in one rack with a 32 port switch at the top, nicely wired by good self (wishes I had a picture, but we were still using film for photo's back then, and it was too much effort).

The middle rack was a bit more the experimental kit, there was a 4U server in there, a couple of desktop cased machines stood directly on top of that unit - with plastic cutouts to stop hot air from the back feeding back to the front of the rack - yes, even with ghetto server layouts forced upon me, I did try to make the best of things and keep good order...

The third rack was telecomms units, it contained a bank of modems (yes, 64K modems!) another ethernet switch, an unmanaged switch too, and our SAN.

The SAN was a Dell EquiLogic; from memory I remember having 16 drives in it of 120Gb each, and two were hot spares...

The plan, from management, "unplug it all, load it into the two Nissan Primera Estate company cars, and move it from Derbyshire to Leicestershire"... 

That was it, "unplug and move"!

We had two days, over a weekend, to do this... It was Thursday afternoon... The clock was on.

Before you ask, I can't tell you much about why we had to move, nor whom I was working for, but let us just say, a week after the move the company changed name, and I changed employment soon after.

So, Thursday afternoon, I sent out e-mail to everyone, all staff, literally everyone, and said "The Servers are ALL going off, the Network is coming down, ALL IT services will be suspended at 3pm the following day".

Of course the whole place started to moan, so I promptly sent another mail.. "No seriously, ALL Services will be offline at 3pm, I'm serious!"  And I left the building to go see this new site... Two hours driving later, it's nearing 5pm Thursday and I arrive at a tin-shack looking warehouse like building, am let in by a man with a carrier bag and a cough.  I get the keys off of him to, and go check out the "IT Room" as he calls it.

It's a desk, with a single 15amp 240v rail supply and a bunch of cut off ethernet cables spilling out the wall in one corner.

There is no aircon, there is no patch panel, there is no racking... And it's on the first floor... (If you're from the US and reading this, here in the UK the floor against the ground is called "the ground floor", and the "first floor" is above that, it is up at least one flight of stairs... Yep, stairs... No lift (elevator).

Company credit card out, I head back to the office, and I order on next day (before 11am) delivery two RJ45 crimpers, two spools of ethernet cable, a pair of wall mountable 8U cabinets and a laptop (you know, because I thought I might need one) and a pair of walkie-talkies.

I then survey the kit I have to move, now, I can ignore the modems in the large, they unplug and lift out, but there's no telecomms due at the other end for a fortnight, so they'll go dark, they can be the last thing we move.  The switches in that right hand rack though therefore become free, and I can take them our now and start to set up the ethernet at the other end.

I have been assigned a minion from the shop floor to help, Friday morning comes and I await until 1pm that afternoon for my "before 11am delivery"... things are going so swimmingly already.  But I have had time to take the two desktop form factor servers offline, the 4U unit off line, the front blanking all out and disassemble the middle rack.  I've also got the switches from the right hand telecoms cabinet...

In our first transfer load we therefore have the rack, cables, UPS's, a 1U fold out terminal and crimpers in one car.  The two desktop servers and the 4U unit in the other.  We drive to the new site, unload the servers onto a trolley and lift them up stairs, placing them in a corner on the floor.

We then pull up the rack, assemble it, and fit a switch to the top of the cabinet and I send my helper off to survey the site, looking for any and all RJ45 sockets, and noting where they are, room by room and any notes on them.  I meanwhile start to splice new RJ45 connectors onto every one of the fifty or so ethernet cables laying on the floor, and I plug them into the switch.  I braid them all and cap them and wrap them nicely into the rack cable managements either side.

The switch has a useful line-test function, and my minion has the laptop!... So he can just plug a cable in at the other end and I see a light come on...  Over the radio I ask him to pick a socket, tell me if it's marked and to plug in... We do this room by room, and I move patches around to group rooms together, and I tell him a number to mark on the socket with a sharpie.

We've been at this mind numbing task for a couple of hours when I decide we need a break, and I go down to meet him... I'm a little aghast to see he's not written on the little window areas for the socket numbers, he's written them in letters as tall as the socket itself... *slaps forehead*.... It looks a mess, but it works, I'll have to come around in a weeks time with some acetone to clean it up, but it'll do... It'll do.

Fifty odd sockets later, we've got the whole building ethernet hooked into this switch.  The rack is powered and the UPS's are stable, reporting good, and the 4U server is up and fine from the laptop over a few of the sockets I've checked.

The two desktop servers survive the move too, and they're placed in the footing of the rack, rather then perched ontop.

Everything looks fab, and we've got this all done before 7pm on the Friday!  Things are looking GOOOODD!

I buy the chap helping me a pub meal, and he takes the company car home, I expect to see him Saturday morning.

Saturday morning, before switching down everything in the office, I check everyone is offline, and start to kill the servers down.  The SAN down, and pulling everything out of the rack, I'm stacking all the patch cables I'm taking all the units out and the car is pretty full.  Where is the other car?... 9am... 10am... No sign, I've got to call him.

He's at home, in bed... His wife describes him as, "Drunk as a lord"... He apparently didn't realise I needed him the next day, and had a skin full after he'd gone home.  He can't drive.

So, I'm flying solo... 

I drive the first load down to the new site, and basically throw it all out the back into the loading dock, and set off for the next load, I get the UPS's for this rack in the car and two of the 2U servers... and it's pretty much at load... Four more trips and I have all the servers at the new site, in the loading bay, and I'm taking the left hand rack down at the old place.

It won't come apart, and it's really a two man job... So, I give up, and I load all the bits I can up, and go to the new site, and decide to just stack the machines up off the floor but in a pile, rather then rack mounted, for a while.

So, machine by machine, I lug them up the stairs... It's heavy, it's hard, and I'm on the penultimate machine... When half way up the first flight of stairs I feel I'm about to loose my grip.

I try to catch a better hold, but it all happens at once, the machine is free, I'm toppling to my side as the weight takes me, and I'm going down the stairs on my side with my left finger in the thumb hook on the front of the server.

Lets just say, it was my left finger... And the server fell to my right.... Yeah, snappy snappy.

So, I have definitely broken my finger.  And I've definitely broken the server, as it bounced down about eight hard steps, the real flanges on the rack rails are all bent, the handles on the PSU units are smashed and the drives have shook loose...

Swearing and hobbling I crawl over to the machine, pop the lid and it's all fucked, just properly fucked.  The motherboard has popped up, everything is a mess.... That's an expensive mistake, but not-one I've ever admitted to, until now.

My finger however, needs attention, so I lock up and take a trip to A&E... After three hours they basically say it's a bad break, and put my hand in a mini-cast across the back of my hand and down my finger itself its all fixed.  I can use my wrist.

I return to the site, and luckily for me, there are no more servers to be lifted upstairs... Because someone has hiked open the loading dock roller door and pinched the one remaining server which was sat there.... They've also taken the laptop from upstairs, the two desktop profile servers and a bunch of other stuff...

When I go talk to the "security" guy, the old geeza with the bag from the previous day, he's still carrying his bag... I ask if he saw anything, "yeah saw one of your lads moving your computer things"... I explain he wasn't one of our lads... "I thought that funny, he didn't lift the roller, but crawled under it"... Total retard.

A 999 call later, and checking the grey CCTV, the policeman says he reckons he knows where our stuff is, and they set off to a well known local toe-rags house, where they find the shit with several 2U servers, a spool of ethernet cable and they're busy trying to log into my locked laptop, which was running OpenSuse and totally baffled them.

The police seize everything, I can't get the job done, I call the boss and tell him, and basically tell the security guy to not let a soul past him until they show the ID's for the company. 

Monday morning and I'm at the old site, showing people how to unplug their machines for transit to the new site, there's a fleet of vans to help now... You know, gotta move the leather chairs of the directors and the coffee machine properly, but the servers... ner just chuck them in the back of the car!

Needless to say, the ethernet all worked for everyone, replacement servers were easy enough to sort, and restore from the SAN, which was all fine and in place.  The smashed server was harder to explain, and I chose not to, and let everyone assume the thieves had dropped it, whomever dropped it, it was well insured, and the replacement was the first of the then new Dell Poweredge's with the Itanium 2 in them!

But, I soon left this role, the company was sold to a larger parent and stripped of assets.

The drunk, he had my eternal ire after doing such a good job initially I found him not so appealing.

The local toe-rag, got 3 months, all the assets took, IIRC seven weeks to be returned to us, and some bright spark had used aluminium dust to take finger prints off of them... JOYEOUS!