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
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ispc-users/b83cfaa0-be0b-46ce-b47d-708e53ea532b%40googlegroups.com.