returning struct by value from ispc-exported function?

40 views
Skip to first unread message

Михаил Усачёв

unread,
Oct 21, 2019, 3:29:45 PM10/21/19
to Intel SPMD Program Compiler Users
Hi all !
I can not get at c++-side a struct by value from exported ispc-function (ispc v1.12 and msvc 2017 are used). Program compiles and runs smoothly (32bit, debug mode), except i have empty fields where i expect non-zero values. In 32bit release mode i have slightly different values. In 64bit i always have zeros at c++-side. I have not found any direct mention or example of such snippet around. Bundled samples contain only void or primitive types returning exported functions.. My code:

kernel.ispc:

struct fp32_2 { float v0, v1; };

export uniform fp32_2 loopback( uniform float arg0, uniform float arg1 ){
    uniform fp32_2 result;
    result.v0 = arg0;
    result.v1 = arg1;
    print( "ispc side: v0 = %\n", result.v0 );
    print( "ispc side: v1 = %\n", result.v1 );
    return result;
    }

kernel.h (generated by ispc, related parts):

#ifndef __ISPC_STRUCT_fp32_2__
#define __ISPC_STRUCT_fp32_2__
struct fp32_2 {
    float v0;
    float v1;
};
#endif
...
extern "C"{
    extern struct fp32_2 loopback(float arg0, float arg1);
}

main.cpp:

#include "kernel.h"
#include <iostream>

int main(){
    auto res = ispc::loopback( 10.0f, 11.0f );
    std::cout << "c++ side: v0 = " << res.v0 << "\n";
    std::cout << "c++ side: v1 = " << res.v1 << "\n";
    }

command line parameters for ispc file compiling (for 32bit debug mode):

ispc %(FullPath) --arch=x86 --target-os=windows --target=sse4-i32x4
-O1 --opt=disable-loop-unroll --emit-obj --outfile=$(IntDir)%(FileName).obj
--header-outfile=%(RootDir)%(Directory)%(Filename).h --werror -g

output (32 bit debug mode or 64bit both modes):

ispc side: v0 = 10.000000
ispc side: v1 = 11.000000
c++ side: v0 = 0
c++ side: v1 = 0

output (32bit release mode):

ispc side: v0 = 10.000000
ispc side: v1 = 11.000000
c++ side: v0 = 0
c++ side: v1 = 5.39308e+33

Each run i got same values. What am i missing or doing wrong ?

Thanks in advance
Message has been deleted

Михаил Усачёв

unread,
Oct 21, 2019, 5:04:19 PM10/21/19
to Intel SPMD Program Compiler Users
ispc-program compiled to avx1 always gives zeros. My CPU is AMD fx-8350 (avx1 is supported).
I can not  attach VS 2017 solution (groups.google.com gives me "error occurs")...

Dmitry Babokin

unread,
Oct 21, 2019, 5:46:33 PM10/21/19
to ispc-...@googlegroups.com
Michael,

This is supposed to work. Please file an issue.

Dmitry.

On Mon, Oct 21, 2019 at 2:04 PM Михаил Усачёв <michael...@gmail.com> wrote:
ispc-program compiled to avx1 always gives zeros. My CPU is AMD fx-8350 (avx1 is supported).
I can not  attach VS 2017 solution (groups.google.com gives me "error occurs")...

--
You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ispc-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ispc-users/c8b43e10-84c3-4642-98c0-26c0c1dfbad1%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages