Just a quick answer with some approaches sketched. From athe theoretical point of view: there is a Jordan-like canonical form for pairs of Hermitian matrices $(A,B)$ under the equivalence relation $(A,B) \sim (PAP^T, PBP^T)$ (with a nonsingular $P$), I would start from consideringsee https://www.sciencedirect.com/science/article/pii/0024379576900215 . This is known today in my area as "(a variant of) the even Kronecker canonical form (seeform"; see e.g. my paper https://doi.org/10.1137/120861679 forwhich contains a self-contained statement for Hermitian-anti-Hermitian (which is the same up to multiplication by $i$ of one of them), which.
It is essentiallyeasy to check that only a few of these blocks can be used to produce positive semidefinite $A$ and $B$: if I am not wrong, if $A,B$ are spd then you can only get in the canonical form for pencils of Hermitian matricessize-1 blocks corresponding to purely real eigenvalues (E2), size-1 blocks corresponding to infinite eigenvalues (E3), and check whichsize-1 singular blocks correspond(E4, corresponding to semidefinitecommon kernel of the two matrices). ThisAll these blocks are size-1: in particular, this means that this decomposition will giveproduce diagonal $PAP^T,PBP^T$, and hence it is the decomposition that you at least an existence proofwant. From a numerical point of viewI.e., at least when the problem is nonsingular and does not have multiple eigenvalues atform that you ask for exists for all pairs $\infty$$(A,B)$, and you can reduceobtain it even if you restrict to the case in whichtransformations with $B = \operatorname{diag}(I,0)$$Q=P^T$ (which is nice, since they preserve symmetry and then I think thatdefiniteness).
Numerically, you can first identify the finite eigenvaluescommon kernel of $\begin{bmatrix}A_{11}-zI & A_{12} \\ A_{21} & A_{22}\end{bmatrix}$ are$A$ and $B$ and then change basis to put it in evidence, to reduce the ones ofproblem to
$$
\begin{bmatrix}A_{11} & 0\\ 0 & 0\end{bmatrix}, \begin{bmatrix}B_{11} & 0\\ 0 & 0\end{bmatrix}
$$
and then apply a generalized eigensolver $A_{11} - A_{12}A_{22}^{-1}A_{21}$(e.g., Matlab's eig(A11, B11)
) to $A_{11}$ and $B_{11}$, which is now a nonsingular problem (i.e., $\det(A+Bz)$ is not identically zero) in view of the previous discussion.