670 karma · joined May 12, 2010
It must be nice living a world where energy is free, you have unlimited cores and unbounded caches, and context switches, thread synchronisation and cache coherence have no cost or latency.
I'm not saying that reducing the number of cases with undefined behaviour isn't worth it in most cases, but claiming that you can just zero application memory at virtually no cost on a multicore is misguided.
Instruction set extensions (which I believe might be what you were thinking of) are used via intrinsics and assembly programming by pretty much any performance-oriented code. For example look at the dozens of architecture-specific implementations of glibc functions: x86-64[0], arm[1].
[0] https://sourceware.org/git/?p=glibc.git;a=tree;f=sysdeps/x86... [1] https://sourceware.org/git/?p=glibc.git;a=tree;f=sysdeps/arm...
It's a pretty cool proof-of-concept, but I wouldn't connect anything to the USB port. These issues could be solved for deployment by potting or by using a custom smaller PCB integrating the various boards.
* probably a violation of the EULA
I've added XV support[0] for video resizing and colorspace conversion, after which mplayer compiled with NEON support and with multithreading could decode in software pretty much any video I've thrown at it.
Things could have significantly improved since then, but I've been out of the loop.
However, I would strongly recommend just going for a Jetson-TK1 - I happen to be posting this from one. You get a fairly comprehensive reference manual and NVIDIA fully supports GNU/Linux (albeit with proprietary Xorg drivers at the time), the ARM cores (Cortex-A15 @ 2.3GHz) are much faster, the GPU supports full OpenGL (as opposed to OpenGL ES) and NVIDIA and the community are working on a fully open source driver stack (with nouveau).
[0] https://github.com/lgeek/xf86-video-fbturbo - very much abandoned alpha-quality software
I've seen this claim repeated a few times in the thread and I still have no idea what it means.
For medium levels of optimisation it's usually very simple to predict what assembly code will be generated by C compilers. On many platforms the operators often match directly to a instruction (e.g. arithmetic and bitwise operations) or short patterns of instructions (the control flow primitives and conditional execution, equality testing, function calling, etc). At a higher level, compiled C functions look pretty much exactly like manually written assembly language procedures and structs are just blocks of memory with clear order and offsets. It's also very simple to interface C and assembly code without any hacks on either side.
It's a bit of a weird exercise, you'd generally just calculate the maximum space used by the algorithm, maybe account for stack frame size if recursion is used.
Yes, that's spaghetti code. In general I strongly recommended to write assembly functions which follow the platform's ABI (I'm a TA for a course using assembly programming). At the very least, function calls and returning values should be consistent and function calls shouldn't have this kind of side effects. In this case
* calculateStrLength effectively leaks stack space because it pushes the input string and doesn't balance the stack before returning - this is why the return value is passed using rdi. At least the return value pushed by call could have been preserved in calculateStrLength itself. It also increments the size counter without resetting it (it's reset to 0 in _start) which is a bit of a weird choice.
* then reverseStr (which is not a function but just a label in _start) pops the string off the stack and copies it to the OUTPUT buffer (but doesn't copy an end of string NULL character - which works because the buffer is in the bss section, but it's not a good practice). The return address pushed by the call to calculateStrLength is left on the stack.
The whole thing is designed pretty weirdly because reversing a string is trivial to do in place (or with just an input and output buffer), there's no need to use the stack.
Maybe there are other causes as well.
> Would it be possible to determine ahead of time what order would maximize performance, or would that require profiling?
I think at the very least, you'd need profiling to determine the hot code path, and that can change depending on input...
* improved cache locality
* reduced false sharing
* use of multiple arenas for reduced lock contention
[O] http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemall...
You can also think about it as a sort of reductio ad absurdum: Assume that the array is actually already sorted and you use a sorting algorithm with O(n) complexity for already sorted data. In this ideal case you'd need to do n (for sorting) + log n (binary search) predictable operations. For linear search you'd only need to n operations of the same type. In practice you'd need to do n log n operations for sorting, I don't think you can avoid unpredictable branches, and instead of just loading elements sometimes you'll move them around.
The source code used to build the kernel for ChromeOS should be available so I'm surprised this sort of thing is a problem.
Not really. Many low end to mid range devices use Allwinner, Rockchip, MediaTek or Amlogic SoCs. NVIDIA's Tegra series has also been somewhat popular and the two K1 SoCs are really nice.