bokesyo / csc4005_2022fall_demo Goto Github PK
View Code? Open in Web Editor NEWOfficial demo repo of CSC4005 Parallel Programming 2022 Fall @ CUHK(Shenzhen)
License: MIT License
Official demo repo of CSC4005 Parallel Programming 2022 Fall @ CUHK(Shenzhen)
License: MIT License
I notice that in assignment 3, all heap memory deallocation was used delete
but not delete[]
. I think maybe we should use delete[]
to deallocate the array?
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:
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
__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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.