You need to know the local size. And thankfully you can get it by calling get_local_size. It will always return a valid value.
It goes like this assuming no offset:
get_global_id(0) = get_local_id(0)+get_local_size(0)*get_group_id(0)
Remember that even if you call your kernel with NULL as the local size the implementation will make something up so that you will always get valid values.