- 博客(23)
- 资源 (215)
- 问答 (3)
- 收藏
- 关注
原创 OpenMP变量的私有与共享
#include #include #ifdef _OPENMP#include #endifint gval = 8;//gval是共享的void funcb(int *x, int *y, int z)//z是线程私有,z-i{ static int sv;//静态变量,共享的,在内存中只有一份,所以会引起冲突 int u;//自变量,线程私有的 u = (*y)*gv
2017-11-30 22:18:23 4165 4
转载 C语言进程的内存地址空间分配
图为一个执行进程的内存地址空间。代码段就是存储程序文本的,所以有时候也叫做文本段,指令指针中的指令就是从这里取得。数据段是存储数据用的,还可以分成初始化为非零的数据区,BSS,和堆(Heap)三个区域。初始化非零数据区域一般存放静态非零数据和全局的非零数据。BSS是Block Started by Symbol的缩写,原本是汇编语言中的术语。该区域主要存放未初始化的全局数据和静态数据。还有就是
2017-11-30 21:12:04 2731
原创 C语言auto、register、static、extern关键字
1.auto#include#include#includeint a = 0;void show(){ a++; printf("hello: %d\n",a);}void main(int *argv, char *args[]){ show();/**Auto变量:局部变量不作任何说明,都作为自动变量auto,及动态存储的。Auto可省略
2017-11-30 20:23:17 664
原创 C语言二维数组Array[][]
#include#include#include#includeint main(int argc, char*argv[]){ int a[5][3]={ {1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15} }; int b[5][3]={ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
2017-11-30 20:11:33 565
原创 C语言预处理#line、#error
#line 的作用是改变当前行数和文件名称,它们是在编译程序中预先定义的标识符命令的基本形式如下:#line number["filename"]其中[]内的文件名可以省略。例如:#line 30 a.h //其中,文件名a.h 可以省略不写。这条指令可以改变当前的行号和文件名,例如上面的这条预处理指令就可以改变当前的行号为30,文件名是a.h。初看起来似乎没有什么用,不过,他还是有点用的
2017-11-30 20:06:49 525 1
原创 C语言预处理#pragma
1.#pragma message如果已经宏定义的PI,/**#pragma message(): 在编译信息输出窗口中输出相应的信息 * 这对于源代码信息的控制是非常重要的*/#ifdef PI#pragma message("Already define PI.")#endif编译的时候就会出现:-bash-4.1$ gcc -o
2017-11-30 20:01:21 877 1
原创 Linux查看显示编辑文本文件
1.cat-bash-4.1$ cat --help用法:cat [选项]... [文件]...将[文件]或标准输入组合输出到标准输出。 -A, --show-all 等于-vET -b, --number-nonblank 对非空输出行编号 -e 等于-vE -E, --show-ends
2017-11-29 21:31:28 3131
原创 C语言函数指针&命令行参数
我们可以用函数指针实现多态等高端函数,再加上命令行参数让你的程序提高一个档次。程序如下:#include#include#include#includeint f1(int a){ printf("f1:%d\n",a); return a;}int f2(int a){ printf("f2:%d\n",a); return a*a;
2017-11-29 20:16:06 524
转载 CUDA:对齐内存访问、展开循环提高运算性能
#include "../common/common.h"#include #include /* * This example demonstrates the impact of misaligned reads on performance by * forcing misaligned reads to occur on a float*. Kernels that reduc
2017-11-29 19:46:05 2851
转载 结构体数组(SoA)与数组结构体(AoS)
1.结构体数组(SoA)/* * SoA 结构体数组定义 */struct InnerArray{ float x[LEN]; float y[LEN];};/* * CPU -> SoA 结构体数组的CPU计算形式 */void testInnerArrayHost(InnerArray *A, InnerArray *C, const int n){
2017-11-29 19:32:22 7719 4
原创 CUDA零拷贝内存(zerocopy memory)
为了实现CPU与GPU内存的共享,cuda采用了零拷贝内存,它值固定内存的一种,当然,也就是实际存储空间实在cpu上。零拷贝内存的延迟高,在进行频繁的读写操作时尽量少用,否则会大大降低性能。/* *创建固定内存映射 * * flags: cudaHostAllocDefault: make cudaHostAlloc same as "cudaMallocHost"
2017-11-29 16:07:25 6699
原创 CUDA全局变量(__device__)的初始化与使用:cudaMemoryToSymbol、cudaMemoryFromSymbol、cudaGetSymbolAddress
在cuda中在设备(device)中声明一个全局变量用__device__关键字修饰:__device__ float devData;初始化为:float value = 3.14f;cudaMemcpyToSymbol(devData, &value, sizeof(float));在使用结束后,将其转回host:cudaMemcpyFromSymbol(&value, de
2017-11-29 14:24:38 13300 1
转载 CUDA:在GPU上实现核函数的嵌套以及编译运行
#include "../common/common.h"#include #include /* * A simple example of nested kernel launches from the GPU. Each thread displays * its information when execution begins, and also diagnostics wh
2017-11-28 21:59:01 3790 6
原创 CUDA:一维、二维的grid、block的核函数线程分配
1.一维grid,一维block int nx = 1 << 14; int ny = 1 << 14; int dimx = 32; dim3 block(dimx, 1); dim3 grid((nx + block.x - 1) / block.x, 1);核函数__global__ void kernel_function(){
2017-11-28 17:00:02 3224
原创 CUDA:使用nvprof工具计时
CUDA在运行程序时加上nvprof会对程序进行性能分析,这种性能分析最重要的就是统计不同函数的运行时间(占比)。-bash-4.1$ nvprof ./a./a Starting...==19114== NVPROF is profiling process 19114, command: ./aVector size 32Execution configure >>Arrays
2017-11-28 16:24:50 5687 2
转载 用CPU计时器统计CUDA核函数的运行时间
该源程序来自《CUDA C语言编程中文译文版》,如有侵权,联系删除。此处只为学习交流。cuda程序如下:#include "../common/common.h"#include #include /* * This example demonstrates a simple vector sum on the GPU and on the host. * sumArraysO
2017-11-28 16:18:18 2806
原创 CUDA线程分配<<<>>>
在cuda中,blockDim表示一个块中线程的维度信息,例如blockDim(2,1,1)代表一个块中有2个thread,gridDim表示一个网格中块的维度。下面给出一个示例程序,这个程序来自CUDA C语言编程中文译本,如有侵权,联系删除。#include "../common/common.h"#include #include /* * Display the dime
2017-11-28 15:30:15 2076 2
转载 MPI_Send和MPI_Recv(初识1)
/** * * * @Copyright Du Zhihui :edited * Li Sanli :review * Chen Yu Liu Peng :proofreading * * Rong
2017-11-24 12:21:49 2636 2
转载 MPI_Get_processor_name,MPI_Get_version
/** * * * @Copyright Du Zhihui :edited * Li Sanli :review * Chen Yu Liu Peng :proofreading * * Rong
2017-11-24 12:05:52 2577 1
转载 OpenMP、MPICH与OpenMPI
原文网址openmp比较简单,修改现有的大段代码也容易。基本上openmp只要在已有程序基础上根据需要加并行语句即可。而mpi有时甚至需要从基本设计思路上重写整个程序,调试也困难得多,涉及到局域网通信这一不确定的因素。不过,openmp虽然简单却只能用于单机多CPU/多核并行,mpi才是用于多主机超级计算机集群的强悍工具,当然复杂。(1)MPI=message passing
2017-11-24 12:01:37 12219
原创 C语言extern用法
1.用extern修饰变量#include#include#includevoid show();void main(int *argv, char *args[]){ show(); printf("num = %d\n",num);}const int num = 3;void show(){ printf("num = %d\n",num)
2017-11-22 15:07:00 4931
原创 C语言局部变量、全局变量、静态局部变量、静态全局变量
建立三个文件,文件名分别为main.c \ head1.c \ head2.cmain.c#include#include#includeint A;void show(){ volatile static int a ;//静态局部变量(static) 静态局部变量定义时前面加static关键字。 a++; f1(a); f2(a);
2017-11-21 22:21:01 490
C语言设计模式 PDF《C Design Pattern》
2024-04-17
C, GNUC GCC 预处理《The C Preprocessor》
2024-04-16
User Guide: Open Build Service
2022-05-13
CentOS Stream 9 nasm 安装包
2022-05-01
CentOS Stream 9 nasm 源码包
2022-05-01
Optimizing Linux Kernel with BOLT.pdf
2022-01-21
red_hat_enterprise_linux-8-customizing_anaconda-en-us.pdf
2022-01-18
cclinux-coreos-34.20211111.3.0-live.x86_64.iso
2021-11-11
Ftrace Kernel Hooks-More than just tracing.pdf
2021-10-22
cpumemory-What Every Programmer Should Know About Memory.pdf
2021-09-10
architecture-instruction-set-extensions-programming-reference
2021-09-10
System V Application Binary Interface - AMD64 Architecture
2021-09-10
Hidden Linux Metrics with Prometheus eBPF Exporter.pdf
2021-09-03
e2ap-v01.00.00.asn
2021-08-25
Intel 64 and IA-32 Architectures Software Developer’s Manual Combined
2021-07-07
谈谈你对Container Linux容器操作系统的理解
2021-11-14
Linux“实时补丁”导致CPU无法占满运行
2021-02-22
C语言如何将字符串“int”转化为int类型
2019-01-09
TA创建的收藏夹 TA关注的收藏夹
TA关注的人