About Me
Michael Zucchi
B.E. (Comp. Sys. Eng.)
also known as Zed
to his mates & enemies!
< notzed at gmail >
< fosstodon.org/@notzed >
GPGPU & OpenCL
Hmm, after getting a bit of stuff working with the CPU OpenCL yesterday I thought i'd better dig deeper into the GPU side of things. Kinda wish I hadn't. It's ... a bit ... messy. It's kind of like it wants to be a vector processor but can't make up it's mind. To get the best performance you have to know a lot more details about the internals (on the specific card in question) than you do on something like the CELL CPU, and it's more difficult to realise it. The minuscule local store could be a real bottleneck. I wish I still had linux on my PS3 to be able to try out some CELL code to compare, but fucking Sony did that in didn't they?
I guess it'll be a challenge.
Winter.
Damn, winter hit properly all of a sudden this week. Went to the pub on Monday night and spent most of the way riding home shivering a lot, and what was with some new winter gloves and a good riding jacket. Even resorted to wearing long thermal underwear to try to stop my feet freezing during the day, but with only limited success. It's not even really that cold in absolute terms - about 10C, but I seem to be feeling it more of late.
I got a fair chunk of retaining wall done a few weeks ago with the last of the sunshine, but have been very sedentary lately - the weather, the short days, eating oddly, sleeping irregularly, it all adds up. Always seem to feel extra flat around this time of year too and I seem to be even more extra-flat for various reasons. And overly anxious for no good reason.
I started looking at OpenCL this week for work at last. The basics look pretty simple and straightforward, and i've got some little prototype code working already, although it looks somewhat more involved to get the most out of it. The work synchronisation stuff looks pretty rich and relatively flexible and will hopefully be able match the problem I'm working on. I'm just using the ATI CPU implementation so far but will hopefully get some real hardware soon. I don't think i'm quite as excited about it as I thought I might be, but I guess there are other factors at play.
Been making a lot of noodles and flat breads lately. I've just about got a decent naan-ish bread worked out. Need to use a hotplate or frying pan to cook them - my oven just isn't hot enough (there's a thought, perhaps I could try the grill). Also tried making crumpets which sort of worked - only having wholemeal flour at the time I think that was a bit of a handicap. I think my attempt at making sourdough has spontaneously aborted itself though so I might have to reset on that - it's been too cold to keep it active amongst other errors. I'm not sure all this bread and noodles is really all that great though - well apart from being somewhat fattening while i'm otherwise being such a lazy arse, it seems to aggravate the sleep apnoea. Although that's so fickle it's hard to tell - particularly when you haven't had enough sleep.
I watched a bit of the oil spill cameras there for a while. Interesting certainly, and in many cases didn't really inspire confidence in the equipment they're using or the procedures they were attempting. One day I saw a sub spend an hour picking up a block and tackle from a snag-riddled box only to put it back where it got it from after finally untangling itself from all the snags. And cutting off the final bit of the riser (which I saw live) just created a torrent of hot oil which barely seems to have been throttled by the mounting of the LMRP - the later camera shots were from closer in which made the over-flow appear more controlled. I'm glad my sister is getting out of Florida - although she'd decided to leave before this anyway because she's sick of being paid 'minimum wage' $4.20 an hour plus tips in the only work she can find there. Although I'm not sure what she expects to find back here in oz, it seems to be headed toward the stupid-right as well.
On an unrelated note, I never really understood the service that facebook provides, and didn't particularly like it and do not use it much. But I think i've finally worked out why I dislike it. To cut a long babble short it pretty much just makes me feel lonelier, more alienated from society, and more of a boorish, boring loser than I might otherwise feel. What rubs it in even more is these are people I was at least once friends with; although most were some time ago. But even with those people I have very little in the way of shared interests or anything much even to talk about.
Hmm, this could be a long winter.
Australian Bananas Suck
They do, they really do.
We get to eat tasteless over-firm shitty bananas so some dumb queensland farmers can protect their third-world crop from foreign competitors. It's just the public who suffers - subsidising their production and having to put up with sub-par produce.
Shared Libraries n Stuff
Hmm, another long weekend followed by what turned into a long week. Damn I'm tired.
Well I gave up on building XBMC on the beagleboard for now, and I haven't had time to work on setting up a cross compilation environment yet either. Work is getting in the way too much, just too worn out to concentrate enough. I should try this weekend, although I need to get outside a bit too for some exercise and my own sanity.
I spent the rest of the long weekend past trying to grok shared libraries and thinking about how to get newlib into one for WoofƆs. I didn't make a lot of progress. It would be nice just to use something like Amiga libraries which are more like objects, including an instance pointer to all functions, but that just makes it too hard to re-use existing code. Partly because all the code also must be re-entrant and not reference .data or.bss, not to mention the object pointer. Easier to map/load, not so easy to port existing libraries. I just about had a handle on the whole elf-shared-library thing, but I was a bit too tired/distracted so it's still a bit up in the air.
Well at least one nice thing is it only takes 17 seconds(!) to do a complete build of newlib on my workstation, althoughI fear I will need a few iterations before I work it out. I was trying to enable _REENT_ONLY, but it seems to be an old option which is no longer supported and fixing it all up will be more hassle than it's worth, so I will probably just have to work out elf shared libraries to make any progress there.
It's not that I really need a C library just yet, but I was thinking about how to write the application server and how to hook system startup into application startup, i.e. accessing dynamic memory and so on, and so I was just thinking of killing two birds with one stone. Might have to leave that on the back burner for a bit, and try something a bit more modest. Actually I should probably put it all on the backburner for a wile, I have other things that need attention.
I didn't do anything on the yard at all last weekend - a bit hungover Saturday and then the weather turned. It's been a bit cold and crappy most of the week (in relative terms) which is always pretty draining. And the days are so short already ... (particularly when you get up at 11 or 12!)
Sleep. Damn. Eating poorly, sleeping worse. It adds up. My mouth has been a bit sore so I have avoided using the mouth splint every night - but boy do I notice if I don't use it. It's like the `Rain God' truck driver in So Long and Thanks for All the Fish who upon experiencing rain so heavy he imagines it makes no difference whether the wipers are on or off tries turning them off, only to discover it really does make it a lot worse. However to his dismay it doesn't get any better when he turns them on again. That's exactly what it is like with the mouth splint and sleep apnoea.
Well i'm glad I stayed in rather than going to the pub tonight - starting to feel a bit weird, and last weekend was too depressing - my drinking buddy went off to a show and I had a couple more at another pub, and what I can remember got pretty boring by the end.
Accepted for GSOC 2010, XBMC acceleration
Well the students and projects have been announced for the GSOC 2010, and the beagleboard project ended up with 6 slots, which is quite good considering it is their first year (and I was expecting only 4).
And one of the projects I put my name down as a mentor made the cut - the XBMC acceleration project which seems to have been a favourite amongst all potential mentors. Since we knew what projects were in the top running I have already had some contact with Tobias in preparation, and he seems both keen and also good at communicating with the XBMC project which will of course be vital. Well I'm not sure what I will have to do to help as it is not a project I've worked on but I guess I'll learn as I go too.
I have also been trying to build XBMC on a beagleboard (silly I know - I need to set up a cross-dev environment for it) - wow, what a beast of an app. I spent about 3 days just setting up a new angstrom and the build dependencies (I just did a bit when I walked past and noticed it'd finished the last bit/failed again). Very slow - also doing it over NFS so that probably isn't helping. And I don't really need to, as I'm using my old PS3 hard drive as the system drive - it's much faster/more reliable than flash cards are.
Just as well I don't have 'a life' - i've got plenty of time to play with this stuff without any distractions.
PS Sorry to those who didn't make the cut this year - there were a lot of applications and plenty of competition.
Java n i/o
I needed to write an application to process very large files, and it had to run on M$ stuff. Well for me that means Java since my workstation is GNU.
I would normally use C, and would definitely use GNU/Linux or some other system with a modern filesystem on a task like this - NTFS is so god-awful slow. But that wasn't my choice.
Just to make sure i/o would be as minimal a bottleneck as possible I wrote a very simple async i/o loop - I don't even know if makes a lot of difference because Linux does quite aggressive read-ahead anyway, but it certainly doesn't hurt it. Java 7 is supposed to have an async i/o interface that maps more directly to the OS one, but that isn't available so I just rolled my own.
I used the 'nio' interfaces - just for the buffers really to avoid excess copying. Oddly searching for 'async i/o' brings them up but they only have a non-blocking select type thing which has no use in this application.
It's pretty simple anyway. First a bit of setup in the processing thread.
final ByteBuffer sentinal = ByteBuffer.allocate(0);
final ArrayBlockingQueue queue = new ArrayBlockingQueue(numBuffers+1);
final ArrayBlockingQueue done = new ArrayBlockingQueue(numBuffers+1);
// must be one less than queue size - room for sentinal
for (int i = 0; i < numBuffers; i++) {
done.add(ByteBuffer.allocate(bufSize));
}
The main idea is using the blocking queues as a read-ahead mechanism. They seem to have a fair bit of overhead but it can be easily tuned by using different sized blocks.
The sentinal is used to mark end of file.
Then a thread is setup with a simple loop:
while (true) {
ByteBuffer bin = done.take();
bin.rewind();
int len = fc.read(bin);
if (len > 0) {
bin.limit(bin.position());
bin.position(0);
queue.add(bin);
} else if (len == -1) {
queue.add(sentinal);
break;
} else {
done.add(bin);
}
}
It took me a little while to realise how to use the ByteBuffer properly - to reset it after reading so the processing loop can read the same data, but it's pretty straightforward.
The processing loop is then simply:
while ((bb = queue.take()) != sentinal) {
... do stuff ...
bb.clear();
done.add(bb);
}
The processing loop can get a bit 'hairy' if you want to avoid copying data around too much, but this is the same in any language.
For comparison I whipped up a simple C version that did the same processing but with just the Linux read-ahead. The overall processing time (taking out java startup) is identical because - surprise surprise - the system is completely i/o bound. The Linux read-ahead is obviously quite aggressive too - which might not be so good if you're doing more random access.
The C version used 1/10th of the memory and about 1/4 of the CPU time ... but it had a better inner-loop, and the Java has a nice GUI as well. The C one only took about 20 minutes to write vs a few hours for Java - but I'm more familiar with C, and particularly writing this sort of stream processor to run efficiently in C.
Anyway it was an interesting diversion from my current work, and a good learning opportunity.
Another week down
Blah. Been a long week - got a bit caught up with hacking away so had some pretty late nights, and then early mornings from phone calls or visitors. Hmm.
Some friends are in town from OS next week so that should be nice, hopefully I catch up with them and their new twins. I'd been trying to call for the last few weeks - after not having seen them for about a year - and finally got through at some silly time on Saturday morning. We also tried the PS3 video phone application (alas, i upgraded my firmware in the end ...) which wasn't too bad - a bit like those old 'hello from space' videos, but a bit clearer and sometimes the framerate was very good. Audio delay was noticeable though. First time i'e used a video phone, and it's a bit weird talking to someone through a window in another lounge room (maybe all the stranger stranger for it being 8am in the morning after being up all night). Didn't know where to look.
We've just had some great weather and it's a pity it looks like they'll arrive on ANZAC day - which is typically the obvious start to winter, and it looks like this this year will be a typical year. After hibernating for a Chicago winter i'm sure the week of 25+ we just had would've been nice.
On the international traveller front it sounds like my sister has had enough of the ignorance and absurdity of the country, and sick of not being able to get decent work and is heading back from America fairly soon. She's only been away for a few years but she might get a bit of a shock to see how far down that path we have also gone. Even if she doesn't decide to stay long, I'm hoping she cleans up my 'other house' that's sat empty for a couple of years collecting dust anyway!
Speaking of ANZAC day - that's a pretty good example of how the nation has become a bit feral. How a total rout and a day meant to remember the utter stupidity of war got turned into a day of nationhood and the glorification of `fighting for ones country' i'll never know. I always thought it was about remembering the poor diggers who were mis-used as pawns in political games or by incompetent chains of command, and the 'least we forget' was about the stupidity of sending them in the first place, not the 'honour of their sacrifice' - typical right wing bullshit. Now it all seems to be about draping yourself in the flag (a flagrant violation of the honour of any nation's flag - and they didn't even fight under that flag anyway - it was all as British subjects) in a sort of quasi-national day and thinking of it as the day 'we grew up' - I can't really say if it was, but we surely have 'grown down' since if this is the thought of the common man these days.
Hello world
Well I integrated a timer interrupt into WoofƆs and got that to work eventually - the MMU makes things like this very fun as I have to map everything I need to use. A few silly bugs in the MMU code didn't help either.
After a 7 hour stint last night I finally booted up an executed a 'user process', including sending it the initial welcome message. It doesn't do much other than call a debug printf function to say hello, but given that it is running in it's own address space successfully that seems a reasonable achievement.
Interrupts are going to be a bit of a pain. Because I want user code to deal with interrupts the kernel has to clear the hardware interrupt status bits itself - which means it needs to know about all the devices that might produce interrupts and how to turn them off. I can't see any way around this right now. I also need some way of letting the user-code know what triggered the interrupt, which is another issue - even with 96 interrupts there is some double-up on the interrupt source. I guess there's always the mailbox idea, or a syscall to query it. There might be some hardware where the interrupt needs processing immediately too, but i'll come to that when I find it.
Hmm, next thing might be to think about devices and get a serial device working.
Copyright (C) 2019 Michael Zucchi, All Rights Reserved.
Powered by gcc & me!