Reorder how max thread count is computed

This simplifies better, and prevents over-conservative bounds.
A test which exercises most types in shared mem
Made the types test test a wider range of values
custom_do_par_for was not respected on osx

Bug popped up while testing opencl backend
Pass shared OpenCL memory as ulong instead of uchar

This should hopefully tell the OpenCL drivers that we want 64-bit alignment for shared.