Giter Site home page Giter Site logo

Comments (7)

ebahapo avatar ebahapo commented on July 18, 2024 1

Rather, shouldn't a library that supported RVV set vxrm as part of supporting fenv.h instead?

from rvv-intrinsic-doc.

zakk0610 avatar zakk0610 commented on July 18, 2024

We had purposed vread_csr and vwrite_csr interface here, but it is not included in intrinsic RFC and function list yet

enum RVV_CSR {
  RVV_VSTART = 0,
  RVV_VXSAT,
  RVV_VXRM,
  RVV_VCSR,
};

unsigned long vread_csr(enum RVV_CSR csr);
void vwrite_csr(enum RVV_CSR csr, unsigned long value);

Any comments or suggestions will be appreciated.

from rvv-intrinsic-doc.

arcbbb avatar arcbbb commented on July 18, 2024

I prefer HK's idea having specific API to read/set vector rounding mode.
In that way user doesn't need to know the format of CSR in order to read the content.

from rvv-intrinsic-doc.

kito-cheng avatar kito-cheng commented on July 18, 2024

I prefer high-level API for that too, the only concern to me is it's not intrinsic.

from rvv-intrinsic-doc.

HanKuanChen avatar HanKuanChen commented on July 18, 2024

@kito-cheng do you think this is a semantic intrinsic?
If so, I think we should add this.

from rvv-intrinsic-doc.

HanKuanChen avatar HanKuanChen commented on July 18, 2024

I propose a new pull request #46 and a simple implementation here.

#define VE_TONEARESTUP 0
#define VE_TONEARESTEVEN 1
#define VE_DOWNWARD 2
#define VE_TOODD 3
// Each of these macro constants expands to a nonnegative integer constant expression.

// return 0 on success, non-zero otherwise.
int vesetxround(int round)
{
	switch(round)
	{
	case VE_TONEARESTUP:
	case VE_TONEARESTEVEN:
	case VE_DOWNWARD:
	case VE_TOODD:
		asm volatile("csrw vxrm,%z0"::"rJ"(round));
		return 0;
	default:
		return -1;
	}
}

// return the current rounding macro, negative value if the rounding mode cannot be determined.
int vegetxround(void)
{
	int vxrm;
	asm volatile("csrr %0,vxrm":"=r"(vxrm));
	switch(vxrm)
	{
	case VE_TONEARESTUP:
	case VE_TONEARESTEVEN:
	case VE_DOWNWARD:
	case VE_TOODD:
		return vxrm;
	default:
		return -1;
	}
}

// clear vxsat
inline void veclearxsat(void)
{
	asm volatile("csrw vxsat,x0");
}

// return 1 if vxsat is set, 0 otherwise.
inline int vetestxsat(void)
{
	int vxsat;
	asm volatile("csrr %0,vxsat":"=r"(vxsat));
	return vxsat;
}

from rvv-intrinsic-doc.

kito-cheng avatar kito-cheng commented on July 18, 2024

We define vxrm and vxsat as call clobber in psABI, so this proposal become impossible to implement now.

[1] riscv-non-isa/riscv-elf-psabi-doc#294

from rvv-intrinsic-doc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.