Giter Site home page Giter Site logo

bokesyo / csc4005_2022fall_demo Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 10.0 12.89 MB

Official demo repo of CSC4005 Parallel Programming 2022 Fall @ CUHK(Shenzhen)

License: MIT License

C++ 58.42% Shell 6.36% C 0.32% Makefile 3.83% Cuda 18.36% Sass 12.71%

csc4005_2022fall_demo's People

Contributors

bokesyo avatar lyzx2001 avatar mwg2023 avatar tonyyxliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

csc4005_2022fall_demo's Issues

Wrong cuda API invoke

Code below is refered in template of project3:

cudaMalloc(&device_m, n_body);
cudaMalloc(&device_x, n_body);
cudaMalloc(&device_y, n_body);
cudaMalloc(&device_vx, n_body);
cudaMalloc(&device_vy, n_body);

cudaMemcpy(device_m, m, n_body, cudaMemcpyHostToDevice);
cudaMemcpy(device_x, x, n_body, cudaMemcpyHostToDevice);
cudaMemcpy(device_y, y, n_body, cudaMemcpyHostToDevice);
cudaMemcpy(device_vx, vx, n_body, cudaMemcpyHostToDevice);
cudaMemcpy(device_vy, vy, n_body, cudaMemcpyHostToDevice);

However, the invoke of cudaMalloc API seems to be wrong. As the official documentation of cuda says:
image

The parameter here should be in bytes.

Thus, the API should be invoked as:

cudaMalloc(&device_m, n_body * sizeof(double));
cudaMalloc(&device_x, n_body * sizeof(double));
cudaMalloc(&device_y, n_body * sizeof(double));
cudaMalloc(&device_vx, n_body * sizeof(double));
cudaMalloc(&device_vy, n_body * sizeof(double));

cudaMemcpy(device_m, m, n_body * sizeof(double), cudaMemcpyHostToDevice);
cudaMemcpy(device_x, x, n_body * sizeof(double), cudaMemcpyHostToDevice);
cudaMemcpy(device_y, y, n_body * sizeof(double), cudaMemcpyHostToDevice);
cudaMemcpy(device_vx, vx, n_body * sizeof(double), cudaMemcpyHostToDevice);
cudaMemcpy(device_vy, vy, n_body * sizeof(double), cudaMemcpyHostToDevice);

This is a prboblem of template, so I am afraid it might affect a lot of students, as I have already wasted much time finding this bug. Please quickly correct them. @bokesyo

advice: reinstall nvidia driver

__glapi_tls_current has been introduced since 2013.
NVIDIA/libglvnd@efa8ca1
Different commits may have different ABIs, which are not compatible.
It's likely that centos pack the cuda and libglvnd-dev with different commits. A simple reinstallation of cuda with --install-libglvnd will likely to solve this.
https://download.nvidia.com/XFree86/Linux-x86_64/450.80.02/README/installedcomponents.html
Installation guide using the cuda repo:
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#redhat-installation
This is just a guess; hope it will be useful.

[WSL | Project 2] gcc compile mpi.cpp with gui generate linking error for glut

I compiled on WSL1 of Windows 10 and have already settled X server to solve the gui issues.

When compiling mpi.cpp with gui, linking error will be reported as following:

$ mpic++ -I/usr/include -L/usr/local/lib -L/usr/lib -lglut -lGLU -lGL -lm mpi.cpp -o mpig -DGUI -std=c++11
/usr/bin/ld: /tmp/cc9iyyF6.o: in function `plot()':
mpi.cpp:(.text+0x242): undefined reference to `glClear'
/usr/bin/ld: mpi.cpp:(.text+0x253): undefined reference to `glColor3f'
/usr/bin/ld: mpi.cpp:(.text+0x26c): undefined reference to `glPointSize'
/usr/bin/ld: mpi.cpp:(.text+0x276): undefined reference to `glBegin'
/usr/bin/ld: mpi.cpp:(.text+0x280): undefined reference to `glClear'
/usr/bin/ld: mpi.cpp:(.text+0x2ea): undefined reference to `glColor3f'
/usr/bin/ld: mpi.cpp:(.text+0x304): undefined reference to `glVertex2f'
/usr/bin/ld: mpi.cpp:(.text+0x314): undefined reference to `glEnd'
/usr/bin/ld: mpi.cpp:(.text+0x319): undefined reference to `glFlush'
/usr/bin/ld: /tmp/cc9iyyF6.o: in function `main':
mpi.cpp:(.text+0x3e8): undefined reference to `glutInit'
/usr/bin/ld: mpi.cpp:(.text+0x3f2): undefined reference to `glutInitDisplayMode'
/usr/bin/ld: mpi.cpp:(.text+0x401): undefined reference to `glutInitWindowSize'
/usr/bin/ld: mpi.cpp:(.text+0x410): undefined reference to `glutInitWindowPosition'
/usr/bin/ld: mpi.cpp:(.text+0x41c): undefined reference to `glutCreateWindow'
/usr/bin/ld: mpi.cpp:(.text+0x441): undefined reference to `glClearColor'
/usr/bin/ld: mpi.cpp:(.text+0x44b): undefined reference to `glMatrixMode'
/usr/bin/ld: mpi.cpp:(.text+0x474): undefined reference to `gluOrtho2D'
/usr/bin/ld: mpi.cpp:(.text+0x480): undefined reference to `glutDisplayFunc'
/usr/bin/ld: mpi.cpp:(.text+0x5b6): undefined reference to `glutMainLoop'
collect2: error: ld returned 1 exit status

I have checked that all dependencies had been installed.

I solved this problem with the help of this post.

The GCC linker may scan libraries in the order they are on the command line, which means for you it may scan the libraries first and sees no one using them, and therefore you get the errors.

Therefore, I solved this problem by running mpic++ -I/usr/include -L/usr/local/lib -L/usr/lib mpi.cpp -o mpig -DGUI -std=c++11 -lglut -lGLU -lGL -lm instead. Hope this issue can help other people working with WSL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.