1. A method for optimizing a barrier comprising: determining, by a compiler, that a call to a named barrier is matched across all of a plurality of threads; and based at least in part on determining that the call to the named barrier is matched across all of the plurality of threads, replacing, by the compiler, the named barrier with an unnamed barrier.