CUDA:编译我的第一个cuda程序时出错(CUDA: Error while compiling my first cuda program)
我是CUDA编程的新手。我编写了我的第一个代码,当我编译它时,它向我显示了很多错误。 任何人都可以告诉我有什么问题
代码
#include <stdio.h> #include "cuda.h" #include <stdlib.h> __global__ void kernel(void) { } int main(int argc, char *argv[]) { kernel<<<1,1>>>(); printf("finished \n"); return 0; }
错误是
cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ cuda.c: In function âmainâ: cuda.c:12: error: âkernelâ undeclared (first use in this function) cuda.c:12: error: (Each undeclared identifier is reported only once cuda.c:12: error: for each function it appears in.) cuda.c:12: error: expected expression before â<â token
我编译使用
nvcc cuda.c
谁能告诉我我犯的是什么错误....
I am very new to CUDA programming.. I wrote my first code and when I compiled it, it is showing me a lots of error. Can anyone tell me what is wrong
the code
#include <stdio.h> #include "cuda.h" #include <stdlib.h> __global__ void kernel(void) { } int main(int argc, char *argv[]) { kernel<<<1,1>>>(); printf("finished \n"); return 0; }
The errors are
cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ cuda.c: In function âmainâ: cuda.c:12: error: âkernelâ undeclared (first use in this function) cuda.c:12: error: (Each undeclared identifier is reported only once cuda.c:12: error: for each function it appears in.) cuda.c:12: error: expected expression before â<â token
I compiled using
nvcc cuda.c
Can anyone tell me what mistake I am making....
原文:https://stackoverflow.com/questions/4362455
更新时间:2022-09-12 20:09
最满意答案
使用
MergeArea
?Sub showRandomWord() Dim ws As Worksheet, ws2 As Worksheet Dim stRow As Long, endRow As Long, dataCol As Long Dim dispRow As Long, dispCol As Long Set ws = Sheets("Sheet1") Set ws2 = Sheets("Sheet2") stRow = 2 dataCol = 1 dispRow = 2 dispCol = 2 With ws endRow = .Cells(.Rows.Count, dataCol).End(xlUp).Row End With ws2.Cells(dispRow, dispCol).Value = "" ws.Cells(Application.RandBetween(stRow, endRow), dataCol).Value ws2.Range("J2").MergeArea.ClearContents End Sub
Use
MergeArea
?Sub showRandomWord() Dim ws As Worksheet, ws2 As Worksheet Dim stRow As Long, endRow As Long, dataCol As Long Dim dispRow As Long, dispCol As Long Set ws = Sheets("Sheet1") Set ws2 = Sheets("Sheet2") stRow = 2 dataCol = 1 dispRow = 2 dispCol = 2 With ws endRow = .Cells(.Rows.Count, dataCol).End(xlUp).Row End With ws2.Cells(dispRow, dispCol).Value = "" ws.Cells(Application.RandBetween(stRow, endRow), dataCol).Value ws2.Range("J2").MergeArea.ClearContents End Sub
相关问答
更多-
您正在寻找一个Calculate选项而不是RefreshAll选项 我建议你使用Application.CalculateFull来计算所有公式 Charles Williams对Excel计算方法的这一链接可能证明是有用的 Rather than a RefreshAll option you are looking for a Calculate option I suggest you use Application.CalculateFull to calculate all formulae Th ...
-
使用MergeArea ? Sub showRandomWord() Dim ws As Worksheet, ws2 As Worksheet Dim stRow As Long, endRow As Long, dataCol As Long Dim dispRow As Long, dispCol As Long Set ws = Sheets("Sheet1") Set ws2 = Sheets("Sheet2") stRow = 2 dataCol = 1 dispRow = 2 dispCol ...
-
改变这个: month = Worksheet(2).Cells(31, "J") 对此: month = Worksheet(2).Cells(31, "J").Value 和这个: Sheet1.Range("C" & num & ":C18") = 34 对此: For Each c in Worksheet(1).Range("C" & num & ":C18") c.Value = 34 Next c Change this: month = Worksheet(2).Cells(31 ...
-
VBA运行时1004错误(VBA run-time 1004 error)[2022-07-14]
这对我有效... Sub Tester() Dim c As Range, cTot As Range, s As Series 'collect all values for "40" For Each c In Range("D1:D27").Cells If c.Offset(0, -1) = 40 Then If cTot Is Nothing Then Set cTot = c ... -
尝试: PROGGRAPH.Range("A5", "A93") Try: PROGGRAPH.Range("A5", "A93")
-
Excel VBA运行时错误1004(Excel VBA runtime error 1004)[2022-03-20]
原因很简单,当您从CSV复制然后在工作簿中复制时,单击开发人员工具栏中的Macros ,Excel将清除剪贴板。 当您单击Developer | Macros时,Excel有清除剪贴板的习惯 Developer | Macros 。 为了演示这一点,请从同一工作簿中复制单元格。 你会看到蚂蚁像细胞周围的边界。 现在在同一个工作簿中,单击Developer | 宏。 像边框一样的Ant会消失:) 设置宏的快捷键并使用它。 它会工作:) The reason is very simple, When you c ... -
你的最后一行, Debug.Print wksPivotData.Range(1, 1).Value将不会打印,因为你错过了Range() 。 我想你想要A1? 使用Range(1,1) ,您指的是不存在的范围。 如果你想做单元格A1,你需要 With wksPivotData myData = .Range(.Cells(1,1),.Cells(1,1)).Value End with 由于您使用的是多个工作表,因此我将使用上面的with语句。 编写相同内容的另一种方法是wksPivotData. ...
-
VBA - 运行时错误1004(VBA - Runtime error 1004)[2023-03-27]
您的copyPath只是一个文件夹,但SaveCopyAs的参数应该是带文件名的完整路径。 试试这个: ThisWorkbook.SaveCopyAs copyPath & "\filename.xlsx" Your copyPath is only a folder, but the argument of SaveCopyAs should be a full path with file name. Try this: ThisWorkbook.SaveCopyAs copyPath & "\file ... -
问题是当变量表示为字符串时,它将具有系统的小数点。 在你的情况下它是一个逗号,所以你需要将它转换为点,例如使用replace()函数。 The problem is when a variable is represented as string it will have the system's decimal point. In your case it is a comma so you need to convert it to dot, for example using replace() fu ...
-
您要求vLookup返回2列范围,而不是1列范围。 更改BRange =“A2:B9”以使您的vLookup获取标准普尔价值。 或者,您可以将范围更改为A2:C9,并在vLookup中将2更改为3并获得DJ平均值。 简而言之,vLookup只能将列引用返回到范围中的最大列数。 它可以返回3列范围内的第1,第2,第3列参考,但不能返回第4列,因为没有第4列。 You are asking vLookup to return on a 2 column range, against a 1 column ran ...