In the ElGamal cipher, the key generation algorithm needs to randomly sample a generator g and test whether g is a safe generator or not each time. I wonder whether we can use a fixed safe generator for all users, which may reduce the time of key generation. Will this be safe?
The generator $g$ is always assumed to be public and does not need to be generated as part of the KeyGen. Specifically, the whole Diffie-Hellman group description (which includes $g$) can fixed. For example, see https://en.wikipedia.org/wiki/ElGamal_encryption#Key_generation