我在这里有 这个代码(由于答案而修改)。
信息
32 字节堆栈帧,0 字节溢出存储,0 字节溢出加载
ptxas 信息:使用了 46 个寄存器,120 字节 cmem[0],176 字节 cmem[2],76 字节 cmem[16]
我不知道还需要考虑什么才能使其适用于点“numPointsRs”和“numPointsRp”的不同组合
例如,当我使用 Rs=10000 和 Rp=100000 运行代码时,块=(128,1,1),grid=(200,1) 很好。
我的计算:
46 个寄存器*128 个线程=5888 个寄存器。
我的卡有限制 32768 个寄存器,所以 32768/5888=5 +一些 => 5 块/SM
(我的卡有限制 6)。使用占用计算器,我发现使用 128 个线程/块给了我 42% 并且在我的卡的限制中。
此外,每个 MP 的线程数为 640(限制为 1536)
现在,如果我尝试使用 Rs=100000 和 Rp=100000(对于相同的线程和块),它会给我标题中的消息,其中:
cuEventDestroy 失败:启动超时
cuModuleUnload 失败:启动超时
1)我不知道/不明白还需要计算什么。
2)我无法理解我们如何使用/找到块的数量。我可以看到大多数情况下,有人放置了 (threads-1+points)/threads ,但这仍然不起作用。
- - - - - - - 更新 - - - - - - - - - - …
当我尝试从eclipse导入,并选择根目录 - >选择我拥有所有my-gdx-game-android,html,desktop的文件夹..它只导入android并显示一条消息:
无法为'my-gdx-game-android'设置项目描述,因为项目描述文件(.project)与文件系统不同步.
假设我有数组:
import numpy as np
x = np.array([1.2334, 2.3455, 3.456], dtype=np.float32)
并要打印:
print('{:.2f}%'.format(x))
它给了我:
unsupported format string passed to numpy.ndarray.__format__
我有以下代码.我的问题是我无法正确调整框架的大小.当我运行程序时,一切都如预期的那样.但是当我调整它的大小时,我想保留原始视图.
from Tkinter import *
import os
import sys
ALL=N+S+E+W
class Application(Frame):
def __init__(self,master=None):
Frame.__init__(self,master)
self.master.rowconfigure(0,weight=1)
self.master.columnconfigure(0,weight=1)
self.grid(sticky=ALL)
self.rowconfigure(0,weight=1)
myframe1=Frame(self,bg='green')
myframe1.bind("<Button-1>",self.handler1)
myframe1.grid(row=0,column=0,rowspan=1,columnspan=2,sticky=ALL)
self.rowconfigure(1,weight=1)
myframe2=Frame(self,bg='blue')
myframe2.bind("<Button-1>",self.handler2)
myframe2.grid(row=1,column=0,rowspan=1,columnspan=2,sticky=ALL)
buttons=('Red','Blue','Green','Black')
button=[0]*4
for c in range(4):
self.rowconfigure(c+2,weight=1)
self.columnconfigure(c,weight=1)
button[c]=Button(self,text="{0}".format(buttons[c]),command=lambda x=buttons[c]:self.colors(x))
button[c].grid(row=2,column=c,sticky=E+W)
self.columnconfigure(4,weight=1)
self.rowconfigure(6,weight=1)
button1=Button(self,text='{0}'.format('Open'),command=self.content)
button1.grid(row=2,column=4,sticky=E+W)
f=Frame(self,bg='red')
self.myentry=Entry(f)
self.myentry.grid(row=0,column=4,sticky=ALL)
self.text=Text(f)
self.text.grid(row=1,column=4,sticky=ALL)
f.grid(row=0,column=2,rowspan=2,columnspan=3,sticky=ALL)
...
Run Code Online (Sandbox Code Playgroud)
我试过很多的组合rowconfigure,columnconfigure,rowspan,columnspan,但我失败了!
我原来的观点是:

在朝一个方向调整大小后:

在另一个方向:

白色区域是Text我想要调整大小的小部件(也是蓝色和绿色区域).
我更新了代码.我想要做的是在指针d中保持每个拉格朗日的系数值.(例如对于L1(x)d [0]将是"x-x2/x1-x2",d 1将是(x-x2/x1-x2)*(x-x3/x1-x3)等
我的问题是
1)如何初始化d(我做了d [0] =(zx [i])/(x [k] -x [i])但我认为它不对"d [0]"
2)如何初始化L_coeff.(我使用的是L_coeff = new double [0],但我不确定它是否正确.
练习是:使用5个点(x = -1,-0.5,0,0.5和1)找出y(x)= cos(πx),x∈-1,1的拉格朗日多项式近似.
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
const double pi=3.14159265358979323846264338327950288;
// my function
double f(double x){
return (cos(pi*x));
}
//function to compute lagrange polynomial
double lagrange_polynomial(int N,double *x){
//N = degree of polynomial
double z,y;
double *L_coeff=new double [0];//L_coefficients of every Lagrange L_coefficient
double *d;//hold the polynomials values for every Lagrange coefficient
int k,i; …Run Code Online (Sandbox Code Playgroud) 如何将__m256i数据类型存储为整数?
我知道浮子有:
_mm256_store_ps(float *a, __m256 b)
Run Code Online (Sandbox Code Playgroud)
其中第一个参数是输出数组.
对于整数我只发现:
_mm256_store_si256(__m256i *a, __m256i b)
Run Code Online (Sandbox Code Playgroud)
其中两个参数都是__m256i数据类型.
做这样的事情就足够了:
int * X = (int*) _mm_malloc( N * sizeof (*X) ,32 );
Run Code Online (Sandbox Code Playgroud)
(我使用它作为函数的参数,我想获得它的值)
内功能:
__m256i * Xmmtype = (__m256i*) X;
//fill output
_mm256_store_si256( &Xmmtype[ i ] , T ); //T is __m256i
Run Code Online (Sandbox Code Playgroud)
这个可以吗?
- - -更新 - - - - - - - - - - - -
好的,如果我有:
__m256i T;
for ( y = 0; y < h; y++ )
{
for ( x = …Run Code Online (Sandbox Code Playgroud) 从这里开始.
假设dev_X是一个向量.
int * X = (int*) malloc( ThreadsPerBlockX * BlocksPerGridX * sizeof(*X) );
for ( int i = 0; i < ThreadsPerBlockX * BlocksPerGridX; i++ )
X[ i ] = i;
// create device vectors
thrust::device_vector<int> dev_X ( ThreadsPerBlockX * BlocksPerGridX );
//copy to device
thrust::copy( X , X + theThreadsPerBlockX * theBlocksPerGridX , dev_X.begin() );
Run Code Online (Sandbox Code Playgroud)
以下是减法:
thrust::transform( dev_Kx.begin(), dev_Kx.end(), dev_X.begin() , distX.begin() , thrust::minus<float>() );
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)dev_Kx - dev_X.
我想使用整个dev_Kx向量(因为它使用的是因为它从.begin到.end())和整个dev_X向量.
上面的代码使用 dev_X.begin(). …
我无法想象从这个文件读取的方式,只有整数:
34
-1
2 48
+0
++2
+1
2.4
1000
-0
three
-1
Run Code Online (Sandbox Code Playgroud)
该函数应返回:
[34, -1, 0, 1, -1]
Run Code Online (Sandbox Code Playgroud)
如果数字有效+或-有效.但如果它有++或任何字母不是.
如果它有空格(例如2 48)无效.
如果> 999则无效.
我只被困在这里:
my_list = []
with open('test.txt') as f:
lines = f.readlines()
for line in lines:
my_list.append(line.strip())
Run Code Online (Sandbox Code Playgroud)
我试图使它成为一个字符串并使用标点符号translate但我不确定它是否变得更复杂.
另外,我不确定使用正则表达式.我尝试了一个简单的正则表达式,但我没有使用它的经验.
我的数据中有一个是:
Power:
0 130
1 165
2 150
3 150
4 ?
5 198
6 220
7 215
8 225
9 ?
10 170
Run Code Online (Sandbox Code Playgroud)
我想替换每个'?' 用Nan或零。
我试过了:
data['Power'].str.replace('?', 0).astype(float)
data['Power'].str.replace('^[^\d]*', '').astype(float)
data['Power'].replace(r'\s+', np.nan, regex=True)
data['Power'].convert_objects(convert_numeric=True)
data['Power'].replace(regex=True,inplace=True,to_replace=r'\D',value=r'')
Run Code Online (Sandbox Code Playgroud)
但是这些都不起作用!
有些会产生错误,could not convert string to float而有些则不会产生任何错误,但不会更改'?'。