ICS-E4020: Frequently asked questions

Rules Debugging Tools Computers Forums

Grading of the course

What if I miss one week?

If you have medical reasons, etc.: get a doctor’s certificate and contact the lecturer for a deadline extension.

If you are just busy, travelling, etc., you can use any combination of the following options:

Note that you cannot return anything after the end of week 6. If you know you will miss week 6, plan ahead.

Debugging your code

Strange bugs, segmentation faults, etc.?

First try the AddressSanitizer: run make clean and make DEBUG=2, see README.md for more details.

Still unexplained segmentation faults?

It might be a stack overflow. Unfortunately, a stack overflow is typically reported as a segmentation fault. In the classroom computers, the stack size limit is approx. 8MB. Do not allocate large arrays on the stack. If you need to allocate storage for megabytes of data, use the heap.

Different behaviour with vs. without make?

It might be a stack overflow. Make accidentally changes the stack size limits so you might see a stack overflow (segmentation fault) when you run your code directly, yet it might work fine if you run it with make.

Random results? Strange results?

Remember to initialise all memory. Do not assume that e.g. malloc initialises newly allocated memory. Zero it explicitly if needed.

Poor performance, strange benchmarks?

Make sure there is no other load on the machine that you use for benchmarking. Try uptime and top to see what is the current load and who is running what there. See finding a computer with a low load.

My CUDA code does not seem to work at all?

Check for errors. Wrap all CUDA API calls in error-checking macros, and also check for errors after each kernel launch. For example, you can define a macro like this:

    #define CHECK_CUDA_ERROR(call) do { \
        cudaError_t result_ = (call); \
        if (result_ != cudaSuccess) { \
            fprintf(stderr, #call " failed: %s\n", \
                    cudaGetErrorString(result_)); \
            exit(1); \
        } \
    } while(0)

And use it like this:

    CHECK_CUDA_ERROR(cudaMalloc((void**)&x, n));
    CHECK_CUDA_ERROR(cudaMalloc((void**)&y, n));
    kernel<<<dimGrid, dimBlock>>>(params);

Problems with tools

AddressSanitizer says “failed to allocate…”

It needs lots of virtual memory: check with ulimit -v that you do not have any restrictions in place.

Valgrind says “illegal hardware instruction”

Compile with make ARCH=1, see README.md for more details.

GDB does not find any symbols

It is due to a combination of a new GCC and old GDB. Replace “-g” with “-g -gdwarf-3” in the definition of CXXFLAGS in common/Makefile.common.


Can I use Windows?

You are free to use any computer during the development, but we do not provide any support for that. The code templates, Makefiles, and scripts are tested on Linux and Mac OS X, and some extra effort may be needed to port it to Windows.

The final solution that you return has to work on the classroom computers. Please note that you can access the computers remotely via ssh.

Finding a computer with a low load for benchmarking

To quickly check the load of another machine, use the command ssh MACHINE uptime.

The following shell command might be helpful (just paste it to a terminal in e.g. kosh.aalto.fi):

for a in albatrossi broileri dodo drontti emu fasaani flamingo iibis kakadu kalkkuna karakara kasuaari kiuru kiwi kolibri kondori kookaburra koskelo kuukkeli lunni moa pelikaani pitohui pulu ruokki siira strutsi suula tavi tukaani undulaatti; do printf "%-15s " $a; ssh $a uptime; done

Support forums

How can I use Gitter with IRC?

With Irssi:

  1. Using your web browser, open https://irc.gitter.im/ and log in with your Github account.
  2. Save the token the page gives you.
  3. In Irssi, add the gitter server using the following command, replacing TOKEN with the token you got: /server add -ssl irc.gitter.im 6697 TOKEN
  4. Connect: /connect irc.gitter.im
  5. Join the channel: /join #ICS-E4020/discussion