Howdy,
Yes there is a difference between those two submissions. You are correct that usually ntasks is for mpi and cpus-per-task is for multithreading, but let’s look at your commands.
For your first example, the “sbatch --ntasks 24 […]”, this will allocated a job with 24 tasks. These tasks in this case are only 1 CPUs, but may be split across multiple nodes. So you get a total of 24 CPUs across multiple nodes.
For your second example, the “sbatch --ntasks 1 --cpus-per-task 24 [...]”, this will allocated a job with 1 task and 24 CPUs for that task. So you will get a total of 24 CPUs on a single node.
So in other words, a task cannot be split across multiple nodes. So using --cpus-per-task will ensure it gets allocated to the same node, while using --ntasks can and may allocate it to multiple nodes.
Hope this helps.
Matthew