- 博客(14)
- 收藏
- 关注
原创 vscode开发c/c++
下载vs code 创建空文件夹 随意创建一个hello.cpp文件 在调试中添加launch.json { // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": .
2021-09-01 19:07:08
290
原创 滑动窗口(双指针)
给你一个仅由大写英文字母组成的字符串,你可以将任意位置上的字符替换成另外的字符,总共可最多替换 k 次。在执行上述操作后,找到包含重复字母的最长子串的长度。 注意:字符串长度 和 k 不会超过 104。 示例 1: 输入:s = “ABAB”, k = 2 输出:4 解释:用两个’A’替换为两个’B’,反之亦然。 示例 2: 输入:s = “AABABBA”, k = 1 输出:4 解释: 将中间的一个’A’替换为’B’,字符串变为 “AABBBBA”。 子串 “BBBB” 有最长重复字母, 答案为 4。
2021-02-02 21:13:21
212
原创 mpi排序
思想 将一个较大的需要排序的数组,拆分成等大小的数据段,分配给不同的进程,利用归约排序算法的思想,将不同进程之间的数据进行排序,同时在规约中包含快排结合使用最大程度的加速程序的速度,最后将各个程序的内容发送到根进程中,完成输出。 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <mpi.h> #define length 10//0//0000 //快排的实现 void sw
2020-10-18 17:59:23
1547
2
原创 openmp和mpi的综合使用
openmp和mpi的综合使用 #include "mpi.h" #include "omp.h" #include <math.h> #include<stdio.h> #define N 1000000000 int main(int argc, char* argv[]) { int rank, nproc; int i, low, up; double local = 0.0, pi, w, temp; MPI_Status status; MPI_Init(
2020-09-20 15:47:10
815
2
原创 mpi程序实例
求Π值 #include "stdio.h" #include "mpi.h" #include<math.h> #include "stdlib.h" double f(double); double f(double x) { return (4.0 / (1.0 + x * x)); } int main(int argc, char** argv) { int done = 0, n, myid, numprocs, i; double PI25DT = 3.14159265358
2020-09-18 10:52:32
853
原创 cuda卷积
一D卷积 #include<cuda_runtime.h> #include<device_launch_parameters.h> #include<iostream> using namespace std; __global__ void juan(int* a, int* b, int* c, int m, int n) { int id = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0; int k
2020-09-15 20:17:19
823
原创 cuda矩阵相乘(优化)
原始 #include<cuda_runtime.h> #include<device_launch_parameters.h> #include<iostream> using namespace std; __global__ void jia(int a[2][2], int b[2][2], int c[2][2],int n) { int idx = threadIdx.x + blockIdx.x * blockDim.x; int idy
2020-09-15 18:54:12
674
原创 phread学习
共享内存编程 进程通过共享内存空间相互通信或协同工作,所有进程都可以访问该共享内存空间,比传递消息更快更高效 pthread posix标准指定用于跨unix系统的可移植性 pthread是现成posix标准的实现 创建pthread pthread_create(thread,attr,routine,arg) thread:新线程的唯一标识符 attr:用于设置线程属性。默认值为NULL routine:创建线程后将执行的C例程。 arg:可以传递给start_routine的单个参数 。它必须作为空
2020-09-14 15:43:43
461
原创 cuda简单内积算法
#include<cuda_runtime_api.h> #include<cuda_runtime.h> #include<device_launch_parameters.h> #include<iostream> #include<Windows.h> #include<time.h> #include<math.h> #include<device_functions.h> using namespace
2020-09-13 17:14:56
239
原创 cuda学习
什么是cuda cuda是带有并行内核的串行代码,全部由c/c++编写,串行代码在host端串行执行,并行内核代码在device短的多线程中执行。 cuda是用于在英伟达gpu上编程的编译器和工具 支持gpu的异构计算 cuda API扩展了c/c++编程语言 快速SIMD并行性 从硬件上提供了高级别的抽象 cuda编程流程 从host端将数据拷贝到device端 呼叫gpu告诉gpu启动 在gpu上运行计算 将计算完后的device上的数据拷贝到host端 kernel是CUDA中一个重要的概念
2020-09-11 20:08:56
941
原创 openmp学习
OpenMP是一个支持共享存储并行设计的库,特别适宜多核CPU上的并行程序设计 语法 openmp指令 parallel,用在一个代码段之前,表示这段代码将被多个线程并行执行 for,用于for循环之前,将循环分配到多个线程中并行执行,必须保证每次循环之间无相关性。 parallel for,用在一个for循环之前,表示for循环的代码将被多个线程并行执行。 sections,用在可能会被并行执行的代码段之前 parallel sections,parallel和sections两个语句的结合 critic
2020-09-10 21:03:11
382
原创 java图书管理系统
主函数 public class book { public static void main(String[] args) { System.out.println("hello"); pai begin=new pai(); begin.caiDan(); } } 图书类 public class BookMjr { public String[] name=new String[1000]; public int[]
2020-09-10 17:00:38
263
原创 mpi学习记录
mpi简介 mpi是一个库,不是一个语言,可以在FORTRAN和C的基础上进行开发,他遵守对库函数的调用规则 mpi是一个标准的规范,一个正确的mpi函数可以在任何一台并行机上运行 mpi是一种消息传递编程模型,其最终目的是服务于进程间通信这一目的 mpi函数调用 MPI_Init(&argc,&argv)是MPI程序的第一个调用,初始化MPI执行环境。必须在每个MPI程序中调用此函数,必须在任何其他MPI函数之前调用此函数,并且在MPI程序中只能调用一次。对于C程序,MPI_Init可以用于将命令行
2020-09-09 21:25:31
1607
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅