Yes, as long as you stay under GCD's max thread limit (64 on macOS in my tests) you should be fine in terms of no deadlock.
There are OS-specific APIs to query the number of CPU cores. On macOS you can do it like this (APIs on Linux etc. will probably be different):
import Darwin
var size: size_t = 4
var cpuCount: Int32 = 0
let result = sysctlbyname("hw.logicalcpu", &cpuCount, &size, nil, 0)
if result == 0 {
print(cpuCount) // prints 10 on my machine (Apple M1 Pro)
}
Look at the sysctl(3) man page for more info.