Wavefront: coNCePTuaL vs. C
Why you should write network performance tests in coNCePTuaL

Many people's initial reaction to coNCePTuaL is that the English-like syntax is excessively verbose and makes a coNCePTuaL program longer and more tedious to type than the corresponding C program. In fact, because coNCePTuaL has richer, higher-level semantics than C, a coNCePTuaL program is typically much shorter than its C counterpart. Let's consider the core of the wavefront program, the part that performs all of the communication operations:

all tasks src send a msgsize-byte message to tasks dst such that dst = src+xdim \/ (dst=src+1 /\ dst mod xdim <> 0) then
task num_tasks-1 sends a msgsize-byte message to task 0

When expressed in C and using MPI as the communication library the preceding code looks like this:

if (dst%xdim != 0)
  MPI_Recv (m, msgsize, MPI_BYTE, dst-1, 1, MPI_COMM_WORLD, &s);
if (dst >= xdim)
  MPI_Recv (m, msgsize, MPI_BYTE, dst-xdim, 1, MPI_COMM_WORLD, &s);
if ((src+1)%xdim != 0)
  MPI_Send (m, msgsize, MPI_BYTE, src+1, 1, MPI_COMM_WORLD);
if (src < num_tasks-xdim)
  MPI_Send (m, msgsize, MPI_BYTE, src+xdim, 1, MPI_COMM_WORLD);
if (dst == 0)
  MPI_Recv (m, msgsize, MPI_BYTE, num_tasks-1, 1, MPI_COMM_WORLD, &s);
  if (src == num_tasks-1)
    MPI_Send (m, msgsize, MPI_BYTE, 0, 1, MPI_COMM_WORLD);

…and that doesn't even include all of the variable declarations and initializations! Unlike the coNCePTuaL code, the C code has to explicitly post a matching receive for every send; and, it has to ensure that it neither sends to nor receives from a nonexistent task.

Which requires less typing? To be fair to C, let's compare versions of those two code excerpts with all unnecessary spaces removed:

all tasks src send a msgsize-byte message to tasks dst such that dst=src+xdim\/(dst=src+1/\dst mod xdim<>0) then task num_tasks-1sends a msgsize-byte message to task 0


if(dst%xdim!=0)MPI_Recv(m,msgsize,MPI_BYTE,dst-1,1,MPI_COMM_WORLD,&s);if(dst>=xdim)MPI_Recv(m,msgsize,MPI_BYTE,dst-xdim,1,MPI_COMM_WORLD,&s);if((src+1)%xdim!=0)MPI_Send(m,msgsize,MPI_BYTE,src+1,1,MPI_COMM_WORLD);if(src<num_tasks-xdim)MPI_Send(m,msgsize,MPI_BYTE,src+xdim,1,MPI_COMM_WORLD);if(dst==0)MPI_Recv(m,msgsize,MPI_BYTE,num_tasks-1,1,MPI_COMM_WORLD,&s);else if(src==num_tasks-1)MPI_Send(m,msgsize,MPI_BYTE,0,1,MPI_COMM_WORLD);

(If you make your browser window really, really wide or make the font size really, really small the C code will appear as a single line that contains only one space, between else and if.)

Let's see which language requires less code to express a wavefront communication pattern:

Wavefront code written in C and coNCePTuaL
Metric C coNCePTuaL
Statements 6 2
Tokens 158 45
Characters 432 170

And the winner in all categories is…coNCePTuaL! In case you're still not convinced, take a look at the complete wavefront program written in C. C requires the programmer to include header files, declare variables, allocate memory, compute performance statistics, and include various other bits and pieces of code. None of these requires much code by itself but they add up to a total program length much greater than the equivalent coNCePTuaL program.

Remember, though, that coNCePTuaL is a domain-specific language. It's designed to reduce the effort of writing robust, portable tests of network performance. However, that's all that coNCePTuaL does; hence, you shouldn't think of it as a replacement for a general-purpose language like C but rather as a useful complement to it.

As an aside, coNCePTuaL provides some limited support for executing non-coNCePTuaL code. If you're using a C-based compiler backend (such as the C+MPI backend) this means that you can include C statements within a coNCePTuaL program as follows:

All tasks me backend execute "printf(\"Task %d has PID %d.\\\n\", (int)" and me and ", getpid());"


  1. Communication performance tests written in coNCePTuaL are significantly shorter than the equivalent test written in C.
  2. coNCePTuaL's English-like syntax, which aids program readability, can't be criticized for being more verbose than C's symbol-heavy syntax.
  3. The key to coNCePTuaL's terseness is that the language is domain-specific. All of the idioms and constructs it provides were created specifically to simplify writing communication performance tests.
Scott Pakin, pakin@lanl.gov