小编kev*_*sco的帖子

Visual Studio只在第二行程序集中断?

简短说明:

.CODE在汇编程序中在段的第一行设置断点不会停止程序的执行.

问题:

那么Visual Studio的调试器会使它无法在汇编程序的第一行创建断点?这是调试器的一些奇怪之处,打破多字节指令的情况,还是我只是在做一些愚蠢的事情?

细节:

我有以下汇编程序在Visual Studio中编译和运行:

; Tell MASM to use the Intel 80386 instruction set.
.386
; Flat memory model, and Win 32 calling convention
.MODEL FLAT, STDCALL
; Treat labels as case-sensitive (required for windows.inc)
OPTION CaseMap:None

include windows.inc
include masm32.inc
include user32.inc
include kernel32.inc
include macros.asm

includelib masm32.lib
includelib user32.lib
includelib kernel32.lib

.DATA
    BadText     db      "Error...", 0
    GoodText    db      "Excellent!", 0

.CODE
main PROC
        ;int 3           ; <-- If uncommented, this will not break. …
Run Code Online (Sandbox Code Playgroud)

assembly masm visual-studio-2010

5
推荐指数
1
解决办法
684
查看次数

C++错误:请求'grmanager'中的成员'...',它是非类型的'GraphicsManager'

我的类GraphicsManager已经出错了.

GraphicsManager.cpp:

#include "C:\Users\Chris Uzzolina\Desktop\obj\include\GraphicsManager.h"
#include <SDL.h>
#include <string>
GraphicsManager::GraphicsManager(int SCREEN_WIDTH, int SCREEN_HEIGHT, int SCREEN_BPP,  std::string caption, SDL_Surface *screen)
{

}

GraphicsManager::~GraphicsManager()
{
    //dtor
}
bool init(int SCREEN_WIDTH, int SCREEN_HEIGHT, int SCREEN_BPP, std::string caption, SDL_Surface *scr)
{
    //Initialize all SDL subsystems
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return false;
    }

    //Set up the screen
    scr = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );

    //If there was an error in setting up the screen
    if( scr == NULL )
    { …
Run Code Online (Sandbox Code Playgroud)

c++ sdl

5
推荐指数
1
解决办法
662
查看次数

推力表现::计数

我将以下代码作为重组数据的一部分,以便以后在CUDA内核中使用:

thrust::device_ptr<int> dev_ptr = thrust::device_pointer_cast(dev_particle_cell_indices);
int total = 0;
for(int i = 0; i < num_cells; i++) {
    particle_offsets[i] = total;
    // int num = 0;
    int num = thrust::count(dev_ptr, dev_ptr + num_particles, i);
    particle_counts[i] = num;
    total += num;
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我设置num为0(取消注释第5行,并注释掉第6行),应用程序将以超过30 fps的速度运行,这是我的目标.但是,当我设置num等于thrust::count呼叫时,帧率降至约1-2 fps.为什么会这样?

我的理解是,推力应该是高度优化的算法的集合,利用GPU的强大功能,所以我很惊讶它会对我的程序的性能产生这样的影响.这是我第一次使用推力,所以我可能没有意识到一些重要的细节.

是否有关于thrust::count在循环中使用导致它运行如此缓慢的事情?如何优化我的使用?

在我目前的测试案例中,给出一些数字num_particles大约是2000,num_cells大概是1500.

cuda thrust

4
推荐指数
2
解决办法
2100
查看次数

为什么以下代码进入无限循环?

请考虑以下代码:

const char *s = "a   b    c  d !";
const char *p = s;

top:for(; *p; p++) {
    switch(*p) {
    case 0x20: 
    case '\n': 
        goto top;
    default: 
        putchar(*p);
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么它进入无限循环,而不是停止时*pNULL?我想到了以下几点:当*p0x20\n再次回到循环的开始,因为它测试的条件和计算表达式p++.所以,我没有看到它无限循环的原因,或者我真的没有得到C语言中的goto语句和labels工作方式.

c for-loop goto infinite-loop

0
推荐指数
1
解决办法
220
查看次数

标签 统计

assembly ×1

c ×1

c++ ×1

cuda ×1

for-loop ×1

goto ×1

infinite-loop ×1

masm ×1

sdl ×1

thrust ×1

visual-studio-2010 ×1