if文で遅くなる? GPU のコードは if 文を避けるべき、ということはなんとなく知っていたので実験した。 __kernel void test_if(__global float* out, int mode) { int id = get_global_id(0); float x = (float)id; if (mode == 0) { // 発散なし(全員同じ経路) for (int i = 0; i < 2000000; i++) { x = x * 1.000001f + 0.000001f; } } else { // 発散あり(8 分岐) int branch = id &…